diff options
author | Matt Singleton <matt@xcolour.net> | 2022-09-27 11:49:14 -0500 |
---|---|---|
committer | Matt Singleton <matt@xcolour.net> | 2022-09-27 11:49:14 -0500 |
commit | 29f7bf92edf6031f8d40928514b9408cd3ec610f (patch) | |
tree | 2df9db96825404e2306bb5bfb22636fe9f6c44ab | |
parent | f048fcca53f0c7ed7115e5a050a281e70939bcf8 (diff) |
waybar indicator for when a restart is needed
-rwxr-xr-x | bin/dnf-needs-restarting | 24 | ||||
-rw-r--r-- | config/waybar/config | 14 | ||||
-rw-r--r-- | config/waybar/style.css | 4 |
3 files changed, 39 insertions, 3 deletions
diff --git a/bin/dnf-needs-restarting b/bin/dnf-needs-restarting new file mode 100755 index 0000000..53932b1 --- /dev/null +++ b/bin/dnf-needs-restarting @@ -0,0 +1,24 @@ +#!/bin/bash + +set -eo pipefail + +if command -v dnf > /dev/null; then + DNFCMD="dnf" +fi +if command -v jq > /dev/null; then + JQCMD="jq" +fi +if [ -z "$DNFCMD" ] || [ -z "$JQCMD" ]; then + echo "{\"tooltip\": \"requires 'jq' and 'dnf'\", \"text\": \"\"}" + exit 1 +fi + +set -u + +if ! output="$($DNFCMD needs-restarting -r)"; then + icon="勒" +else + icon="" +fi + +$JQCMD --unbuffered -n -c '{tooltip: $ARGS.positional[0], text: $ARGS.positional[1]}' --args "$output" "$icon" diff --git a/config/waybar/config b/config/waybar/config index 4f04b34..fc238e5 100644 --- a/config/waybar/config +++ b/config/waybar/config @@ -6,7 +6,7 @@ "height": 0, "modules-left": ["sway/workspaces", "sway/mode"], "modules-center": [], - "modules-right": ["tray", "network#wifi", "pulseaudio", "battery#bat1", "temperature", "idle_inhibitor", "clock#local"], + "modules-right": ["tray", "custom/reboot", "network#wifi", "pulseaudio", "battery#bat1", "temperature", "idle_inhibitor", "clock#local"], "sway/workspaces": { "format": "{icon}", "format-icons": { @@ -24,7 +24,8 @@ "temperature": { "critical-threshold": 80, "format": "{icon} {temperatureC}°C", - "format-icons": ["", "", "", "", ""] + "format-icons": ["", "", "", "", ""], + "tooltip": false }, "battery#bat1": { "bat": "BAT0", @@ -76,7 +77,14 @@ "format-icons": { "activated": "", "deactivated": "" - } + }, + "tooltip": false + }, + "custom/reboot": { + "format": "{}", + "exec": "~/.local/bin/dnf-needs-restarting", + "return-type": "json", + "interval": 60 } } ] diff --git a/config/waybar/style.css b/config/waybar/style.css index 6858337..ebcf4a6 100644 --- a/config/waybar/style.css +++ b/config/waybar/style.css @@ -56,3 +56,7 @@ label { background: #a32a3a; text-shadow: 1px 1px 0 #ae4e2a; } + +#custom-reboot { + color: #a32a3a; +} |