1
0
mirror of https://github.com/dcarrillo/dotfiles.git synced 2024-12-22 16:18:00 +00:00

[polybar] Hide 'tasks' label if there are no tasks

This commit is contained in:
Daniel Carrillo 2020-04-10 14:48:33 +02:00
parent c7e3f45906
commit abe3ad126c

View File

@ -1,14 +1,15 @@
#!/usr/bin/env bash #!/usr/bin/env bash
STATUS_FILE=/dev/shm/polybar_task_manager STATUS_FILE=/dev/shm/polybar_task_manager
REFRESH=2 REFRESH=1
create_module_tasklabel() create_module_tasklabel()
{ {
cat <<TASKLABEL_TEMPLATE cat <<TASKLABEL_TEMPLATE
[module/taskslabel] [module/taskslabel]
type = custom/text type = custom/ipc
content = "%{T4}Tasks:%{T-}" hook-0 = echo "%{T4}Tasks:%{T-}"
hook-1 = echo ""
click-left = rofi -modi window -show window -theme orange -show-icons -location 1 -yoffset +45 -xoffset +20 click-left = rofi -modi window -show window -theme orange -show-icons -location 1 -yoffset +45 -xoffset +20
TASKLABEL_TEMPLATE TASKLABEL_TEMPLATE
@ -78,6 +79,13 @@ show_tasks()
mv $STATUS_FILE.current $STATUS_FILE mv $STATUS_FILE.current $STATUS_FILE
num_windows=$(wc -l $STATUS_FILE | cut -f 1 -d " ") num_windows=$(wc -l $STATUS_FILE | cut -f 1 -d " ")
if [ "$num_windows" -eq 0 ]; then
polybar-msg hook taskslabel 2 > /dev/null
else
polybar-msg hook taskslabel 1 > /dev/null
fi
for counter in $(seq 1 "$max_tasks"); do for counter in $(seq 1 "$max_tasks"); do
if [ "$counter" -le "$num_windows" ]; then if [ "$counter" -le "$num_windows" ]; then
polybar-msg hook taskbar"$counter" 2 > /dev/null polybar-msg hook taskbar"$counter" 2 > /dev/null