我正在寻找一种解决方案,将进程的所有窗口保留在给定工作区上,以便与 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
潜在替代解决方案的参考资料: