Skip to content

Instantly share code, notes, and snippets.

@naranyala
Created May 24, 2024 17:40
Show Gist options
  • Save naranyala/709e038c050006c344ef358fa00cf5a6 to your computer and use it in GitHub Desktop.
Save naranyala/709e038c050006c344ef358fa00cf5a6 to your computer and use it in GitHub Desktop.
polybar module for herbstluftwm tags indicator
#!/bin/bash
# Get the list of tags (workspaces) with their states
tags=$(herbstclient tag_status)
# Primary Colors
clr_red="#FF0000"
clr_orange="#FFA500"
clr_yellow="#FFFF00"
clr_green="#008000"
clr_blue="#0000FF"
clr_indigo="#4B0082"
clr_violet="#EE82EE"
# Secondary Colors
clr_light_red="#FF6666"
clr_light_orange="#FFB347"
clr_light_yellow="#FFFF99"
clr_light_green="#66FF66"
clr_light_blue="#6666FF"
clr_light_indigo="#9370DB"
clr_light_violet="#E6E6FA"
# Dark colors
clr_dark_red="#8B0000"
clr_dark_orange="#FF8C00"
clr_dark_yellow="#FFD700"
clr_dark_green="#006400"
clr_dark_blue="#00008B"
clr_dark_indigo="#3A005A"
clr_dark_violet="#9400D3"
clr_white="#F5F5F5"
clr_black="#000000"
ACTIVE_COLOR="$clr_light_green"
INACTIVE_COLOR="$clr_white"
FOCUS_COLOR="$clr_light_yellow"
output=""
for tag in $tags; do
tag_name="${tag:1}"
case ${tag:0:1} in
'#') # Active workspace
output+="%{A1:herbstclient use $tag_name:}%{F$ACTIVE_COLOR}${tag_name}%{F-}%{A} "
;;
':') # Inactive workspace with windows
output+="%{A1:herbstclient use $tag_name:}${tag_name}%{A} "
;;
'!') # Urgent workspace
output+="%{A1:herbstclient use $tag_name:}%{F$FOCUS_COLOR}${tag_name}%{F-}%{A} "
;;
*) # Empty workspace or other states
output+="%{A1:herbstclient use $tag_name:}${tag_name}%{A} "
;;
esac
done
echo $output
# [module/workspaces]
# type = custom/script
# exec = ~/.config/polybar/scripts/workspaces-hlwm.sh
# interval = 0.5
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment