refactor(waybar): refactor check updates scripts
This commit is contained in:
@@ -1,14 +1,18 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
main() {
|
main() {
|
||||||
|
data=""
|
||||||
updates=$(checkupdates --nocolor 2>/dev/null)
|
updates=$(checkupdates --nocolor 2>/dev/null)
|
||||||
|
|
||||||
if [[ $? -ne 0 || -z "$updates" ]]; then
|
if [[ $? -ne 0 || -z "$updates" ]]; then
|
||||||
echo '{"text": "", "tooltip": ""}' | jq --unbuffered --compact-output
|
data='{"text": "", "tooltip": ""}'
|
||||||
else
|
else
|
||||||
numberOfUpdates=$(echo "$updates" | wc -l)
|
numberOfUpdates=$(echo "$updates" | wc -l)
|
||||||
tooltip=$(echo "$updates" | sed 's/\n/\r/g' | jq -sR .)
|
tooltip=$(echo "$updates" | sed 's/\n/\r/g' | jq -sR .)
|
||||||
echo "{\"text\": \"$numberOfUpdates\", \"tooltip\": $tooltip}" | jq --unbuffered --compact-output
|
data="{\"text\": \"$numberOfUpdates\", \"tooltip\": $tooltip}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
echo $data | jq --unbuffered --compact-output
|
||||||
}
|
}
|
||||||
|
|
||||||
main "$@"
|
main "$@"
|
Reference in New Issue
Block a user