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 May 24 '13

mariusz gravatar image

updated May 27 '13

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.

Comments

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

joepd gravatar imagejoepd (May 25 '13)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 (May 27 '13)edit

3 answers

Sort by » oldest newest most voted
4

answered May 24 '13

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.

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 (May 24 '13)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 (May 24 '13)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 (May 24 '13)edit
0

answered May 27 '13

mariusz gravatar image

updated May 27 '13

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!

0

answered May 25 '13

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.

Question Tools

1 follower

Stats

Asked: May 24 '13

Seen: 604 times

Last updated: May 27 '13