feat: add $XDG_STATE_HOME directory

adapt sb-battery and setbg scripts
dev
David JULIEN 11 months ago
parent b03369ba79
commit 268c870d04
Signed by: swytch
GPG Key ID: 4B388E8BD9D47382
  1. 7
      .local/bin/setbg
  2. 7
      .local/bin/statusbar/sb-battery
  3. 1
      .zshenv

@ -13,8 +13,9 @@
# if $1 is a jpg file, set it as a wallpaper
# if $1 is a directory, choose a randomized image in it, set it as wallpaper
[ -f "$1" ] && cp $1 "$XDG_CONFIG_HOME/wall.jpg" && dunstify -u "low" "Wallpaper changed"
wall="$XDG_STATE_HOME/wall.jpg"
[ -f "$1" ] && cp $1 "$wall" && dunstify -u "low" "Wallpaper changed"
[ -d "$1" ] && cp "$(find "$1"/*.jpg -type f | shuf -n 1)" "$XDG_CONFIG_HOME/wall.jpg" && dunstify -u "low" "Random wallpaper chosen"
[ -d "$1" ] && cp "$(find "$1"/*.jpg -type f | shuf -n 1)" "$" && dunstify -u "low" "Random wallpaper chosen"
xwallpaper --zoom "$XDG_CONFIG_HOME/wall.jpg"
xwallpaper --zoom "$wall"

@ -15,16 +15,17 @@
# In any case, show the remaining battery percentage
# Also sends a notification if battery running low
time="$XDG_STATE_HOME/batteryupdate"
notify() { \
now=$(date +%s)
if [ -e $XDG_CONFIG_HOME/batteryupdate ]; then
old=$(cat $XDG_CONFIG_HOME/batteryupdate)
if [ -e $time ]; then
old=$(cat $time)
delta=$(expr $now - $old)
else
delta=$now
fi
[ 300 -gt $delta ] && return;
echo $now > $XDG_CONFIG_HOME/batteryupdate
echo $now > $time
case "$capacity" in
2[0-9]) notify-send -u "normal" "Battery is running low ($capacity%)" "Please plug your computer to a power source" ;;
*) notify-send -u "critical" "Battery is dangerously low ($capacity%)" "Please plug your computer to a power source - <b>NOW!</b>" ;;

@ -4,6 +4,7 @@
export XDG_CACHE_HOME="$HOME/.cache"
export XDG_CONFIG_HOME="$HOME/.config"
export XDG_DATA_HOME="$HOME/.local/share"
export XDG_STATE_HOME="$HOME/.local/state"
export ZDOTDIR="$HOME/.config/zsh"

Loading…
Cancel
Save