aboutsummaryrefslogtreecommitdiff
path: root/bin
diff options
context:
space:
mode:
authorMatt Singleton <matt@xcolour.net>2022-09-27 11:49:14 -0500
committerMatt Singleton <matt@xcolour.net>2022-09-27 11:49:14 -0500
commit29f7bf92edf6031f8d40928514b9408cd3ec610f (patch)
tree2df9db96825404e2306bb5bfb22636fe9f6c44ab /bin
parentf048fcca53f0c7ed7115e5a050a281e70939bcf8 (diff)
waybar indicator for when a restart is needed
Diffstat (limited to 'bin')
-rwxr-xr-xbin/dnf-needs-restarting24
1 files changed, 24 insertions, 0 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"