Can I pass some keys for a specific window? I could not find in Sway's man pages or the issues on Github.

At the moment, I'm executing a script with bindsym XF86Forward exec sway-next (requires jq and xdotool):

class=`swaymsg -t get_tree | jq '.nodes[]|.nodes[]|.nodes[]|select(.focused)|.window_properties|.class'`
if [[ ${class} = \"Firefox\" ]]; then
  xdotool key XF86Forward
  swaymsg workspace next
# Likewise for the `XF86Back` key.

But I'd rather have for_window[class="(?i)firefox"] unbind XF86Forward in my configuration. If there's no better way, could someone help me turn this into a python script? I can't figure out how to use the json module correctly.

(Edit: this doesn't take tabbed mode into account, which adds another .nodes[])

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.