Fix workspace renaming script
We can just kindly ask for the current workspace 🤷
This commit is contained in:
@@ -1,36 +1,28 @@
|
|||||||
#!/bin/bash
|
#!/bin/sh
|
||||||
|
|
||||||
workspace_num=-1
|
swaymsg -t subscribe -m '[ "window" ]' | while read -r event ; do
|
||||||
workspace_name=""
|
if [ "$(jq -r '.change' <<< $event)" = 'focus' ] ; then
|
||||||
|
current_workspace="$(swaymsg -t get_workspaces | jq -r '.[] | select(.focused)')"
|
||||||
|
workspace_num="$(jq -r '.num' <<< $current_workspace)"
|
||||||
|
workspace_name="$(jq -r '.name' <<< $current_workspace)"
|
||||||
|
|
||||||
swaymsg -t subscribe -m '[ "workspace", "window" ]' | while IFS= read -r event ; do
|
|
||||||
if [ "$(jq -r '.change' <<< $event)" == 'focus' ] ; then
|
|
||||||
if [ "$(jq -r '.container' <<< $event)" == 'null' ] ; then
|
|
||||||
# Workspace
|
|
||||||
workspace_num="$(jq -r '.current.num' <<< $event)"
|
|
||||||
workspace_name="$(jq -r '.current.name' <<< $event)"
|
|
||||||
elif [ workspace_num != -1 ] ; then
|
|
||||||
# Window
|
|
||||||
app_name="$(jq -r '.container.app_id' <<< $event)"
|
app_name="$(jq -r '.container.app_id' <<< $event)"
|
||||||
if [ $app_name == 'null' ] ; then
|
if [ $app_name = 'null' ] ; then
|
||||||
app_name="$(jq -r '.container.window_properties.instance' <<< $event)"
|
app_name="$(jq -r '.container.window_properties.instance' <<< $event)"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ "$app_name" == "kitty" ] ; then
|
if [ "$app_name" = "kitty" ] ; then
|
||||||
app_name=""
|
app_name=""
|
||||||
elif [ "$app_name" == "chromium" ] ; then
|
elif [ "$app_name" = "chromium" ] ; then
|
||||||
app_name=""
|
app_name=""
|
||||||
elif [ "$app_name" == "discord" ] ; then
|
elif [ "$app_name" = "discord" ] ; then
|
||||||
app_name=""
|
app_name=""
|
||||||
elif [ "$app_name" == "spotify" ] ; then
|
elif [ "$app_name" = "spotify" ] ; then
|
||||||
app_name=""
|
app_name=""
|
||||||
elif [ "$app_name" == "GEMOC Studio" ] ; then
|
elif [ "$app_name" = "GEMOC Studio" ] ; then
|
||||||
app_name=""
|
app_name=""
|
||||||
fi
|
fi
|
||||||
|
|
||||||
new_workspace_name="$workspace_num:$app_name"
|
swaymsg rename workspace "$workspace_name" to "$workspace_num:$app_name"
|
||||||
swaymsg rename workspace "$workspace_name" to "$new_workspace_name"
|
|
||||||
workspace_name="$new_workspace_name"
|
|
||||||
fi
|
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|||||||
Reference in New Issue
Block a user