Use temp file for cache

This commit is contained in:
Santiago Lo Coco 2024-04-10 11:27:56 +02:00
parent 0b3c6bfe92
commit d058087729
1 changed files with 3 additions and 3 deletions

View File

@ -2,7 +2,7 @@
set -e set -e
CACHE_FILE="${XDG_CACHE_HOME:-$HOME/.cache}/cbattery.status" TMP_FILE=/tmp/cbattery.status
SHARE_DIR=/usr/local/share/cbattery SHARE_DIR=/usr/local/share/cbattery
PATH="/usr/bin:/usr/local/bin:/usr/sbin:/opt/homebrew/bin:/opt/homebrew/sbin:/opt/homebrew:$PATH" PATH="/usr/bin:/usr/local/bin:/usr/sbin:/opt/homebrew/bin:/opt/homebrew/sbin:/opt/homebrew:$PATH"
@ -19,11 +19,11 @@ EOF
} }
write_cache() { write_cache() {
echo "$1" > "$CACHE_FILE" echo "$1" > "$TMP_FILE"
} }
read_cache() { read_cache() {
cat "$CACHE_FILE" 2> /dev/null cat "$TMP_FILE" 2> /dev/null
} }
enable_discharging() { enable_discharging() {