baskerville / sxhkd

Simple X hotkey daemon
BSD 2-Clause "Simplified" License
2.79k stars 139 forks source link

Using other keys as modifiers #241

Open boardfish opened 3 years ago

boardfish commented 3 years ago

My keyboard's got an XF86Calculator key, which I'd rather not use for its intended purpose. I want to use it as a modifier instead to grant me another layer of actions. Is there a way to either remap it to an existing modifier through sxhkd, or use it as a modifier so that it can be used in combination with other keys, like this:

XF86Calculator + XF86AudioMute
    dbus-send --print-reply --dest=org.mpris.MediaPlayer2.spotify /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player.PlayPause

XF86Calculator + Pause
    dbus-send --print-reply --dest=org.mpris.MediaPlayer2.spotify /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player.Pause; i3lock

XF86Calculator + XF86AudioRaiseVolume
    dbus-send --print-reply --dest=org.mpris.MediaPlayer2.spotify /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player.Next

XF86Calculator + XF86AudioLowerVolume
    dbus-send --print-reply --dest=org.mpris.MediaPlayer2.spotify /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player.Previous
ke-ss commented 3 years ago

Try using it as a keychain / key chord. The difference between a usual hot keys use and keychains is usually hot keys are pressed together, where as with key chains you press one key let go of it then press the other. May be see if XF86Calculator works with the other keys in a key chain

XF86Calculator; XF86AudioMute
     dbus-send --print-reply --dest=org.mpris.MediaPlayer2.spotify /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player.PlayPause
boardfish commented 3 years ago

I can confirm that works. I still think it'd be nice to be able to use other keys as modifiers so that it's one motion instead of two, though.

Vftdan commented 3 years ago

If your keyboard layout does not use AltGr, you can make your calculator key send ISO_Level3_Shift, and use it as mod5 in sxhkdrc (if it doesn't work, check xmodmap -pm)

boardfish commented 3 years ago

I like this as a solution. Trying it now.

boardfish commented 3 years ago

Not sure why, but this didn't work out for me. I also tried following the advice here to make sure XFB86Calculator got mapped to mod5. I might give this another shot when I'm feeling a bit more focused.

Jeansidharta commented 1 year ago

For anyone else that finds this issue, Vftdan's proposal worked for me. I wanted to use the Pause key in my keyboard as a modifier. Here's what I did:

  1. Write to ~/.xmodmap this:
    add mod5 = Pause
  2. In my ~/.xinitrc, make sure the new xmodmap file is being loaded
    [[ -f ~/.xmodmap ]] && xmodmap ~/.xmodmap
  3. Reload Xorg (I just rebooted my system)

Note that I'm using xinit to start xorg. This may not work in other setups

After these steps, I can now use mod5 as a modifier in my sxhkdrc file. Example:

alt + shift + mod5 + n
    bspc node --to-monitor next --follow