From 8f1247b0a6678d5ed5d1b76ebac806cc81de87d1 Mon Sep 17 00:00:00 2001 From: Harzo Date: Fri, 26 May 2023 14:51:07 +0200 Subject: [PATCH] Waybar: Add checkupdates script Update path and signal in config, add IPC support (maybe pkill will work and update the module without killing the whole waybar?) --- .config/waybar/config.jsonc | 7 ++++--- .config/waybar/scripts/checkupdates | 13 +++++++++++++ 2 files changed, 17 insertions(+), 3 deletions(-) create mode 100755 .config/waybar/scripts/checkupdates diff --git a/.config/waybar/config.jsonc b/.config/waybar/config.jsonc index 8a9c714..9a969bf 100644 --- a/.config/waybar/config.jsonc +++ b/.config/waybar/config.jsonc @@ -3,6 +3,7 @@ "position": "top", "height": 30, "spacing": 4, + "ipc": true, "modules-left": [ "clock", "custom/weather", @@ -91,10 +92,10 @@ "format": "󰏗 {}", "interval": "3600", "return-type": "json", - "exec": "$HOME/.local/bin/scripts/checkupdates", + "exec": "$HOME/.config/waybar/scripts/checkupdates", "exec-if": "exit 0", - "signal": 12, - "on-click": "foot paru; pkill waybar; waybar &" + "signal": 8, + "on-click": "foot paru; pkill -SIGRTMIN+8 waybar" }, "custom/weather": { "exec": "curl -s 'https://wttr.in/?format=1' | sed 's/ \\+/ /g'", diff --git a/.config/waybar/scripts/checkupdates b/.config/waybar/scripts/checkupdates new file mode 100755 index 0000000..a695922 --- /dev/null +++ b/.config/waybar/scripts/checkupdates @@ -0,0 +1,13 @@ +#!/bin/sh +updates="$(paru -Qua | wc -l)" + +count="$(echo "$(paru -Qua | wc -l) + $(pacman -Qu | wc -l)" | bc)" + +class="ok" +if [ "$count" -gt 0 ]; then + class="urgent" +elif [ "$count" -gt 10 ]; then + class="warning" +fi + +echo '{"text": "'$count'", "tooltip": "Updates pending: '$count'", "class": "'$class'"}'