6

ショートカットを使用してウィンドウフォーカスを変更するようにxbindkeysを構成しています。たとえば、アプリケーションウィンドウ、たとえばターミネータウィンドウに焦点を合わせるためのショートカットを作成することができました。

wmctrl -xa terminator

残念ながら、それは常に同じターミネーターウィンドウに焦点を合わせているため、ターミネーターウィンドウを循環することができません。

ターミネーターウィンドウに焦点を合わせるコマンドを提案していただけますか。もう一度押すと、すべてのターミネーターウィンドウが循環します。

2013年3月30日更新

このスクリプト http://lars.st0ne.at/blog/switch%20between%20windows%20within%20the%20same%20applicationを変更して、次 のようなスクリプトを作成しました。

script.sh NAME

アプリケーションNAMEにフォーカスするか、NAMEのウィンドウがすでにフォーカスされている場合は、NAMEのすべてのウィンドウを循環しますが、正しく機能しません。

これがスクリプトです

win_class=$1 # 'terminator' # $1

# get list of all windows matching with the class above
win_list=$(wmctrl -x -l | grep -i $win_class | awk '{print $1}' )

# get id of the focused window
active_win_id=$(xprop -root | grep '^_NET_ACTIVE_W' | awk -F'# 0x' '{print $2}')

# get next window to focus on, removing id active
switch_to=$(echo $win_list | sed s/.*$active_win_id// | awk '{print $1}')

# if the current window is the last in the list ... take the first one
if [ "$switch_to" == '' ];then
   switch_to=$(echo $win_list | awk '{print $1}')
fi

# switch to window
wmctrl -i -a $switch_to

スクリプトはアプリケーションのウィンドウに焦点を合わせ、ウィンドウに到達するまでそれらを循環します。最後に作成されたと思います。その時点で、サイクリングは機能しなくなります。

4

4 に答える 4

9

どのウィンドウにもフォーカスがない場合、スクリプトに問題があることがわかりました。

次の変更されたスクリプトを試していただけますか。

#!/bin/bash
win_class=$1 # 'terminator' # $1

# get list of all windows matching with the class above
win_list=$(wmctrl -x -l | grep -i $win_class | awk '{print $1}' )

# get id of the focused window
active_win_id=$(xprop -root | grep '^_NET_ACTIVE_W' | awk -F'# 0x' '{print $2}')
if [ "$active_win_id" == "0" ]; then
    active_win_id=""
fi

# get next window to focus on, removing id active
switch_to=$(echo $win_list | sed s/.*$active_win_id// | awk '{print $1}')

# if the current window is the last in the list ... take the first one
if [ "$switch_to" == '' ];then
   switch_to=$(echo $win_list | awk '{print $1}')
fi

# switch to window
wmctrl -i -a $switch_to
于 2013-04-04T10:16:13.193 に答える
1

st0ne でスクリプトを適応させた後、一般的に機能するバージョンを作成しました (app_name を指定する必要はありません)。それが誰かに役立つことを願っています。:)

#!/bin/bash
active_win_id=`xprop -root | grep '^_NET_ACTIVE_W' | awk -F'# 0x' '{print $2}' | awk -F', ' '{print $1}'`
if [ "$active_win_id" == "0" ]; then
    active_win_id=""
fi

app_name=`wmctrl -lx | grep $active_win_id | awk '{print $3}'`
workspace_number=`wmctrl -d | grep '\*' | cut -d' ' -f 1`
win_list=`wmctrl -lx | grep -ri $app_name | grep " $workspace_number " | awk '{print $1}'`

# get next window to focus on, removing id active
switch_to=`echo $win_list | sed s/.*$active_win_id// | awk '{print $1}'`
# if the current window is the last in the list ... take the first one
if [ "$switch_to" == "" ];then
    switch_to=`echo $win_list | awk '{print $1}'`
fi


if [[ -n "${switch_to}" ]]
    then
        (wmctrl -ia "$switch_to") &
    else
        if [[ -n "$2" ]]
            then
                ($2) &
        fi
fi


exit 0
于 2015-11-09T11:11:10.923 に答える