I know that I'm able to disable (and even change) the Alt+Tab window switching shortcut through Ubuntu's settings menu. However, what I'd like to do is keep it for all but a certain application.
Is there a way to conditionally disable Alt+Tab when that application is open? Or some way I can rig a script together to do approximately this?
EDIT: The specific application I want Alt-Tabbing disabled for is godot
. The following script (from this post) fails to work on my machine:
#!/bin/bash
keySwitchApplication="switch-applications"
keySwitchApplicationBackward="switch-applications-backward"
backupSwitchApplications="$(gsettings get org.gnome.desktop.wm.keybindings "$keySwitchApplication")"
disableSwitchApplications="$(gsettings get org.gnome.desktop.wm.keybindings "$keySwitchApplication" | sed "s/\,*\s*'<Alt>Tab'//")"
backupSwitchApplicationsBackward="$(gsettings get org.gnome.desktop.wm.keybindings "$keySwitchApplicationBackward")"
disableSwitchApplicationsBackward="$(gsettings get org.gnome.desktop.wm.keybindings "$keySwitchApplicationBackward" | sed "s/\,*\s*'<Shift><Alt>Tab'//")"
disabled="0"
while true; do
isActive=$(wmctrl -lx | awk -v search=$(printf 0x0%x $(xdotool getactivewindow)) -v wm_class="$wm_class" '{ if($1 ~ search && $3 ~ /godot/) print $3 }')
if [[ "$isActive" != "" ]]; then
# echo "active"
if [[ "$disabled" == "0" ]]; then
# echo "disable shortcut"
gsettings set org.gnome.desktop.wm.keybindings "$keySwitchApplication" "$disableSwitchApplications"
gsettings set org.gnome.desktop.wm.keybindings "$keySwitchApplicationBackward" "$disableSwitchApplicationsBackward"
disabled="1";
fi
else
# echo "not active"
if [[ "$disabled" == "1" ]]; then
# echo "enable shortcut"
gsettings set org.gnome.desktop.wm.keybindings "$keySwitchApplication" "$backupSwitchApplications"
gsettings set org.gnome.desktop.wm.keybindings "$keySwitchApplicationBackward" "$backupSwitchApplicationsBackward"
disabled="0"
fi;
fi;
sleep 1
done
In fact just simply calling
gsettings set org.gnome.desktop.wm.keybindings switch-applications-backward "['']"
gsettings set org.gnome.desktop.wm.keybindings switch-applications "['']"
fails to disable Alt-Tabbing in Ubuntu 19.04.