-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
[Feature request] Allow forwarding of key events #4937
Comments
Hm, neat idea. |
I think a way of doing it that would be more flexible is allow to send input. And now that I'm typing it I realise that this is already possible with seats. So in this case you would do: for_window [class="discord"] bindsym F24 seat - mmmhh, oops, nope, keyboards don't work yet. #1779 I prefer this solution over adding a redundant command. |
While I understand your argument, and I would accept it as a solution when it is implement, I have two small concerns:
I think the config file must be as expressive, concise and easy to organize as possible. |
I'm not sure I understand what you mean here. I would say it's actually the opposite:
|
Well, that's a matter of taste, for me:
is clearer than:
Because I group my But this is a matter of taste. Anyway, there is another problem, the My syntax would make that clear and would also permit forwarding to multiple apps:
This would swallow the key if neither A and B are running, if either A or B is running it would forward the key to it, and if both are running, it would forward the key to both. |
|
Well, I guess creating a new event with the same keycode would work, like The idea is to provide an easy way to bind global hotkeys for app that cannot be scripted. I'm sure we can come up with a nice solution. |
Reread the original comment (#4937 (comment)) and realised I misread it. It won't be as easy as using seats. But regardless I still believe it can be done with seats. Especially with if "virtual seats" become a thing. |
A workaround for this issue is to write a script that:
Below is an example with OBS as the target application: #!/bin/sh
WRKSPC1=`swaymsg -t get_workspaces | jq -r '.[] | select(.focused==true).name'`
swaymsg [app_id="obs"] focus
if [ "$?" = "0" ]
then
wtype $*
WRKSPC2=`swaymsg -t get_workspaces | jq -r '.[] | select(.focused==true).name'`
if [ ! "$WRKSPC1" = "$WRKSPC2" ]
then
swaymsg workspace number $WRKSPC1
fi
fi With the above script saved as
Notes: we can't use the same key combination in both OBS and Sway because it would result in an infinite loop. |
More generalized approach from what @jalvesaq does:
This way you get your window focus back afterwards. Using it like this:
It is quite annoying that the window flashes into focus briefly tho and am still searching for a solution that doesn't do that... |
Command Syntax: emit <press|release|press-release> <criteria> <keys> * action: specifies whether to press, release the keys or do both * criteria: first window that matches the criteria will get the key input * keys: modifiers and keys separated by + Examples: * emit press-release [app_id=com.obsproject.Studio] ALT+F8 * bindsym --no-repeat Ctrl+T emit press [app_id=wev] Ctrl+A * bindsym --no-repeat --release Ctrl+T emit release [app_id=wev] Ctrl+A
Shortly put, I'd like to be able to do this:
bindsym F24 forward [class="discord"]
With this example, when F24 is pressed, the first window matching the criteria get a keypress event, exactly as if it was focused and F24 was pressed.
This would allow for a very easy way to handle global hotkeys.
The text was updated successfully, but these errors were encountered: