-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy path02-rename-ws.sh
More file actions
executable file
·39 lines (35 loc) · 1.3 KB
/
Copy path02-rename-ws.sh
File metadata and controls
executable file
·39 lines (35 loc) · 1.3 KB
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
35
36
37
38
39
#!/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
[[ "$NEW" ]] || exit 0
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
elif pgrep hyprland; then
WS=$(hyprctl activeworkspace | head -n 1 | cut -d' ' -f3)
WSNUM=$(hyprctl activeworkspace | head -n 1 | grep -oE '\([^)]+\)' | tr -d '()' | cut -d: -f1)
hyprctl dispatch "hl.dsp.workspace.rename({ workspace = '$WSNUM', name = '$WSNUM: $NEW' })"
fi