当某个应用程序处于活动状态时禁用“Alt-Tab”键盘快捷键?

当某个应用程序处于活动状态时禁用“Alt-Tab”键盘快捷键?

我知道我可以通过 Ubuntu 的设置菜单禁用(甚至更改)Alt+Tab窗口切换快捷键。但是,我想做的是保留它,但某个应用程序除外。

有没有办法在应用程序打开时有条件地禁用Alt+ ?或者我可以通过某种方式编写脚本来大致完成此操作?Tab


编辑:我希望禁用 Alt-Tabbing 的特定应用程序是godot。以下脚本(来自这个帖子)无法在我的计算机上运行:

#!/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

事实上,只需简单调用

gsettings set org.gnome.desktop.wm.keybindings switch-applications-backward "['']"

gsettings set org.gnome.desktop.wm.keybindings switch-applications "['']"

无法在 Ubuntu 19.04 中禁用 Alt-Tabbing。

相关内容