プロセスウィンドウをi3ワークスペースに制限する

プロセスウィンドウをi3ワークスペースに制限する

i3(i3wm)で使用するために、特定のワークスペースでプロセスのすべてのウィンドウを維持するソリューションを探しています。

プロセス/プロセスツリーのウィンドウをワークスペース(名前または番号に基づいて)に制限するコマンドをi3-msg実行するためにバイナリを使用するつもりです。assign [...] workspace ...

これまで私が思いついた内容は次のとおりです。https://gist.github.com/nmschulte/ab206ea9bd32f3eb599cf1552ef27ecc

#!/usr/bin/env sh

## constrain process windows to an i3 workspace; requires jq
## usage: i3-proc-to-ws.sh command

if [ -z "$JQ" ]; then
    JQ=jq
fi
if [ -z "$I3_PROC_TO_WS" ]; then
    I3_PROC_TO_WS=$(i3-msg -t get_workspaces | $JQ '.[] | select(.focused) | .num')
fi
$@ & PID=$!

# get window properties
for wid in $(xwininfo -tree -root -int | sed 's/\(xwininfo:\| \)*\([0-9]*\) [^c].*/\2/'); do
    wpid=$(xprop -id $wid _NET_WM_PID | sed 's/_NET_WM_PID.* = \([0-9]\+\)/\1/')
    echo $PID $wpid
    constraint=$(xprop -id $wid WM_CLASS | sed 's/WM_CLASS.* = "\(.*\)", "\(.*\)"/class="^\2$" instance="^\1$"/')
    echo $constraint
    if [ "$PID" -eq "$wpid" ]; then
        #constraint=$(xprop -id $wid WM_CLASS | sed 's/WM_CLASS.* = "\(.*\)", "\(.*\)"/class="^\2$" instance="^\1$"/')
        echo i3-msg -t command assign [$constraint] $I3_PROC_TO_WS
    fi
done

wait $PID

潜在的な代替ソリューションに関する参考資料:

ベストアンサー1

おすすめ記事