#!/bin/bash
while read actwin; do
actwin=0x${actwin##* 0x}
((actwin == 0x0)) && continue
leader="$(xprop -notype -id $actwin WM_CLIENT_LEADER)"
leader=0x${leader##* 0x}
[[ "$leader" = "0xWM_CLIENT_LEADER"* ]] && unset leader
while read somewin junk; do
((somewin == actwin)) && continue
if [ -n "$leader" ]; then
someleader="$(xprop -notype -id $somewin WM_CLIENT_LEADER)"
someleader=0x${someleader##* 0x}
[[ "$someleader" != "0xWM_CLIENT_LEADER"* ]] && ((someleader == leader)) && continue
fi
wmctrl -i -r $somewin -b add,hidden
done < <(wmctrl -l)
done < <(xprop -root -spy _NET_ACTIVE_WINDOW)
]]>This is one step towards something I'd actually be happy with, allowing windows to keep their preferred size while removing the clutter of windows stacking over each other.
I've settled on this solution for now:
#!/bin/bash
interface=org.budgie_desktop.TabSwitcher
member=ShowSwitcher
dbus-monitor --profile "interface='$interface',member='$member'" |
while read -r line; do
sleep .05
wmctrl -k on
done
This script monitors dbus for the method that budgie calls internally to open the tab switcher, and then minimizes all windows right away as the tab switcher opens. I would have preferred to minimize everything after selecting a new window in the tab switcher, but this works too. The short sleep is there to prevent the tab switcher window from getting hidden as well, don't know why that happens without the delay since it's not really a window.
Kind of a stupid way to do it, but still better than reimplementing the whole tab switcher logic to call the dbus methods from a script. I've asked the budgie devs if they would consider giving their tab switcher a /usr/bin command that can receive the two keys to operate it as arguments, maybe something will come of that and this mess will be obsolete in the future. Most budgie apps like the run dialog or the window shuffler have an executable already, the tab switcher seems to be the only exception.
]]>In that case sth. like
xdotool keydown alt keydown Tab sleep 0.1 keyup Tab sleep 10 keyup alt
should trigger the tabbox and allow you to navigate it by only pressing tab.
Pitfalls:
- if the shortcut for your script involves the Alt key, you'll likely trigger a release w/ that
- the shortcut daemon might grab the input/server
The mitigation for both is the same: have the script eg. "sleep 0.25" ahead of everything in order to give yourself some time to release the shortcut keys before the actual xdotool action starts
Edit: maybe elaborate what your actual functional goal is here
]]>I'm afraid the alt+tab emulation approach is impossible anyways, since you can't have a custom and system keyboard shortcut for the script mapped to the same combination. Budgie/Gnome will simply deactivate the tab switcher as soon as you use alt+tab for your custom shortcut.
That's exactly what it would take to make this work though, since you have to be holding that exact key combination, whether its alt+tab or something else, otherwise you won't be able to use the tab switcher even if you manage to properly launch it with a script.
]]>I contacted the budgie developers on their github page, you were right about the dbus interface: https://github.com/BuddiesOfBudgie/budg … ussions/33
It's kind of a pain though since you have to pass all available windows and the target window for switching manually, and doesn't even solve the problem since the tab switcher is hardcoded to close immediately if alt+tab or whatever combination you set in the keyboard settings is not pressed.
It's too bad there is no dbus message sent for the tab switcher exiting, that would allow me to run my own script to hide the other windows at that point.
I'm not familiar w/ budgie or its WM but do you maybe want to use wmctrl to activate a specific window (and/or hide all others)?
I thought about that too, but I would have preferred to just use the budgie tab switcher as is with the added feature of minimizing everything except for the new active window. wmctrl doesn't offer the selection menu that the budgie tab switcher does, I would have to create something like that from scratch or just use a different tab switcher.
]]>Also:
launch budgie's window switcher and hide all unfocused windows after it exits
I'm not familiar w/ budgie or its WM but do you maybe want to use wmctrl to activate a specific window (and/or hide all others)?
]]>I've tried these two approaches with xdotool, but both of them are extremely janky and only trigger the window switcher very vary rarely.
xdotool key alt+Tab
xdotool keydown alt key Tab; sleep 2; xdotool keyup alt
Most of the time both commands produce don't trigger the switcher and instead write this cryptic output to the terminal:
^[ %
I'd like to avoid this janky way of emulating pressing alt and tab if possible, but I couldn't find any way to directly launch the window switcher. It doesn't seem to have its own executable, and the manpage for wmctrl also doesn't say anything about a command for the window switcher.
]]>