polybar: Ignore/abort on missing commands/files

Catch if the files needed in the battery module are missing and exit
early.

Do not mess up the bar by printing error messages. Instead abort.
This commit is contained in:
2022-10-16 01:09:59 +02:00
parent e564bf0fe6
commit d327ddf79b
2 changed files with 3 additions and 3 deletions

View File

@@ -11,8 +11,8 @@ red='%{F#f00}'
green='%{F#0f0}'
end='%{F-}'
bat="$(cat /sys/class/power_supply/BAT0/capacity)"
ac="$(cat /sys/class/power_supply/AC/online)"
bat="$(cat /sys/class/power_supply/BAT0/capacity 2>/dev/null)" || exit
ac="$(cat /sys/class/power_supply/AC/online 2>/dev/null)"
declare -a ramp
ramp=(          )

View File

@@ -1,6 +1,6 @@
#!/bin/sh
command -v playerctl >/dev/null 2>&1 || { printf "playerctl not found.\n" >&2; exit 1; }
command -v playerctl >/dev/null 2>&1 || exit 1
metadata="$(playerctl metadata --format '{{status}} {{artist}}' 2>/dev/null)"
title="$(playerctl metadata --format '{{title}}' 2>/dev/null)"