Eu tenho uma solução. Tudo o que você precisa é começar este script de observador:
#!/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( ~ search && ~ /emacs/) print }')
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
O script verifica em um loop infinito a classe da janela emacs
e desabilita / ativa Alt + Tab e Shift + Alt + Guia
Se algo der errado, você poderá redefinir a entrada para as configurações padrão:
gsettings reset org.gnome.desktop.wm.keybindings switch-applications
gsettings reset org.gnome.desktop.wm.keybindings switch-applications-backward
No meu caso:
% gsettings reset org.gnome.desktop.wm.keybindings switch-applications
% gsettings get org.gnome.desktop.wm.keybindings switch-applications
['<Super>Tab', '<Alt>Tab']
% gsettings reset org.gnome.desktop.wm.keybindings switch-applications-backward
% gsettings get org.gnome.desktop.wm.keybindings switch-applications-backward
['<Shift><Super>Tab', '<Shift><Alt>Tab']
Créditos
@Serg e sua resposta Como desabilitar a troca de idioma de entrada no terminal
@JacobVlijm para sua comentários