mirror of
https://github.com/dcarrillo/dotfiles.git
synced 2024-12-22 11:38:00 +00:00
[polybar] Add a MVP task_manager module
This commit is contained in:
parent
6e208cb7fc
commit
eb5a55e82d
@ -32,6 +32,7 @@ radius-bottom = 0.0
|
||||
|
||||
border-bottom-size = 3
|
||||
border-color = ${colors.primary}
|
||||
padding-left = 2
|
||||
padding-right = 2
|
||||
|
||||
module-margin-left = 1
|
||||
@ -65,7 +66,7 @@ font-2 = "Material Icons:size=16;1"
|
||||
font-3 = NotoSans-Regular:size=18:weight=bold;2
|
||||
font-4 = NotoSans-Regular:size=18:weight=bold;-7
|
||||
|
||||
modules-left = spotify
|
||||
modules-left = taskbar1 taskbar2 taskbar3 taskbar4 taskbar5 taskbar6 taskbar7 taskbar8 taskbar9 taskbar10 spotify
|
||||
modules-center = custom_date
|
||||
modules-right = updates cpu_bar memory_bar vpn network_usage alsa_bar
|
||||
|
||||
|
@ -1,14 +1,21 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
killall -q polybar
|
||||
while pgrep -u "$(id -u)" -x polybar >/dev/null; do sleep 1; done
|
||||
pkill polybar
|
||||
pkill -f "task_manager --daemon"
|
||||
while pgrep -u "$(id -u)" -x polybar >/dev/null; do
|
||||
sleep 0.5;
|
||||
done
|
||||
|
||||
export TERMINAL_CMD="tilix --profile orange --new-process -e"
|
||||
WM_CONTROL="$(dirname "$0")/scripts/switch_window_state"
|
||||
export WM_CONTROL
|
||||
export WM_CONTROL="$(dirname "$0")/scripts/switch_window_state"
|
||||
|
||||
for monitor in $(polybar --list-monitors | cut -d":" -f1); do
|
||||
export MONITOR=$monitor
|
||||
polybar top -c ~/.config/polybar/bar.ini >/dev/null &
|
||||
done
|
||||
|
||||
until pgrep -u "$(id -u)" -x polybar >/dev/null; do
|
||||
sleep 0.5
|
||||
done
|
||||
|
||||
~/.config/polybar/scripts/task_manager --daemon &
|
||||
|
@ -153,3 +153,45 @@ exec = ~/.config/polybar/scripts/check_updates
|
||||
tail = true
|
||||
interval = 5
|
||||
click-left = $TERMINAL_CMD "yay -Suy" &
|
||||
|
||||
|
||||
[module/taskbar1]
|
||||
type = custom/ipc
|
||||
hook-0 = ~/.config/polybar/scripts/task_manager --window 1
|
||||
hook-1 = echo ""
|
||||
[module/taskbar2]
|
||||
type = custom/ipc
|
||||
hook-0 = ~/.config/polybar/scripts/task_manager --window 2
|
||||
hook-1 = echo ""
|
||||
[module/taskbar3]
|
||||
type = custom/ipc
|
||||
hook-0 = ~/.config/polybar/scripts/task_manager --window 3
|
||||
hook-1 = echo ""
|
||||
[module/taskbar4]
|
||||
type = custom/ipc
|
||||
hook-0 = ~/.config/polybar/scripts/task_manager --window 4
|
||||
hook-1 = echo ""
|
||||
[module/taskbar5]
|
||||
type = custom/ipc
|
||||
hook-0 = ~/.config/polybar/scripts/task_manager --window 5
|
||||
hook-1 = echo ""
|
||||
[module/taskbar6]
|
||||
type = custom/ipc
|
||||
hook-0 = ~/.config/polybar/scripts/task_manager --window 6
|
||||
hook-1 = echo ""
|
||||
[module/taskbar7]
|
||||
type = custom/ipc
|
||||
hook-0 = ~/.config/polybar/scripts/task_manager --window 7
|
||||
hook-1 = echo ""
|
||||
[module/taskbar8]
|
||||
type = custom/ipc
|
||||
hook-0 = ~/.config/polybar/scripts/task_manager --window 8
|
||||
hook-1 = echo ""
|
||||
[module/taskbar9]
|
||||
type = custom/ipc
|
||||
hook-0 = ~/.config/polybar/scripts/task_manager --window 9
|
||||
hook-1 = echo ""
|
||||
[module/taskbar10]
|
||||
type = custom/ipc
|
||||
hook-0 = ~/.config/polybar/scripts/task_manager --window 10
|
||||
hook-1 = echo ""
|
||||
|
51
.config/polybar/scripts/task_manager
Executable file
51
.config/polybar/scripts/task_manager
Executable file
@ -0,0 +1,51 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
STATUS_FILE=/dev/shm/polybar_task_manager
|
||||
REFRESH=2
|
||||
MAX_TASKS=10
|
||||
|
||||
show_tasks()
|
||||
{
|
||||
wmctrl -lx | awk '{if ($2 > -1) print $3}' \
|
||||
| awk -F'.' '{ print $NF }' \
|
||||
| tail -$MAX_TASKS | sort > $STATUS_FILE.current
|
||||
|
||||
diff -q $STATUS_FILE $STATUS_FILE.current > /dev/null 2>&1
|
||||
if [ $? -ne 1 ]; then
|
||||
return 0
|
||||
fi
|
||||
|
||||
mv $STATUS_FILE.current $STATUS_FILE
|
||||
|
||||
counter=1
|
||||
num_windows=$(wc -l $STATUS_FILE | cut -f 1 -d " ")
|
||||
while [ $counter -le "$MAX_TASKS" ]; do
|
||||
if [ $counter -le "$num_windows" ]; then
|
||||
polybar-msg hook taskbar$counter 1 > /dev/null
|
||||
else
|
||||
polybar-msg hook taskbar"$counter" 2 > /dev/null
|
||||
fi
|
||||
|
||||
sleep 0.1
|
||||
counter=$((counter+1))
|
||||
done
|
||||
}
|
||||
|
||||
daemon()
|
||||
{
|
||||
while true; do
|
||||
show_tasks
|
||||
sleep $REFRESH
|
||||
done
|
||||
}
|
||||
|
||||
if [ "$1" = "--daemon" ]; then
|
||||
> /dev/shm/polybar_task_manager
|
||||
daemon
|
||||
fi
|
||||
|
||||
if [ "$1" = "--window" ]; then
|
||||
sed "${2}q;d" $STATUS_FILE
|
||||
fi
|
||||
|
||||
exit 1
|
Loading…
Reference in New Issue
Block a user