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

Context sensitive shortcuts

asked Oct 7 '15

Hello,

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

2 answers

Sort by » oldest newest most voted
0

answered Oct 8 '15

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 https://github.com/i3/i3/issues/1809

0

answered Oct 8 '15

i3convert gravatar image

updated Oct 8 '15

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.

Question Tools

Stats

Asked: Oct 7 '15

Seen: 30 times

Last updated: Oct 08