aboutsummaryrefslogtreecommitdiff
path: root/bin/linux/dnf-needs-restarting
diff options
context:
space:
mode:
Diffstat (limited to 'bin/linux/dnf-needs-restarting')
-rwxr-xr-xbin/linux/dnf-needs-restarting26
1 files changed, 26 insertions, 0 deletions
diff --git a/bin/linux/dnf-needs-restarting b/bin/linux/dnf-needs-restarting
new file mode 100755
index 0000000..60f7f7c
--- /dev/null
+++ b/bin/linux/dnf-needs-restarting
@@ -0,0 +1,26 @@
+#!/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
+
+# this is a literal expression for `jq`
+# shellcheck disable=SC2016
+$JQCMD --unbuffered -n -c '{tooltip: $ARGS.positional[0], text: $ARGS.positional[1]}' --args "$output" "$icon"