The i3 FAQ has migrated to https://github.com/i3/i3/discussions. All content here is read-only.
Ask Your Question
0

programmatically send keybinging to i3

asked 2013-05-24 09:11:53 +0000

mariusz gravatar image

updated 2013-05-27 09:10:31 +0000

Hey,

is it possible to artificially send specific keybinding to i3 so it executes the proper command? I couldn't find any sufficient command in protocol specification. I also tried sending XLib keyboard event using XSendEvent to the root window but it does nothing (or maybe I'm doing something wrong).

Thanks!

Edit: What I want to do is catch Mod key before Virtualbox guest does that and pass it to i3.

edit retag flag offensive close merge delete

Comments

Could you update the question so that you are asking for what you want to know?

joepd gravatar imagejoepd ( 2013-05-25 06:22:55 +0000 )edit
joepd gravatar imagejoepd ( 2013-05-25 06:25:08 +0000 )edit

Actually I want to achieve the opposite - I want to catch windows key before virtualbox guest and use it with i3.

mariusz gravatar imagemariusz ( 2013-05-27 09:14:17 +0000 )edit

3 answers

Sort by ยป oldest newest most voted
4

answered 2013-05-24 10:08:42 +0000

vandannen gravatar image

You could use xdotool key ctrl+c to emulate a keypress and -release of the specified key combination. But if you want to execute i3 commands, you should definitely use, e.g., i3-msg workspace 1 to switch to the first workspace. i3-msg accepts all known i3 commands.

edit flag offensive delete link more

Comments

What I want to do is catch Mod key before Virtualbox guest does that and pass it to i3. Now I'm doing exactly what you suggested - I'm calling "i3-msg workspace N" if Mod+[0-9] is pressed. However, it would be better not to hardcode commands and let i3 do the work.

mariusz gravatar imagemariusz ( 2013-05-24 11:27:28 +0000 )edit

I am not sure whether I understand what you want to achieve and where you defined your workspace keybindings. But if this is soley about virtualbox: you can define a host key (default is right ctrl key), which toggles the keyboard focus between the virtualbox guest and the host.

vandannen gravatar imagevandannen ( 2013-05-24 11:57:05 +0000 )edit

Another way would be to define a "pass-through"-mode in i3 and use this to control whether the guest or the host should interpret the shortcuts. (Then you should disable the autofocus of virtualbox for its guests.)

vandannen gravatar imagevandannen ( 2013-05-24 12:05:44 +0000 )edit
0

answered 2013-05-27 09:41:33 +0000

mariusz gravatar image

updated 2013-05-27 10:23:33 +0000

Ok, so I eventually wrote a small program that catches windows key before virtualbox and evaluates i3 command through i3-msg. I placed it here: gist.github.com/5656098

It's not the fanciest method, but works for me.

Thanks for everyone's help!

edit flag offensive delete link more
0

answered 2013-05-25 06:22:43 +0000

joepd gravatar image

You could make a mode in your config (similar to resize), without any special commands, except a return keycombo. The $mod-key will lose all it's special meaning to i3 when in that mode, and will get passed on to the application.

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2013-05-24 09:11:53 +0000

Seen: 604 times

Last updated: May 27 '13