Files
dotfiles/.config/sway/workspace-rename.sh
RhiobeT 2d8c60e8e1 Fix workspace renaming script
We can just kindly ask for the current workspace 🤷
2020-03-10 16:03:37 +01:00

29 lines
1.0 KiB
Bash
Executable File

#!/bin/sh
swaymsg -t subscribe -m '[ "window" ]' | while read -r event ; do
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)"
app_name="$(jq -r '.container.app_id' <<< $event)"
if [ $app_name = 'null' ] ; then
app_name="$(jq -r '.container.window_properties.instance' <<< $event)"
fi
if [ "$app_name" = "kitty" ] ; then
app_name=""
elif [ "$app_name" = "chromium" ] ; then
app_name=""
elif [ "$app_name" = "discord" ] ; then
app_name=""
elif [ "$app_name" = "spotify" ] ; then
app_name=""
elif [ "$app_name" = "GEMOC Studio" ] ; then
app_name=""
fi
swaymsg rename workspace "$workspace_name" to "$workspace_num:$app_name"
fi
done