The i3 FAQ has migrated to All content here is read-only.
Ask Your Question

Context sensitive shortcuts

asked 2015-10-07 23:28:13 +0000


is it possible to have context sensitive shortcuts. E. g. a shortcut should only be possible to trigger if application A is (not) running.

Best Regards

edit retag flag offensive close merge delete

2 answers

Sort by ยป oldest newest most voted

answered 2015-10-08 06:07:40 +0000

Airblader gravatar image

As @i3convert pointed out, this isn't possible directly. However, starting with 4.11 the focus command returns success depending on whether a window was focused. This allows something like this:

[ "$(i3-msg '[class=\"firefox\"] focus')" = "[{\"success\":true\}]" ] || i3-msg exec firefox`

Also see

edit flag offensive delete link more

answered 2015-10-08 02:01:25 +0000

i3convert gravatar image

updated 2015-10-08 02:02:29 +0000

I don't think i3 directly provides this functionality. However, you can write a script that checks whether a given application is running (maybe checking the output of ps -A will be good enough in your case? read the man page for ps to fine-tune it), and triggers a given action only if it is (not) running. Then you bind the script to the shortcut you had in mind.

edit flag offensive delete link more

Question Tools


Asked: 2015-10-07 23:28:13 +0000

Seen: 30 times

Last updated: Oct 08