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

[polybar] Enhance active window in task bar

This commit is contained in:
Daniel Carrillo 2020-08-01 16:11:11 +02:00
parent 80a47fbbcc
commit 716106c528

View File

@ -86,10 +86,14 @@ show_tasks()
| awk -F'.' '{ print $NF }' \ | awk -F'.' '{ print $NF }' \
| tail -"$max_tasks" | sort > $STATUS_FILE.current | tail -"$max_tasks" | sort > $STATUS_FILE.current
diff -q $STATUS_FILE $STATUS_FILE.current > /dev/null 2>&1 if [ -f $STATUS_FILE.active ]; then
if [ $? -ne 1 ]; then if [ "$(get_task_id "$(cat $STATUS_FILE.active)")" = "$(get_active_window)" ]; then
rm -rf $STATUS_FILE.current diff -q $STATUS_FILE $STATUS_FILE.current > /dev/null 2>&1
return 0 if [ $? -ne 1 ]; then
rm -rf $STATUS_FILE.current
return 0
fi
fi
fi fi
mv $STATUS_FILE.current $STATUS_FILE mv $STATUS_FILE.current $STATUS_FILE
@ -113,17 +117,20 @@ show_tasks()
done done
} }
print_task_name() print_task_icon()
{ {
name=$(sed "${1}q;d" $STATUS_FILE | cut -f 1 -d " " | tr '[:upper:]' '[:lower:]') name=$(sed "${1}q;d" $STATUS_FILE | cut -f 1 -d " " | tr '[:upper:]' '[:lower:]')
icon=$(get_icon_by_name "$name") icon=$(get_icon_by_name "$name")
if [ -n "$icon" ]; then if [ "$(get_task_id "$1")" = "$(get_active_window)" ]; then
name="$name " echo '%{T6}%{F#FDD835}'"$icon"'%{F-}%{T-}'
if [ -f $STATUS_FILE.active ]; then
polybar-msg hook "taskbar$(cat $STATUS_FILE.active)" 2 > /dev/null
fi
echo "$1" > $STATUS_FILE.active
else
echo '%{T6}'"$icon"'%{T-}'
fi fi
#echo "${name^}${icon}"
echo '%{T6}'"$icon"'%{T-}'
} }
show_task_menu() show_task_menu()
@ -149,7 +156,7 @@ show_task_menu()
;; ;;
esac esac
print_task_name "$1" print_task_icon "$1"
} }
get_active_window() get_active_window()
@ -185,7 +192,7 @@ case "$1" in
update_bar_config "$2" >> ~/.config/polybar/task_manager.ini update_bar_config "$2" >> ~/.config/polybar/task_manager.ini
;; ;;
--set-task) --set-task)
print_task_name "$2" print_task_icon "$2"
;; ;;
--show-menu) --show-menu)
show_task_menu "$2" show_task_menu "$2"
@ -198,7 +205,7 @@ case "$1" in
else else
wmctrl -ia "$id" wmctrl -ia "$id"
fi fi
print_task_name "$2" print_task_icon "$2"
;; ;;
--close-window) --close-window)
id=$(get_task_id "$2") id=$(get_task_id "$2")