You are not logged in.
Offline
This solution, while unelegant, works. I don't understand why the function keys need to be prefixed by @. Is this a limitation with X?
Also, I still cannot get the number pad to work. It might be some similar hidden modifier business. The whole point for me is to use the keypad as single-key shortcuts.
Appreciate the help!
Offline
Offline
Yes, but what is special about the Fn keys? A-Z 1-9 etc work fine without the @.
And what could be causing the numpad keys (KP_0..9) not to work?
Offline
I don't understand why the function keys need to be prefixed by @.
Hotkey daemons use passive keyboard grabbing. It means that when one of the registered combinations is pressed, the keyboard is grabbed (no other clients receive keyboard events) and is ungrabbed when the combination's key is released.
So, it is mainly useful for programs that emit fake keyboard events and programs that tries to grab the keyboard (e.g.: scrot -s).
Also, I still cannot get the number pad to work.
What does xev say about your KP_0-9 keys?
You could create a debug executable with make debug and try this simple configuration:
KP_0
echo hello
Offline
Will do a debug compile.
In the mean time, I noticed that some shortcut that seemed to fail actually work if pressed twice very fast. No numkeys though.
Does this sound like a clue?
Offline
Here's the debug output:
./sxhkd -c config
keysym for 'Alt_L' is 0xFFE9.
keysym for 'Alt_R' is 0xFFEA.
keysym for 'Super_L' is 0xFFEB.
keysym for 'Super_R' is 0xFFEC.
keysym for 'Hyper_L' is 0xFFED.
keysym for 'Hyper_R' is 0xFFEE.
keysym for 'Mode_switch' is 0xFF7E.
keysym for 'Num_Lock' is 0xFF7F.
keysym for 'Scroll_Lock' is 0xFF14.
lock fields 16 2 0
load configuration 'config'
hotkey 65438 0 1 2 echo hello
grab
keycode for 65438 is 90
grab key 90 1
grab key 90 17
grab key 90 3
grab key 90 19
000
Another thing that fails is 'backslash'.
Offline
Bloom,
This tool could be very useful for the hordes of people coming from windows and missing autohotkey. All the lifehacker crowd would be all over this, if they could do everything with xdotool, wctrl, and friends.
Offline
And here's the output for this real config file:
# some shortcuts must be set in the gnome wm, with dconf-editor
# some other depend on the gnome shell extension shellshape, a tiling wm
# NOTE for window specific shortcuts:
# Have a look at xdotool. Use it to get the window id first, say for gimp
# win=$(xdotool search --onlyvisible --class gimp | head -1)
# then to send it a key combo
# xdotool key --clearmodifiers --window $win Ctrl+q
# or to switch to it
# xdotool windowactivate $win
# The following are done with gnome settings > keyboard
# send to master => print
# copy => scroll lock # fails
# paste => pause
##################################
# FOCUS different windows
##################################
super + apostrophe
focus.py pycharm.sh
super + e
marlin
super + n
focus.py marlin
super + slash
focus.py firefox
shift + BackSpace
focus.py chrome
# gnome terminal
super + r
focus.py gnome-terminal
super + Return
gnome-terminal
# send to master in shellshape (no idea why this works, but ctrl c doesn't)
shift + @F12
xdotool key --clearmodifiers super+shift+space
##################################
# below, test ground. All full of fail
##################################
# what we know:
# - numpad fails
# - any key that is not a straight letter fails
# - xdotool works in mysterious ways
# copy = fails
backslash
# xte 'keydown Control_L' 'key c' 'keyup Control_L' NO
xdotool key --clearmodifiers Control_L+c
# xte 'keyup Alt_L' 'keyup Alt_R' 'keydown Control_L' 'key c' 'keyup Control_L'
# Super_R+t
# xdotool key --clearmodifiers ctrl+c
@Num_Lock
# xte 'keydown Control_L' 'key c' 'keyup Control_L' NO
# xdotool key --clearmodifiers Control_L+c
xte 'keyup Alt_L' 'keyup Alt_R' 'keydown Control_L' 'key c' 'keyup Control_L'
@KP_6
# xte 'keydown Control_L' 'key c' 'keyup Control_L' NO
# xdotool key --clearmodifiers Control_L+c
xte 'keyup Alt_L' 'keyup Alt_R' 'keydown Control_L' 'key d' 'keyup Control_L'
# map prior, next to move by block in idea # does NOT work
@KP_9
xdotool key --clearmodifiers Control_L+t
super + @F5
pkill -USR1 -x sxhkd
KP_0
echo hello
KP_Add
xdotool getactivewindow windowmove 0 0
./sxhkd -c ~/.config/sxhkd/sxhkdrc
keysym for 'Alt_L' is 0xFFE9.
keysym for 'Alt_R' is 0xFFEA.
keysym for 'Super_L' is 0xFFEB.
keysym for 'Super_R' is 0xFFEC.
keysym for 'Hyper_L' is 0xFFED.
keysym for 'Hyper_R' is 0xFFEE.
keysym for 'Mode_switch' is 0xFF7E.
keysym for 'Num_Lock' is 0xFF7F.
keysym for 'Scroll_Lock' is 0xFF14.
lock fields 16 2 0
load configuration '/home/quesada/.config/sxhkd/sxhkdrc'
hotkey 39 0 64 2 focus.py pycharm.sh
hotkey 102 0 192 2 marlin
hotkey 101 0 64 2 marlin
hotkey 110 0 64 2 focus.py marlin
hotkey 107 0 192 2 focus.py marlin
hotkey 47 0 64 2 focus.py firefox
hotkey 65288 0 1 2 focus.py chrome
hotkey 65288 0 1 2 focus.py chrome
hotkey 112 0 192 2 focus.py gnome-terminal
hotkey 114 0 64 2 focus.py gnome-terminal
hotkey 65293 0 64 2 gnome-terminal
hotkey 92 0 0 2 # xte 'keydown Control_L' 'key c' 'keyup Control_L' NO
hotkey 92 0 0 2 # xte 'keydown Control_L' 'key c' 'keyup Control_L' NO
hotkey 65481 0 1 3 xdotool key --clearmodifiers super+shift+space
hotkey 65407 0 0 3 # xte 'keydown Control_L' 'key c' 'keyup Control_L' NO
hotkey 65432 0 1 3 # xte 'keydown Control_L' 'key c' 'keyup Control_L' NO
hotkey 65434 0 1 3 xdotool key --clearmodifiers Control_L+t
hotkey 65474 0 64 3 pkill -USR1 -x sxhkd
hotkey 65438 0 1 2 echo hello
hotkey 65451 0 0 2 xdotool getactivewindow windowmove 0 0
grab
keycode for 65451 is 86
grab key 86 0
grab key 86 16
grab key 86 2
grab key 86 18
keycode for 65438 is 90
grab key 90 1
grab key 90 17
grab key 90 3
grab key 90 19
keycode for 65474 is 71
grab key 71 64
grab key 71 80
grab key 71 66
grab key 71 82
keycode for 65434 is 81
grab key 81 1
grab key 81 17
grab key 81 3
grab key 81 19
keycode for 65432 is 85
grab key 85 1
grab key 85 17
grab key 85 3
grab key 85 19
keycode for 65407 is 77
grab key 77 0
grab key 77 16
grab key 77 2
grab key 77 18
keycode for 65481 is 96
grab key 96 1
grab key 96 17
grab key 96 3
grab key 96 19
keycode for 92 is 51
grab key 51 0
grab key 51 16
grab key 51 2
grab key 51 18
keycode for 92 is 94
grab key 94 0
grab key 94 16
grab key 94 2
grab key 94 18
keycode for 92 is 51
grab key 51 0
grab key 51 16
grab key 51 2
grab key 51 18
keycode for 92 is 94
grab key 94 0
grab key 94 16
grab key 94 2
grab key 94 18
keycode for 65293 is 36
grab key 36 64
grab key 36 80
grab key 36 66
grab key 36 82
keycode for 114 is 39
grab key 39 64
grab key 39 80
grab key 39 66
grab key 39 82
keycode for 112 is 27
grab key 27 192
grab key 27 208
grab key 27 194
grab key 27 210
keycode for 65288 is 22
grab key 22 1
grab key 22 17
grab key 22 3
grab key 22 19
keycode for 65288 is 66
grab key 66 1
grab key 66 17
grab key 66 3
grab key 66 19
keycode for 65288 is 22
grab key 22 1
grab key 22 17
grab key 22 3
grab key 22 19
keycode for 65288 is 66
grab key 66 1
grab key 66 17
grab key 66 3
grab key 66 19
keycode for 47 is 61
grab key 61 64
grab key 61 80
grab key 61 66
grab key 61 82
keycode for 107 is 57
grab key 57 192
grab key 57 208
grab key 57 194
grab key 57 210
keycode for 110 is 44
grab key 44 64
grab key 44 80
grab key 44 66
grab key 44 82
keycode for 101 is 45
grab key 45 64
grab key 45 80
grab key 45 66
grab key 45 82
keycode for 102 is 26
grab key 26 192
grab key 26 208
grab key 26 194
grab key 26 210
keycode for 39 is 48
grab key 48 64
grab key 48 80
grab key 48 66
grab key 48 82
^[[Creceived event 34
received event 34
received event 34
received event 34
This is interesting:
hotkey 92 0 0 2 # xte 'keydown Control_L' 'key c' 'keyup Control_L' NO
hotkey 92 0 0 2 # xte 'keydown Control_L' 'key c' 'keyup Control_L' NO
hotkey 65481 0 1 3 xdotool key --clearmodifiers super+shift+space
hotkey 65407 0 0 3 # xte 'keydown Control_L' 'key c' 'keyup Control_L' NO
hotkey 65432 0 1 3 # xte 'keydown Control_L' 'key c' 'keyup Control_L' NO
They shortcuts that fail have a NO a the end. What does this mean?
Offline
Ok, I see:
xmodmap -pke | grep KP_0
yields
keycode 90 = KP_Insert KP_0 KP_Insert KP_0
So, just replace KP_0 with KP_Insert.
The problem is that you're expecting sxhkd to interpret the num lock mask as the shift mask for certain keycodes whereas it just ignores any lock mask.
Last edited by bloom (2013-01-25 11:07:13)
Offline
In the xte examples, you only need to artificially release the modifiers, so this:
@Num_Lock
xte 'keyup Alt_L' 'keyup Alt_R' 'keydown Control_L' 'key c' 'keyup Control_L'
should be simply written:
@Num_Lock
xte 'keydown Control_L' 'key c' 'keyup Control_L'
Offline
Well, here's what I got:
# some shortcuts must be set in the gnome wm, with dconf-editor
# some other depend on the gnome shell extension shellshape, a tiling wm
# NOTE for window specific shortcuts:
# Have a look at xdotool. Use it to get the window id first, say for gimp
# win=$(xdotool search --onlyvisible --class gimp | head -1)
# then to send it a key combo
# xdotool key --clearmodifiers --window $win Ctrl+q
# or to switch to it
# xdotool windowactivate $win
##################################
# FOCUS different windows
##################################
super + apostrophe
focus.py pycharm.sh
super + e
marlin
super + n
focus.py marlin
super + slash
focus.py firefox
shift + BackSpace
focus.py chrome
# gnome terminal
super + r
focus.py gnome-terminal
super + Return
gnome-terminal
# The following shortcuts depend on shellshape
# send to master => print
@Print
xdotool key --clearmodifiers super+shift+space
# win y (yank,float) => scroll lock # fails
@Scroll_Lock
xdotool key --clearmodifiers super+y
# win p (pin, tile) => pause
@Pause
xdotool key --clearmodifiers super+p
##################################
# Copy, paste... ctrl + left hand combos
##################################
#fails: @KP_Add, divide, multiply, substract, numlock
# so to put them to good use, we need gconf, in org → gnome → desktop → wm → keybinding
# 0 copy
@KP_Insert
xdotool key --clearmodifiers ctrl+c
# copy
@backslash
xdotool key --clearmodifiers ctrl+c
# . ( decimal )
@KP_Delete
xdotool key --clearmodifiers ctrl+v
# 1 paste
@KP_End
xdotool key --clearmodifiers ctrl+z
# 2 cut
@KP_Down
xdotool key --clearmodifiers ctrl+x
# 3 bookmark
@KP_Next
xdotool key --clearmodifiers ctrl+d
# 6 new tab
@KP_Right
xdotool key --clearmodifiers ctrl+t
# 9 close tab
@KP_Prior
xdotool key --clearmodifiers Control_L+w
I gotta say, that was x10 more difficult than I expected. Autohotkey is far better documented, and there are more examples; but it beats xbindkeys, for sure.
Offline
sxhkd is wonderful, it's really easy to set up and works like a charm, I use it in combination with bspwm. But I have two small problems with it :
When I load sxhkd with sxhkd -c ~/.config/bspwm/keys, only the first few keybindings work (see the config file below). When I reload it using the exact same command, everything works.
This
super + {n,comma,semicolon,colon}
bspc presel {left,down,up,right}
works perfect, but this
super + shift + {n,comma,semicolon,colon}
bspc cancel
does nothing, but this
super + shift + n
bspc cancel
works perfect.
Here is the config file I use :
#
# bspwm hotkeys
#
# Launchers
super + {Return, shift + Return}
{urxvtc,opera}
super + {Tab, shift + Tab}
{bash /home/alain/Scripts/mygtkmenu-generate default,gmrun}
# Audio
super + Home
urxvtc -e ncmpcpp
super + {Insert, Delete}
ncmpcpp {toggle, stop}
super + {Left, Right}
ncmpcpp {prev,next}
super + {Down, Next, Up, Prior}
amixer set PCM 1%{-,-,+,+}
super + shift + Down
amixer set PCM 0%
super + End
bash /home/alain/Scripts/alsa-mute Master
shift + {button4, button5}
amixer set PCM 2%{+,-}
# bspwm
control + alt + shift + {q,r,k}
{bspc quit, bash /home/alain/Scripts/wm-autostart bsp, sxhkd -c ~/.config/bspwm/keys}
######### When sxhkd is first started, every keybinding defined below this line do NOT work
######### When I reload sxhkd, they all work except the one for bspc cancel.
# Splitting
super + {n,comma,semicolon,colon}
bspc presel {left,down,up,right}
super + shift + {n,comma,semicolon,colon}
bspc cancel
super + {y,u,i,o}
bspc push {left,down,up,right}
super + shift + {y,u,i,o}
bspc pull {left,down,up,right}
# Browsing through windows
super + {h,j,k,l}
bspc focus {left,down,up,right}
super + shift + {h,j,k,l}
bspc shift {left,down,up,right}
alt + {Tab, shift + Tab}
bspc cycle {next,prev}
super + {q, shift + q}
bspc {close,kill}
# Layout
super + {equal, shift + equal}
bspc circulate {forward,backward}
super + {dollar, shift + dollar}
bspc rotate {clockwise, counter_clockwise}
super + {f, shift + f}
bspc toggle_{floating,fullscreen}
# Desktops and monitor
super + {ampersand,eacute,quotedbl,apostrophe,parenleft}
bspc use {1,2,3,4,5}
super + shift + {ampersand,eacute,quotedbl,apostrophe,parenleft}
bspc send_to {1,2,3,4,5}
super + alt + {ampersand,eacute,quotedbl,apostrophe,parenleft}
bspc use_monitor Monitor0{1,2,3,4,5}
super + alt + shift + {ampersand,eacute,quotedbl,apostrophe,parenleft}
bspc send_to_monitor Monitor0{1,2,3,4,5}
super + {parenright, shift + parenright}
bspc alternate_{desktop,monitor}
Do you know what could cause these minor annoyances ? And how to fix them ?
Derpy Hooves is best pony.
Offline
Offline
Oooooh! Thanks, everything works now!
Derpy Hooves is best pony.
Offline
Hi!
After an upgrade yesterday (or maybe after my cleaning after the upgrade) sxhkd can't find its
config file because the variable
XDG_CONFIG_HOME
is not set.
In which file was it set in default configuration?
Offline
After an upgrade yesterday (or maybe after my cleaning after the upgrade) sxhkd can't find its config file because the variable
XDG_CONFIG_HOME
is not set.
In which file was it set in default configuration?
The aforementioned variable is not defined by sxhkd but by libx11.
A quick way to solve your problem would be to explicitly specify the main configuration file:
sxhkd -c "$HOME/.sxhkdrc"
Offline
Offline
Thanks a lot for such fast fix :-)
Offline
Would it be possible to dispatch caps lock to escape on key release when no other key is pressed, yet dispatch it to the control key when pressed with any modifier?
Offline
Would it be possible to dispatch caps lock to escape on key release when no other key is pressed, yet dispatch it to the control key when pressed with any modifier?
You can do such things with xcape. maybe use xmodmap to assign caps to ctrl, then use xcape to set the release action to escape.
| alias CUTF='LANG=en_XX.UTF-8@POSIX ' |
Offline
bolted wrote:Would it be possible to dispatch caps lock to escape on key release when no other key is pressed, yet dispatch it to the control key when pressed with any modifier?
You can do such things with xcape. maybe use xmodmap to assign caps to ctrl, then use xcape to set the release action to escape.
There's also keydouble (which I wrote).
Offline
Thank you.
Offline