From 1eb50f10b0b5c4c4ba4742910f3a8ce01f1857e5 Mon Sep 17 00:00:00 2001 From: Daryl Ronningen Date: Mon, 11 Jul 2022 12:20:52 -0700 Subject: [PATCH] added polybar updates --- .config/polybar/config.ini | 21 ++++++++++++++++----- .config/polybar/updates.sh | 17 +++++++++++++++++ 2 files changed, 33 insertions(+), 5 deletions(-) create mode 100755 .config/polybar/updates.sh diff --git a/.config/polybar/config.ini b/.config/polybar/config.ini index 4928070..b6fef8c 100644 --- a/.config/polybar/config.ini +++ b/.config/polybar/config.ini @@ -15,7 +15,7 @@ font-2 = FiraCode Nerd Font Mono:pixelsize=10;2 modules-left = bspwm RightArrow RightStripe RightArrow modules-center = xwindow -modules-right = LeftArrow3 LeftStripe LeftArrow3 pulseaudio LeftArrow1 filesystem LeftArrow2 cpu LeftArrow1 memory LeftArrow2 date +modules-right = LeftArrow3 LeftStripe LeftArrow3 pulseaudio LeftArrow1 updates LeftArrow2 filesystem LeftArrow1 cpu LeftArrow2 memory LeftArrow1 date cursor-click = pointer cursor-scroll = ns-resize @@ -99,7 +99,7 @@ type = internal/cpu interval = 2 -format-background = ${colors.cyan} +format-background = ${colors.red} label =  CPU: %percentage%% label-foreground = ${colors.text} @@ -116,7 +116,7 @@ date-alt = " %d %B %Y" time = %a %r time-alt = " %A %r" -format-background = ${colors.cyan} +format-background = ${colors.red} label =  %date% %time% label-foreground = ${colors.text} @@ -129,7 +129,7 @@ internal = 30 mount-0 = / -format-mounted-background = ${colors.red} +format-mounted-background = ${colors.cyan} label-mounted =  %mountpoint%: %used%/%total% label-mounted-foreground = ${colors.text} @@ -140,7 +140,7 @@ type = internal/memory interval = 2 -format-background = ${colors.red} +format-background = ${colors.cyan} label =  RAM: %percentage_used%% label-foreground = ${colors.text} @@ -219,6 +219,17 @@ label-muted-foreground = ${colors.text} type = internal/tray +[module/updates] +type = custom/script +exec = $HOME/.config/polybar/updates.sh +interval = 600 +label = Updates: %output% +format-foreground = ${colors.text} +format-background = ${colors.red} +format-prefix = " " +format-prefix-foreground = ${colors.text} + + [module/windows] type = custom/script exec = ${env:P_BSPWM_WINDOW_CMD} diff --git a/.config/polybar/updates.sh b/.config/polybar/updates.sh new file mode 100755 index 0000000..38fe49c --- /dev/null +++ b/.config/polybar/updates.sh @@ -0,0 +1,17 @@ +#!/bin/sh + +if ! updates_arch=$(checkupdates 2> /dev/null | wc -l ); then + updates_arch=0 +fi + +if ! updates_aur=$(paru -Qua 2> /dev/null | wc -l); then + updates_aur=0 +fi + +updates=$(("$updates_arch" + "$updates_aur")) + +if [ "$updates" -gt 0 ]; then + echo " $updates" +else + echo "0" +fi