diff options
| author | Danilo M. <danix@danix.xyz> | 2026-09-15 12:17:58 +0200 |
|---|---|---|
| committer | Danilo M. <danix@danix.xyz> | 2026-09-15 12:17:58 +0200 |
| commit | 180accd0a4dde00a25c1766c6b962809998d2ad7 (patch) | |
| tree | 6180e830b46bcd309c2813041614a4604275bd86 /docs/superpowers/plans | |
| parent | 405905dcd2308763114f8e479847f238243f2d6f (diff) | |
| download | quickshell-180accd0a4dde00a25c1766c6b962809998d2ad7.tar.gz quickshell-180accd0a4dde00a25c1766c6b962809998d2ad7.zip | |
fix(desktop): keep statusctl quiet when the mode file is absent
read_mode() failed on a missing mode file with a shell redirection
error, 'statusctl: line 56: .../status.dnd: No such file or directory',
printed to stderr on every get/toggle before the file existed and
polluting waybar's exec stderr.
The '2>/dev/null' sat on the 'tr' command, but the error is the parent
shell's input redirection failure, which that redirect cannot suppress.
Guard on '[[ -e "$file" ]]' before reading; a missing file still
reads as 0, which was always the contract.
Mirror the fix into the plan so plan and script agree.
Diffstat (limited to 'docs/superpowers/plans')
| -rw-r--r-- | docs/superpowers/plans/2026-09-15-status-registry.md | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/docs/superpowers/plans/2026-09-15-status-registry.md b/docs/superpowers/plans/2026-09-15-status-registry.md index 5f86de4..614952c 100644 --- a/docs/superpowers/plans/2026-09-15-status-registry.md +++ b/docs/superpowers/plans/2026-09-15-status-registry.md @@ -390,12 +390,12 @@ esac file="$DIR/status.$mode" read_mode() { - local v - # An unreadable file reads as off, deliberately: a missing mode file is - # the normal state before anything has written one, and the redirect - # makes that fallback explicit rather than a side effect of a pipeline - # swallowing cat's exit status. - v="$(tr -d '[:space:]' < "$file" 2>/dev/null)" + local v="" + # A missing file is the normal state before anything has written one and + # reads as off. Guarding on existence keeps the shell's redirection error + # off stderr: `2>/dev/null` on the command cannot suppress a failure of + # its own input redirect. + [[ -e "$file" ]] && v="$(tr -d '[:space:]' < "$file" 2>/dev/null)" [[ "$v" == "1" ]] && printf '1' || printf '0' } |
