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

How do I simulate keypresses?

asked 2012-09-11 15:20:49 +0000

this post is marked as community wiki

This post is a wiki. Anyone with karma >100 is welcome to improve it.

Hello everybody,

this is my first post here, although I've been using i3 for some months now. I really have to thank the developers for this incredible wm (and for its docs!! :) ).

Some context for my question.
I'm using an Apple keyboard and I set the Meta key as $mod. Since this key is easier to reach than Ctrl, I would like to use it for copy/paste shortcuts and other stuff. E.g., I'd like to press Meta+c to copy the selected text to the clipboard, and Meta+v to paste. I tried different programs (xdotool, xte, xvkbd ...) to simulate keypresses. They do work in a terminal, i.e, if I run in xterm

xte "keydown Control_R" "key c" "keyup Control_R"

I do get ^C as output. However, if I configure i3 like this

bindsym $mod+c exec xte "keydown Control_R" "key c" "keyup Control_R"

nothing happens, probably becasue the command is run in the login shell. So I guess my question becomes: is there a way to tell i3 to send a keypress to the focused container?

Thanks in advance.
Bye

edit retag flag offensive close merge delete

2 answers

Sort by ยป oldest newest most voted
0

answered 2012-09-11 22:27:25 +0000

this post is marked as community wiki

This post is a wiki. Anyone with karma >100 is welcome to improve it.

I think you will find your answer in ticket https://github.com/i3/i3/issues/485

A short summary: In the current git "next" version (what will be i3 v4.3 soonish), you can use the following:

bindsym --release $mod+x exec --no-startup-id xdotool key --clearmodifiers ctrl+v
edit flag offensive delete link more

Comments

Fantastic! I installed the git version and it works. Thank you very much :)

scanf gravatar imagescanf ( 2012-09-12 12:42:14 +0000 )edit

Thanks, this is perfect. Shame I can't vote..

gak gravatar imagegak ( 2014-12-13 01:04:39 +0000 )edit
0

answered 2012-09-11 15:30:50 +0000

joepd gravatar image

updated 2012-09-11 15:31:21 +0000

This sounds like a convoluted approach.

I defined some remappings of my keyboard in ~/.Xmodmap. This way, any application that not on a real TTY has CAPSLOCK removed, and functions as an extra ESC there. Might want to make that my i3-modifier, but I am getting addicted to the fast escape key in vim...

Xmodmap is very readable:

$ cat ~/.Xmodmap
remove Lock = Caps_Lock
keysym Caps_Lock = Escape

And it is activated like this in ~/.xinitrc:

xmodmap ~/.Xmodmap
edit flag offensive delete link more

Comments

Yes, I thought about remapping the keyboard. The problem is, if I define the **Meta** key to be **Ctrl**, I lose it as $mod. Or, if I then set $mod to be **Ctrl**, I might get some conflicts. That's why I discarded it as an option. I might try it though if I all else fails. Thank you

scanf gravatar imagescanf ( 2012-09-11 15:42:43 +0000 )edit

Question Tools

Stats

Asked: 2012-09-11 15:20:49 +0000

Seen: 1,321 times

Last updated: Oct 11