-
-
Save nmschulte/ab206ea9bd32f3eb599cf1552ef27ecc to your computer and use it in GitHub Desktop.
constrain process windows to an i3 workspace
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment