Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bindcode --release does not work (but bindsym --release does) #2733

Closed
herrsimon opened this issue Apr 8, 2017 · 13 comments · Fixed by #3179
Closed

bindcode --release does not work (but bindsym --release does) #2733

herrsimon opened this issue Apr 8, 2017 · 13 comments · Fixed by #3179
Labels
4.13 bug reproducible A bug that has been reviewed and confirmed by a project contributor

Comments

@herrsimon
Copy link

Hello,

I'm trying to show an xclock window only while a key is pressed, as is the case for i3bar in hide mode. Technically, this would be possible if i3 allowed assigning different commands when pressing and releasing the same key, i.e. one could then write

keysym [KEY] [COMMAND1]
keysym --release [KEY] [COMMAND2]

As far as I understand, the current behaviour is to only use the keybinding which appears last in the configuration file.

Does anything speak against allowing such a double-binding on press and release for both the keysym and keycode statement? Maybe, to avoid confusion, one could also implement some new option like

keysym --pressrelease [KEY] [COMMAND1] [COMMAND2]

Best,

Simon

@i3bot i3bot added missing-log Read the CONTRIBUTING.md file for instructions missing-version labels Apr 8, 2017
@Airblader Airblader added 4.13 enhancement accepted Has been approved and is ok to start working on and removed missing-log Read the CONTRIBUTING.md file for instructions missing-version labels Apr 9, 2017
@Airblader
Copy link
Member

Allowing this makes sense to me. I think we should avoid a new flag for this. Using --release is the right way.

@nmschulte
Copy link
Contributor

nmschulte commented Apr 13, 2017

As I understand, this (--release bindings being distinct from non---release bindings) works as one expects:

bindsym $mod+b exec notify-send "$mod+b"
bindsym --release $mod+b exec notify-send "$mod+b --release"

-- I played with this for #2442

@herrsimon
Copy link
Author

@nmschulte Thanks for looking at this. Your example works perfectly here, however, what I'm trying to do (and didn't mention as I didn't know that it apparently makes a difference) is binding two different commands to the $mod key. I'm trying to achieve this via keycodes, i.e. for me the relevant configuration would read ($mod is caps lock with keycode 66 , the behaviour is reproduceable when $mod is the windows or alt key):

bindcode 66 exec notify-send "press"
bindcode --release 66 exec notify-send "release".

The "press" notification is shown but the "release"-command isn't executed.

@nmschulte
Copy link
Contributor

nmschulte commented Apr 14, 2017

This must be a difference between bindsym and bindcode, I imagine. See update below.

This works for me and seems like it'll suffice for you:

bindsym $mod+Caps_Lock exec notify-send "press"
bindsym --release $mod+Caps_Lock exec notify-send "release"

$mod is caps lock with keycode 66

Keycode 66 is Caps_Lock. Using it with bindcode and bindcode --release gives the expected behavior for me: pressing Caps_Lock is caught by the regular bindcode and releasing is caught by the bindcode --release statement.

@Airblader Airblader added bug and removed accepted Has been approved and is ok to start working on enhancement labels Apr 17, 2017
@Airblader
Copy link
Member

I'm changing this to a bug issue since apparently it should work already… :-)

@stapelberg stapelberg added the reproducible A bug that has been reviewed and confirmed by a project contributor label Aug 20, 2017
@stapelberg
Copy link
Member

I can reproduce this with 4.13-197-ge6682f86: bindsym’s --release option works as @nmschulte explained, but for bindcode, it doesn’t work.

@stapelberg stapelberg changed the title [feature-request] assign different commands to key press and release bindcode --release does not work (but bindsym --release does) Aug 20, 2017
@ghost
Copy link

ghost commented Jan 25, 2018

What's the state of this issue? I'm still experiencing it in v4.14.1. However, for me, neither bindsym nor bindcode (+ --release) flag works. Trying to have Mod4 (which is Super_L) to execute a command on keypress and another on key release but nothing works so far; only the first command of the two works. For example:

# Both bindsym and bindcode didn't work.

bindsym Super_L exec <a command>      # This one works.
bindsym --release Super_L exec <a command>      # But not this one.

@Airblader
Copy link
Member

What's the state of this issue?

screenshot-2018-01-25_12-20-38

@nmschulte
Copy link
Contributor

nmschulte commented Jan 25, 2018

The following works for me w/ Debian Sid packaged i3.

nmschulte@desmas-l:~$ i3 -v && aptitude show i3 | grep Version
i3 version 4.14.1 (2017-09-24) © 2009 Michael Stapelberg and contributors
Version: 4.14.1-1
bindcode 66 exec notify-send "bc $mod"
bindcode --release 66 exec notify-send "bc $mod --release"

demo


bindsym --release Super_L exec <a command> # But not this one. also does not work as expected for me. Using xev, Super_L key events do not appear either.

Swapping the order of the bindsym/.. --release for Super_L is funky too. With --release before, neither of the two commands seem to work. With --release after, only the "press" command works.

bindsym --release Super_L exec notify-send "<a command> release"
bindsym Super_L exec notify-send "<a command> press"

@ghost
Copy link

ghost commented Jan 25, 2018

@Airblader Lol fair enough xD
It's just that this issue has been bugging me lately, so I just want to know if anyone has been working on/has figured out any temporary solution to this.
Anyway, sorry if I asked such a retarded question...

@nmschulte Just tried and unfortunately, it does not work for me. My code:

# 133 is the code for Super_L, which is Mod4
bindcode 133 exec notify-send "normal"      # This works
bindcode --release 133 exec notify-send "release"      # This doesn't

Edit: Should have mentioned: Mod4 is also my $mod key. If I use bindcode on other keys (such as bindcode 66 as mentioned before), it works as expected. But for my $mod key (Super_L) and also Alt_L, it doesn't work.

@klemens
Copy link

klemens commented Jan 26, 2018

Using Super_L as modifier and single key works fine for me with 4.14.1 using a combination of bindcode and bindsym, see #3024 for details.

@ghost
Copy link

ghost commented Jan 26, 2018

@klemens Unfortunately it didn't work for me. I've tried all combinations, including bindsym + bindcode, with different commands but no luck :(

My code:

bindsym Super_L exec notify-send "hello"      # This one works
bindcode --release 133 exec notify-send "hi"      # But this one doesn't

If I comment out one of the lines, the other one will work.

orestisfl added a commit to orestisfl/i3 that referenced this issue Mar 16, 2018
Before this commit, get_binding() exited on the first match without
marking the rest --release bindings with B_UPON_KEYRELEASE_IGNORE_MODS.

Similarly, once it found a --release binding during a KeyPress event it
would stop searching for a matching key press binding.

Example config, placing the --release line first will trigger the second
problem:

bindsym Super_L exec notify-send "press"
# or
# bindcode 133 exec notify-send "press"
bindsym --release Super_L exec notify-send "release"
# or
# bindcode --release 133 exec notify-send "release"

Fixes i3#2733
orestisfl added a commit to orestisfl/i3 that referenced this issue Mar 16, 2018
Before this commit, get_binding() exited on the first match without
marking the rest --release bindings with B_UPON_KEYRELEASE_IGNORE_MODS.

Similarly, once it found a --release binding during a KeyPress event it
would stop searching for a matching key press binding.

Example config, placing the --release line first will trigger the second
problem:

bindsym Super_L exec notify-send "press"
# or
# bindcode 133 exec notify-send "press"
bindsym --release Super_L exec notify-send "release"
# or
# bindcode --release 133 exec notify-send "release"

Fixes i3#2733
orestisfl added a commit to orestisfl/i3 that referenced this issue Mar 16, 2018
Before this commit, get_binding() exited on the first match without
marking the rest --release bindings with B_UPON_KEYRELEASE_IGNORE_MODS.

Similarly, once it found a --release binding during a KeyPress event it
would stop searching for a matching key press binding.

Example config, placing the --release line first will trigger the second
problem:

# i3 config file (v4)
bindsym Super_L exec notify-send "press"
# or
# bindcode 133 exec notify-send "press"
bindsym --release Super_L exec notify-send "release"
# or
# bindcode --release 133 exec notify-send "release"

Fixes i3#2733
orestisfl added a commit to orestisfl/i3 that referenced this issue Mar 17, 2018
…ease

Before this commit, get_binding() exited on the first match without
marking the rest --release bindings with B_UPON_KEYRELEASE_IGNORE_MODS.

Similarly, once it found a --release binding during a KeyPress event it
would stop searching for a matching key press binding.

Example config, placing the --release line first will trigger the second
problem:

# i3 config file (v4)
bindsym Super_L exec notify-send "press"
# or
# bindcode 133 exec notify-send "press"
bindsym --release Super_L exec notify-send "release"
# or
# bindcode --release 133 exec notify-send "release"

Fixes i3#2733
orestisfl added a commit to orestisfl/i3 that referenced this issue Mar 20, 2018
…ease

Before this commit, get_binding() exited on the first match without
marking the rest --release bindings with B_UPON_KEYRELEASE_IGNORE_MODS.

Similarly, once it found a --release binding during a KeyPress event it
would stop searching for a matching key press binding.

Example config, placing the --release line first will trigger the second
problem:

# i3 config file (v4)
bindsym Super_L exec notify-send "press"
# or
# bindcode 133 exec notify-send "press"
bindsym --release Super_L exec notify-send "release"
# or
# bindcode --release 133 exec notify-send "release"

Fixes i3#2733
@sinh3ck
Copy link

sinh3ck commented Jun 12, 2018

@klemens Your workaround seems to almost solve the problem. I say almost because for me, floating_modifier Mod4 stops working.

orestisfl added a commit to orestisfl/i3 that referenced this issue Jul 12, 2018
…ease

Before this commit, get_binding() exited on the first match without
marking the rest --release bindings with B_UPON_KEYRELEASE_IGNORE_MODS.

Similarly, once it found a --release binding during a KeyPress event it
would stop searching for a matching key press binding.

Example config, placing the --release line first will trigger the second
problem:

# i3 config file (v4)
bindsym Super_L exec notify-send "press"
# or
# bindcode 133 exec notify-send "press"
bindsym --release Super_L exec notify-send "release"
# or
# bindcode --release 133 exec notify-send "release"

Fixes i3#2733
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
4.13 bug reproducible A bug that has been reviewed and confirmed by a project contributor
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants