Open wavexx opened 3 weeks ago
This is what I do to do this very thing for Firefox
I have 4 small executable scripts in my $PATH
in my ~/.local/bin/ directory
:
ff_launch
, ff
& ff_wsid
which is for launching Firefox & setting the workspace name
and:
ff_kill
to kill Firefox & removing the workspace name.
Here are the files:
#### ff_launch ####
#!/bin/sh
~/.local/bin/ff
while true;
do
app_run=$(wmctrl -l | awk '/Firefox/ { print $2 }')
if [ "$app_run" != '' ]; then
break
else
sleep 0.2
fi
done
~/.local/bin/ff_wsid
#### ff ####
#!/bin/sh
wmctrl -a firefox || exec firefox &
#### ff_wsid ####
#!/bin/sh
app_run=$(wmctrl -l -x | awk '/Firefox/ { print $2 }')
if [ "$app_run" != '' ]; then
wmctrl -s "$app_run"
echo '+@fg=8;FF +@fg=2;' | xclip -i
xdotool key super+shift+slash
xdotool key ctrl+y
xdotool key return
fi
#### ff_kill ####
#!/bin/sh
curr_deskt="$(wmctrl -d | awk '/*/ { print $1 }')"
dsktp=$(wmctrl -d | awk '/FF/ { print $1 }')
if [ "$dsktp" != '' ]; then
wmctrl -s "$dsktp"
echo '' | xclip -i
xdotool key super+shift+slash
xdotool key ctrl+y
xdotool key return
fi
sleep 0.5
WID=$(xdotool search --name "Mozilla Firefox")
xdotool windowactivate --sync "$WID"
xdotool key --clearmodifiers ctrl+q
wmctrl -s "$curr_deskt"
I invoke ff_launch
which in turn calls ff
& then ff_wsid
via key bindings that I have set & then when I shutdown Firefox & clear the workspace name I invoke ff_kill
also via key bindings that I have set.
I also have set a quirk to always spawn Firefox on the same workspace.
HTH
I see you're basically using xdotool to "interactively" do the rename.. would work indeed (and I didn't realize you could sneak control codes in there), but kind of ugly.
Just to share my experience, I'm working on a project which requires so much setup that I've wrote a script to launch a set of terminals/editors/tools split into various desktops on demand. I already couldn't find a nice way to spawn a new window into a dedicated workspace when already using IGNORESPAWNWS, so I already use wmctrl/xdotool to move windows by pid into the desktop I want after starting them. I guess adding a few more hacks on top doesn't hurt (too much)...
I don't see a way to programmatically set the workspace name starting from a workspace index. Is there a way through some other custom method?