用於在所有視口中的應用程式視窗之間切換的組合鍵

用於在所有視口中的應用程式視窗之間切換的組合鍵

Alt-`用於在 Unity 中目前視窗中的應用程式視窗之間切換。

是否有其他組合鍵可以在所有視口中的應用程式視窗之間切換?

我不想更改Alt-的預設行為`,即在當前視窗中的應用程式視窗之間切換。

我正在使用 Ubuntu 14.04 和 Unity。

答案1

受皮諾答案的啟發,我發現了一個骯髒的技巧來完成它:保持Alt+`用於在一個視口中的應用程序窗口之間切換,以及(例如)Alt+1用於在所有視口上的應用程序窗口之間切換。

外觀上的一個小缺點是響應能力不太準確,因為設定需要幾分之一秒的時間來更改。然而在實踐中,你幾乎不會注意到。

  1. 安裝xdotool

    sudo apt-get install xdotool
    
  2. 將以下 scipt 複製到一個空文件中並將其另存為switch.sh

    #!/bin/bash
    
    dconf write /org/compiz/profiles/unity/plugins/unityshell/alt-tab-bias-viewport false
    sleep 0.2
    xdotool keydown alt key 0x60
    dconf write /org/compiz/profiles/unity/plugins/unityshell/alt-tab-bias-viewport true
    sleep 1
    
  3. 設定一個組合鍵來運行腳本:System Preferences > Keyboard > Shortcuts > Custom Shortcuts。我選擇Alt+ 1,因為它接近另一個。

    現在您可以使用任一Alt+1在(例如)gedit 的所有視窗之間切換:

    在此輸入影像描述

    Alt+`僅在目前工作區的 gedit 視窗之間切換:

    在此輸入影像描述

筆記:

  1. 在腳本中,上面的鍵Tab設定為key 0x60。這在其他佈局上可能有所不同。如果它不起作用,請在終端機中運行xev,然後按Return,然後按選項卡上方的鍵。在輸出中,尋找類似 的字串(keysym 0x60, grave)。 keysym 值是您在 (script-) 行中所需的值:

    xdotool keydown alt key 0x60
    
  2. sleep 0.2和的值sleep 1使腳本在我的系統上正常工作,但它們可能需要針對更快的系統進行最佳化(減少)。

更多的選擇

同樣,您可以設定一個組合鍵來在所有應用程式視窗所有視窗那麼腳本將是:

#!/bin/bash

dconf write /org/compiz/profiles/unity/plugins/unityshell/alt-tab-bias-viewport false
sleep 0.2
xdotool keydown alt key 0xff09
dconf write /org/compiz/profiles/unity/plugins/unityshell/alt-tab-bias-viewport true
sleep 1

如果您為此設定了例如Alt+ Q,那麼您就有了很好的所有選項集:

Alt+` 之間切換目前應用程式的窗戶打開目前視窗

Alt+1 之間切換目前應用程式的窗戶打開所有視窗

Alt+Tab 之間切換所有申請窗戶打開目前視窗

Alt+Q 之間切換所有申請窗戶打開所有視窗

在此輸入影像描述

Alt+Tab : 在所有應用程式視窗之間切換目前視窗

在此輸入影像描述

Alt+ Q:在所有視窗上的所有應用程式視窗之間切換

答案2

使用通用解決方案wmctrl


概述

以下腳本應與所有相容符合 EWMH 標準視窗管理器(例如 xfwm4、openbox、kwin、compiz...)。它使用wmctrlxprop,可以透過以下方式安裝:

sudo apt-get install x11-utils wmctrl

安裝

複製以下段落並將其另存為simple-window-switcher

#!/bin/bash

# based on a script by Robert Steiniger
# (http://lars.st0ne.at/blog/switch%20between%20windows%20within%20the%20same%20application)

Usage="
  Title:        simple-window-switcher 0.1
  Description:  switch between all windows of active application
  Author:       Copyright Glutanimate 2014 (https://github.com/Glutanimate)
  License:      GNU GPLv3
  Usage:        $(basename "$0") [-g|-l|-h]
                -g: global window switching (across all workspaces)
                -l: local window switching (current workspace)
                -h: display this help message

                If no argument is provided window switching will be set to global.
"

while getopts "lgh" OPTIONS; do
  case $OPTIONS in
    l ) Fields="3-4"
        ;;
    g ) Fields="4"
        ;;
    h ) echo "$Usage"
        exit 0
        ;;
   \? ) echo "$Usage"
        exit 1
        ;;
  esac
done

ActiveWinID="$(xprop -root | sed -n 's/_NET_ACTIVE_WINDOW(WINDOW): window id # 0x//p')"
# fields 3-4: <desktop number> <window class>
ActiveWinClass="$(wmctrl -xl | grep "$ActiveWinID" | cut -d" " -f${Fields})"
WindowList="$(wmctrl -xl | grep "$ActiveWinClass" | cut -d" " -f1)"
NextWindow="$(echo "$WindowList" | grep -A1 "$ActiveWinID" | sed -n 2p)"

if [[ -z "$NextWindow" ]]; then
  NextWindow="$(echo $WindowList | head -n 1)"
fi

wmctrl -i -a "$NextWindow"

將腳本標記為可執行檔並將其儲存在您想要的任何位置(最好在您的 PATH 中,例如/usr/local/bin~/bin)。

用法

使用視窗管理器的鍵盤快速鍵選單來指派simple-window-switcher您選擇的熱鍵。您可以使用以下參數來控制腳本的行為方式:

  • -g:全域視窗切換(跨所有工作區)
  • -l:本地視窗切換(目前工作空間);可能不適用於 Unity/Compiz(有關更多信息,請參閱評論部分)

答案3

開啟終端機並鍵入以下命令:

dconf write /org/compiz/profiles/unity/plugins/unityshell/alt-tab-bias-viewport false

或者,您可以安裝 Unity Tweak Tool:

sudo apt-get install unity-tweak-tool
unity-tweak-tool

然後啟用在所有工作區的視窗之間切換切換器選項卡中的選項:

在此輸入影像描述

相關內容