-
Notifications
You must be signed in to change notification settings - Fork 2
/
rename-ws.sh
executable file
·34 lines (30 loc) · 1.01 KB
/
rename-ws.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#!/bin/bash
# Dynamic [i3|bspwm|herbstluftwm] workspace renamer
set -o pipefail
set -e
if [ "$1" = GUI ]; then
NEW=$(picker -p "Enter new ws name:" </dev/null)
else
NEW=$(fzf --print-query --prompt "Enter new ws name: " </dev/null | head -1) || true
fi
NEW=$(printf "%s" "$NEW" | sed 's/\t/ /g') || exit
if pgrep i3; then
WS=$(i3-msg -t 'get_workspaces' | jq '.[] |select(.focused == true).name' -r)
WSNUM=$(echo "$WS" | cut -d':' -f1)
i3-msg "rename workspace \"$WS\" to \"$WSNUM: $NEW\""
elif pgrep bspwm; then
WSNUM=$(bspc query -D -d --names | grep -oP '^[0-9]+')
if [[ "$NEW" ]]; then
bspc desktop --rename "$WSNUM: $NEW"
else
bspc desktop --rename "$WSNUM"
fi
elif pgrep herbstluftwm; then
if [[ "$NEW" ]]; then
herbstclient attr tags.focus.name \
"$((($(herbstclient attr tags.focus.index) + 1) % 10)): $NEW"
else
herbstclient attr tags.focus.name \
"$((($(herbstclient attr tags.focus.index) + 1) % 10))"
fi
fi