Open TahsinTariq opened 3 years ago
Hello.
sxhkd
can do it:
~{Control_L,Control_R}
{_,_}command_to_run_when_i_press_either_ctrl_key
ctrl
is a modifier, not a key. You need to specify a key, the control keys are two: Control_L
(left) and Control_R
(right).
You also want to add a ~
before the key names (this makes sxhkd
replay the key event), if you don't add the ~
windows won't be able to detect when you press ctrl
.
Cheers.
Thanks.
I can't figure out the syntax for when I want a combination of just two modifiers. For example, Super_L + Control_L
or Super_L + Control_L + Shift_L
. The arch wiki doesn't have enough documentation on this and I can't find them anywhere else.
two modifiers. For example,
Super_L + Control_L
orSuper_L + Control_L + Shift_L
Those are not modifiers, they are keys..
All chords must have exactly one key and any number of modifiers:
ctrl
: invalid chord (1 modifier, 0 keys)Ctrl_L
valid chord (0 modifiers, 1 key)super + ctrl
: invalid chord (2 modifiers, 0 keys)super + Ctrl_L
valid chord (1 modifier, 1 key)Super_L + Ctrl_L
invalid chord (0 modifiers, 2 keys)Super_L + Control_L + Shift_L
invalid chord (0 modifiers, 3 keys)super + ctrl + Shift_L
valid chords (2 modifiers, 1 key)super + ctrl + Shift_{L,R}
this expands to two valid chords that have 2 modifiers and 1 keysuper + ctrl + ~Shift_{L,R}
this expands to two valid chords that have 2 modifiers and 1 key; the ~
tells sxhkd
to replay the chord for other windows (use it if you want windows other than sxhkd to be able to detect when you press super
, shift
and ctrl
at the same timeI also can't run
@Control_L
echo "foo"
I've tried using @ctrl
but doesn't work
I also can't run
@Control_L echo "foo"
It does work. make sure that you don't have typos and that you are not redefining @Control_L
later on on the file.
I've tried using
@ctrl
but doesn't work
that is not a valid chord.
It does work. make sure you have that you don't have typos and that you are not redefining
@Control_L
later on on the file.
Ohh, So does that mean I can only execute a command for either keypress or release?
~Control_L
echo "bar"
@Control_L
echo "foo"
This only ever prints "bar" on keypress. And If I remove the ~
from the first line, I do get both "foo" and "bar" but I can't use ctrl+c
to copy something as I normally do
It does work. make sure you have that you don't have typos and that you are not redefining
@Control_L
later on on the file.Ohh, So does that mean I can only execute a command for either keypress or release?
sxhkd
will execute everything you write with "$SHELL" -c what_you_wrote
(or with "$SXHKD_SHELL" -c what_you_wrote
if SXHKD_SHELL
is set in the environment).
In shell syntax, you can use ;
to run multiple commands:
super + n
echo foo; echo bar
# or, on multiple lines (note sxhkd removes the newlines)
super + x
echo foz; \
echo baz; \
echo zuz
This only ever prints "bar" on keypress. And If I remove the
~
from the first line, I do get both "foo" and "bar" but I can't usectrl+c
to copy something as I normally do
I can confirm that that happens. It is proabably a bug.
It seems a little weird because i posted an sxhkd
feature request (#198) last year in which I show @x
and ~x
working together and there have not been any updates to sxhkd
since then. I wonder why this doesn't work anymore.
Also having trouble with this. I would like to display caps on/off because my keyboard doesn't have an indicator light.
@Jackojc How is that related to this issue?
Assigning commands to a single caps lock key press.
Again, how is that related?
You do it like so:
Caps_Lock
notify-send 'i work; what is the issue?'
The problem like above is that I cannot activate a script on both press and release and sometimes the keypress causes other keys pressed in quick succession to be swallowed.
I see. what you mean is that these work:
# these work
{_,@}Caps_Lock
notify-send Caps_Lock {pressed,released}
but, only the pressed part works if you add the replay option:
# only "pressed" works
{~,@}Caps_Lock
notify-send '~Caps_Lock' {pressed,released}
So I have a keybinding set up like:
~@Caps_Lock
notify_keyboard "caps" "$(keyboard_caps)"
which will show me a notification on key release the current state of the caps lock modifier but for some reason if I press caps, subsequent key presses seem to be swallowed for a moment. So say I press caps and then J
right away, the J
might be swallowed so I'm not sure if ~@
is working as intended.
How should I configure sxhkd
for both to work independantly (both shortcuts should absolutely never trigger at the same time):
Super_L
to launch xterm(1)
super+left
-> bspc node --focus west
; do not run xterm.The current behavior is that chords where "super" is a modifier correctly work but the "single press Super_L
for xterm(1)
" also triggers.
# { focus, move } the node in the given direction
super + {_,shift + }{Left,Down,Up,Right}
bspc node --{focus,swap} {west,south,north,east}
# broken - it ALWAYS triggers with the previous shortcut; this is UNWANTED behavior
#Super_L
#@Super_L
#~Super_L
#@Super_L;
#~Super_L;
~@Super_L;
xterm
EDIT: seems to be a real issue with sxhkd: https://github.com/baskerville/sxhkd/issues/126
@moviuro
that specific issue could be dealt with by using xcape
.
xcape -e 'Super_L=Super_L|t'
where super + t launches xterm.
xcape
will not solve all of these types of issues though.
I can't help here with the OP, but as I'm looking into sxhkd to use it under i3, I find useful to use sxhkd to launch programs with "dead key taps". However, I'm wondering if some people might be looking here for more complex keyboard ergonomics, and I'd like to share my 2c in ergonomics (as is often the case for xcape
users, for instance).
So, OFFTOPIC warning ahead, I'd like to add here my recommendation for those looking for complex key remappings, specially in ergonomics scenarios.
I'm using kmonad to achieve (among other things) a home row mod as I describe here, just for ergonomics sake. Disclaimer: linked reply is mine.
For more info on what can be achieved with kmonad, check out this fine reddit thread. I think both tools are complementary to each other. Hope it helps improve health/ergonomics for others, as it did for me. I hope you don't mind the offtopic, since I thought it might be useful for keyboard freaks, hanging out here for sure.
Title. I need a script to run each time I press
ctrl
to change keyboard backlight and show useful shortcuts. If sxhkd can't do it, is there some alternate way?