You are not logged in.

#51 2013-01-21 20:36:02

bloom
Member
Registered: 2010-08-18
Posts: 749
Website

Re: sxhkd — Simple X HotKey Daemon

urlwolf wrote:

Still the Control_L+C command doesn't work. The others do.

It does, but you need to artificially release alt:

alt + @F2
    xte 'keyup Alt_L' 'keyup Alt_R' 'keydown Control_L' 'key c' 'keyup Control_L'

gh · da · ds

Offline

#52 2013-01-21 23:07:51

urlwolf
Member
Registered: 2008-03-25
Posts: 40

Re: sxhkd — Simple X HotKey Daemon

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

#53 2013-01-21 23:18:11

Stebalien
Member
Registered: 2010-04-27
Posts: 1,239
Website

Re: sxhkd — Simple X HotKey Daemon

The '@' is needed so that the command is run on the key release event (sxhkd defaults to running commands on the key press event). Otherwise, F2 will still be pressed when that command runs.


Steven [ web : git ]
GPG:  327B 20CE 21EA 68CF A7748675 7C92 3221 5899 410C

Offline

#54 2013-01-22 00:04:20

urlwolf
Member
Registered: 2008-03-25
Posts: 40

Re: sxhkd — Simple X HotKey Daemon

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

#55 2013-01-22 11:16:59

bloom
Member
Registered: 2010-08-18
Posts: 749
Website

Re: sxhkd — Simple X HotKey Daemon

urlwolf wrote:

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).

urlwolf wrote:

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

gh · da · ds

Offline

#56 2013-01-23 03:44:03

urlwolf
Member
Registered: 2008-03-25
Posts: 40

Re: sxhkd — Simple X HotKey Daemon

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

#57 2013-01-25 01:39:03

urlwolf
Member
Registered: 2008-03-25
Posts: 40

Re: sxhkd — Simple X HotKey Daemon

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

#58 2013-01-25 01:41:24

urlwolf
Member
Registered: 2008-03-25
Posts: 40

Re: sxhkd — Simple X HotKey Daemon

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

#59 2013-01-25 02:45:57

urlwolf
Member
Registered: 2008-03-25
Posts: 40

Re: sxhkd — Simple X HotKey Daemon

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

#60 2013-01-25 10:14:25

bloom
Member
Registered: 2010-08-18
Posts: 749
Website

Re: sxhkd — Simple X HotKey Daemon

Run xev and press KP_0: what's the output?

As I said earlier, this:

backslash
    xdotool key --clearmodifiers Control_L+c

must be written:

@backslash
    xdotool key --clearmodifiers ctrl+c

gh · da · ds

Offline

#61 2013-01-25 10:39:31

bloom
Member
Registered: 2010-08-18
Posts: 749
Website

Re: sxhkd — Simple X HotKey Daemon

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)


gh · da · ds

Offline

#62 2013-01-25 11:17:34

bloom
Member
Registered: 2010-08-18
Posts: 749
Website

Re: sxhkd — Simple X HotKey Daemon

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'

gh · da · ds

Offline

#63 2013-01-26 05:15:44

urlwolf
Member
Registered: 2008-03-25
Posts: 40

Re: sxhkd — Simple X HotKey Daemon

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

#64 2013-01-29 09:11:26

Silencement
Member
From: France
Registered: 2012-08-06
Posts: 12

Re: sxhkd — Simple X HotKey Daemon

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

#65 2013-01-29 09:19:14

Stebalien
Member
Registered: 2010-04-27
Posts: 1,239
Website

Re: sxhkd — Simple X HotKey Daemon

The templates ("{}") have to match. For now, this should work:

super + shift + {n,comma,semicolon,colon}
    bspc cancel { , , , }

Steven [ web : git ]
GPG:  327B 20CE 21EA 68CF A7748675 7C92 3221 5899 410C

Offline

#66 2013-01-29 09:47:28

Silencement
Member
From: France
Registered: 2012-08-06
Posts: 12

Re: sxhkd — Simple X HotKey Daemon

Oooooh! Thanks, everything works now!


Derpy Hooves is best pony.

Offline

#67 2013-02-12 08:15:41

Heikete
Member
Registered: 2007-04-28
Posts: 40

Re: sxhkd — Simple X HotKey Daemon

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

#68 2013-02-12 11:16:28

bloom
Member
Registered: 2010-08-18
Posts: 749
Website

Re: sxhkd — Simple X HotKey Daemon

Heikete wrote:

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"

gh · da · ds

Offline

#69 2013-02-12 11:23:45

bloom
Member
Registered: 2010-08-18
Posts: 749
Website

Re: sxhkd — Simple X HotKey Daemon


gh · da · ds

Offline

#70 2013-02-12 11:48:54

bloom
Member
Registered: 2010-08-18
Posts: 749
Website

Re: sxhkd — Simple X HotKey Daemon

As of 6945: if XDG_CONFIG_HOME is not defined, sxhkd, instead of dying, will use the default: $HOME/.config.

It should solve your problem.

Last edited by bloom (2013-02-12 11:57:39)


gh · da · ds

Offline

#71 2013-02-12 13:46:22

Heikete
Member
Registered: 2007-04-28
Posts: 40

Re: sxhkd — Simple X HotKey Daemon

Thanks a lot for such fast fix :-)

Offline

#72 2013-04-10 16:02:14

bolted
Member
Registered: 2013-04-10
Posts: 2

Re: sxhkd — Simple X HotKey Daemon

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

#73 2013-04-10 17:11:54

progandy
Member
Registered: 2012-05-17
Posts: 5,257

Re: sxhkd — Simple X HotKey Daemon

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.


| alias CUTF='LANG=en_XX.UTF-8@POSIX ' |

Offline

#74 2013-04-10 17:25:20

bloom
Member
Registered: 2010-08-18
Posts: 749
Website

Re: sxhkd — Simple X HotKey Daemon

progandy wrote:
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).


gh · da · ds

Offline

#75 2013-04-10 19:07:59

bolted
Member
Registered: 2013-04-10
Posts: 2

Re: sxhkd — Simple X HotKey Daemon

Thank you.

Offline

Board footer

Powered by FluxBB