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

[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-4 = NotoSans-Regular:size=28:weight=bold:antialias=true;-12
font-5 = "FontAwesome:size=21:antialias=true;4" 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-center = custom_date
modules-right = updates cpu_bar memory_bar vpn network_usage alsa_bar 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 TERMINAL_CMD="tilix --profile orange --new-process -e"
export WM_CONTROL="$(dirname "$0")/scripts/switch_window_state" 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 for monitor in $(polybar --list-monitors | cut -d":" -f1); do
export MONITOR=$monitor export MONITOR=$monitor
polybar top -c ~/.config/polybar/bar.ini >/dev/null & 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 sleep 0.5
done done
~/.config/polybar/scripts/task_manager --daemon 15 & ~/.config/polybar/scripts/task_manager --daemon &

View File

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

1
.gitignore vendored
View File

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