feat: add $XDG_STATE_HOME directory

adapt sb-battery and setbg scripts
This commit is contained in:
David JULIEN 2021-10-23 02:54:42 +02:00
parent b03369ba79
commit 268c870d04
No known key found for this signature in database
GPG Key ID: 4B388E8BD9D47382
3 changed files with 9 additions and 6 deletions

View File

@ -13,8 +13,9 @@
# if $1 is a jpg file, set it as a wallpaper # 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 # 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"

View File

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

View File

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