From 29f7bf92edf6031f8d40928514b9408cd3ec610f Mon Sep 17 00:00:00 2001 From: Matt Singleton Date: Tue, 27 Sep 2022 11:49:14 -0500 Subject: waybar indicator for when a restart is needed --- bin/dnf-needs-restarting | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100755 bin/dnf-needs-restarting (limited to 'bin/dnf-needs-restarting') 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" -- cgit v1.2.3