blob: 7fc6542ae299df74d5224b652a793ed64819ac0d (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
|
#!/bin/bash
set -euo pipefail
if command -v dnf > /dev/null; then
DNFCMD="dnf"
fi
if command -v jq > /dev/null; then
JQCMD="jq"
fi
if [ -z "${DNFCMD+x}" ] || [ -z "${JQCMD+x}" ]; 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"
|