当某个程序打开时,如何在Cinnamon中禁用Alt-Tab应用程序切换?
我使用emacs并在某些模式下将填充命令设置为Alt-Tab,并且作为习惯的生物,希望保持这种方式。
有没有一种简单的方法可以在emacs打开时通过Alt-Tab禁用应用程序切换?
我有一个解决方案。 所有你需要的是,启动这个观察者脚本:
#!/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*'Tab'//")" backupSwitchApplicationsBackward="$(gsettings get org.gnome.desktop.wm.keybindings "$keySwitchApplicationBackward")" disableSwitchApplicationsBackward="$(gsettings get org.gnome.desktop.wm.keybindings "$keySwitchApplicationBackward" | sed "s/\,*\s*'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 ~ /emacs/) 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
该脚本在无限循环中检查窗口类emacs
并禁用/启用Alt + Tab和Shift + Alt + Tab
如果出现任何问题,您可以将条目重置为默认设置:
gsettings reset org.gnome.desktop.wm.keybindings switch-applications gsettings reset org.gnome.desktop.wm.keybindings switch-applications-backward
就我而言:
% gsettings reset org.gnome.desktop.wm.keybindings switch-applications % gsettings get org.gnome.desktop.wm.keybindings switch-applications ['Tab', 'Tab'] % gsettings reset org.gnome.desktop.wm.keybindings switch-applications-backward % gsettings get org.gnome.desktop.wm.keybindings switch-applications-backward ['Tab', 'Tab']
积分
@Serg和他的回答如何在终端中禁用输入语言切换
@JacobVlijm的评论
一种丑陋的hackish方式浮现在脑海中……
键盘设置应存储在: ~/.config/dconf/user
如果您有两个文件,一个是Alt+Tab
在系统范围内启用,另一个是Alt+Tab
全局禁用,理论上可以交换它们。
简单的脚本将:
- 备份
Alt+Tab Enabled
- 将
Disabled Alt+Tab
复制到Disabled Alt+Tab
Enabled Alt+Tab
- 运行Emacs
- Emacs关闭后,将文件复制回原样
该脚本将用于打开/运行Emacs
我不知道它是否会起作用,为了安全起见我会首先在VB中尝试它,现在我没有时间尝试不幸…