sxhkd: Add dzen2 script

This was a script I used to show the workspace number without having to
worry about having a bar in bspwm.
This commit is contained in:
Donovan Glover 2023-04-26 02:40:35 -04:00
parent 3ed20a4ae8
commit 0f720ca3c0
No known key found for this signature in database
GPG Key ID: EA7408A77AE1BE65

28
sxhkd/.config/sxhkd/dzen2.sh Executable file
View File

@ -0,0 +1,28 @@
#!/bin/sh
# Display brief desktop name notification at the center of the screen.
#
# Based on u/xircon's solution here:
# https://old.reddit.com/r/bspwm/comments/lhvtw7/osd_notifications_on_changing_desktop/
# Kill any old instances of dzen2 to prevent overlapping of notifications
pkill -x dzen2
# Display Variables:
hgt=128 # font size
wid=$((hgt*2)) # e.g. 3.5 times the height, will display the words 'Three' & 'Seven' correctly.
time=1
font="-*-Noto Sans CJK JP-bold-r-*-*-"$hgt"-*-*-*-*-*-*-*"
# Screen Resolution calculations:
full_res=$(cut -d " " -f 1 <<< $(xrandr | grep '*' | xargs)) # xargs removes leading spaces
res_wid="${full_res%%x*}" # Left of 'x' in 1600x900
res_hgt="${full_res##*x}" # Right of 'x'
# Do some calculations for x & y coordinates:
x=$((a=res_wid-wid, xx=a/2))
y=$((b=res_hgt-hgt-2, yy=b/2))
Deskname=$(bspc query -D -d focused --names)
# Display desktop number in the center of the screen:
echo "$Deskname" | dzen2 -bg "#000000" -w $wid -x $x -y $y -p $time -fn "$font"