[polybar] Update dynamic configuration for task_manager

This commit is contained in:
Daniel Carrillo 2020-04-10 16:17:05 +02:00
parent f626125c68
commit 61efb724a3
4 changed files with 34 additions and 18 deletions

View File

@ -67,7 +67,8 @@ font-3 = NotoSans-Regular:size=18:weight=bold:antialias=true;2
font-4 = NotoSans-Regular:size=28:weight=bold:antialias=true;-12
font-5 = "FontAwesome:size=21:antialias=true;4"
modules-left = taskslabel taskbar1 taskbar2 taskbar3 taskbar4 taskbar5 taskbar6 taskbar7 taskbar8 taskbar9 taskbar10
modules-left-dynamic =
include-file = ~/.config/polybar/modules-left.ini
modules-center = custom_date
modules-right = updates cpu_bar memory_bar vpn network_usage alsa_bar

View File

@ -9,6 +9,8 @@ done
export TERMINAL_CMD="tilix --profile orange --new-process -e"
export WM_CONTROL="$(dirname "$0")/scripts/switch_window_state"
~/.config/polybar/scripts/task_manager --generate-config 20
for monitor in $(polybar --list-monitors | cut -d":" -f1); do
export MONITOR=$monitor
polybar top -c ~/.config/polybar/bar.ini >/dev/null &
@ -18,4 +20,4 @@ until pgrep -u "$(id -u)" -x polybar >/dev/null; do
sleep 0.5
done
~/.config/polybar/scripts/task_manager --daemon 15 &
~/.config/polybar/scripts/task_manager --daemon &

View File

@ -1,22 +1,15 @@
#!/usr/bin/env bash
STATUS_FILE=/dev/shm/polybar_task_manager
BAR_CONFIG_FILE=~/.config/polybar/bar.ini
MODULES_LEFT_FILE=~/.config/polybar/modules-left.ini
REFRESH=1
create_module_tasklabel()
update_bar_config()
{
cat <<TASKLABEL_TEMPLATE
[module/taskslabel]
type = custom/ipc
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
base_config=$(grep -e "^modules-left-dynamic *= *" $BAR_CONFIG_FILE | cut -f 3- -d " " )
new_config="taskslabel"
TASKLABEL_TEMPLATE
}
create_module_sections()
{
for task in $(seq 1 "$1"); do
cat <<MODULE_TEMPLATE
@ -31,7 +24,22 @@ click-middle = polybar-msg -p %pid% hook taskbar$task 4
MODULE_TEMPLATE
new_config="$new_config taskbar$task"
done
echo "modules-left = $base_config $new_config" > $MODULES_LEFT_FILE
}
create_module_tasklabel()
{
cat <<TASKLABEL_TEMPLATE
[module/taskslabel]
type = custom/ipc
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
TASKLABEL_TEMPLATE
}
get_icon_by_name()
@ -48,7 +56,10 @@ get_icon_by_name()
[gnome-calendar]=
[gnome-control-center]=
[eog]=
[evince]=
[gimp-210]=
[nautilus]=
[file-roller]=
[keepassxc]=
[steam]=
[skype]=
@ -122,9 +133,6 @@ get_task_id()
daemon()
{
create_module_tasklabel > ~/.config/polybar/task_manager.ini
create_module_sections "$1" >> ~/.config/polybar/task_manager.ini
while true; do
show_tasks
sleep $REFRESH
@ -134,7 +142,11 @@ daemon()
case "$1" in
--daemon)
> /dev/shm/polybar_task_manager
daemon "$2"
daemon
;;
--generate-config)
create_module_tasklabel > ~/.config/polybar/task_manager.ini
update_bar_config "$2" >> ~/.config/polybar/task_manager.ini
;;
--set-task)
print_task_name "$2"

1
.gitignore vendored
View File

@ -1 +1,2 @@
.config/polybar/task_manager.ini
.config/polybar/modules-left.ini