Use XDG state directory instead of custom .spool

This commit is contained in:
John Mertz 2024-03-08 12:11:04 -07:00
parent 7a10a72476
commit 0eb58077e6
23 changed files with 65 additions and 65 deletions

View File

@ -1,7 +1,7 @@
#!/bin/sh
# distrobox_binary
# name: debian
USE_DISPLAYS=`cat /var/home/jpm/.spool/wallpaper_outputs`
USE_DISPLAYS=`cat /var/home/jpm/.local/state/wallpaper_outputs`
if [ ! -f /run/.containerenv ] && [ ! -f /.dockerenv ]; then
command="/usr/bin/distrobox-enter -n debian -- /var/home/jpm/scripts/sway/wallpaper.pl --path=/var/home/jpm/wallpapers -d $USE_DISPLAYS "

View File

@ -13,10 +13,10 @@ my $lat_lon = fetch_lat_lon($location);
my $pid = fork;
unless ($pid) {
open(my $fh, ">", $ENV{HOME}."/.spool/gammastep.pid");
open(my $fh, ">", $ENV{HOME}."/.local/state/gammastep.pid");
print $fh $$;
close($fh);
open($fh, ">", $ENV{HOME}."/.spool/gammastep.status");
open($fh, ">", $ENV{HOME}."/.local/state/gammastep.status");
print $fh 1;
close($fh);

View File

@ -1,17 +1,17 @@
#!/bin/bash
if [ -e "${HOME}/.spool/ssh-agent.sock" ]; then
PID=$(tail -n 1 "${HOME}/.spool/ssh-agent.env" | sed 's/echo Agent pid \([0-9]*\);/\1/')
if [ -e "${HOME}/.local/state/ssh-agent.sock" ]; then
PID=$(tail -n 1 "${HOME}/.local/state/ssh-agent.env" | sed 's/echo Agent pid \([0-9]*\);/\1/')
if [ -z "$PID" ]; then
rm "${HOME}/.spool/ssh-agent.sock" "${HOME}/.spool/ssh-agent.pid" 2>/dev/null
rm "${HOME}/.local/state/ssh-agent.sock" "${HOME}/.local/state/ssh-agent.pid" 2>/dev/null
pkill ssh-agent
else
CMD=$(ps -p "$PID" -o comm | tail -n 1)
if [ -n "$CMD" ] && [ "$CMD" == 'ssh-agent' ]; then
echo "Valid agent already found at ${HOME}/.spool/ssh-agent.sock with PID $PID"
echo "Valid agent already found at ${HOME}/.local/state/ssh-agent.sock with PID $PID"
exit
fi
fi
fi
eval $(ssh-agent -a "${HOME}/.spool/ssh-agent.sock" | tee "${HOME}/.spool/ssh-agent.env")
eval $(ssh-agent -a "${HOME}/.local/state/ssh-agent.sock" | tee "${HOME}/.local/state/ssh-agent.env")

View File

@ -34,7 +34,7 @@ use v5.36;
# "width": __WIDTH__ (optional)
my $waybar_template = "$ENV{'HOME'}/.dotfiles/waybar/config.template";
my $swaysock = $ENV{'SWAYSOCK'} || $ENV{'HOME'} . "/.spool/sway-ipc.sock";
my $swaysock = $ENV{'SWAYSOCK'} || $ENV{'HOME'} . "/.local/state/sway-ipc.sock";
# Path to actual config file generated from template
my $waybar_config = "$ENV{'HOME'}/.dotfiles/waybar/config";
@ -44,13 +44,13 @@ my $waybar_config = "$ENV{'HOME'}/.dotfiles/waybar/config";
my $waybar_bin = "/usr/bin/waybar";
# File to log and recover last used layout name
my $last = "$ENV{'HOME'}/.spool/last_display";
my $last = "$ENV{'HOME'}/.local/state/last_display";
# File to log active outputs (used by swayidle, and to attempt to restore
my $active_outputs = "$ENV{'HOME'}/.spool/active_outputs";
my $active_outputs = "$ENV{'HOME'}/.local/state/active_outputs";
# File to log which displays have a wallpaper active, will be written to restart wallpapers.pl
my $wallpaper_outputs .= "$ENV{'HOME'}/.spool/wallpaper_outputs";
my $wallpaper_outputs .= "$ENV{'HOME'}/.local/state/wallpaper_outputs";
my @wallpapers;
########################################################################

View File

@ -6,9 +6,9 @@ LOCK_TIMEOUT=300 # five minutes
SLEEP_TIMEOUT=600 # ten minutes
HIBERNATE_TIMEOUT=3600 # one hour
BLFILE="$HOME/.spool/idle.dim"
OPFILE="$HOME/.spool/active_outputs"
IDLEMODE=$(cat $HOME/.spool/idle_mode)
BLFILE="$HOME/.local/state/idle.dim"
OPFILE="$HOME/.local/state/active_outputs"
IDLEMODE=$(cat $HOME/.local/state/idle_mode)
if [[ -n $2 ]]; then
if [[ $2 == '--ignore_mode' ]]; then
IDLEMODE='hibernate'
@ -95,13 +95,13 @@ elif [[ $1 == "stop" ]]; then
pkill swayidle
elif [[ $1 == "fade" ]]; then
if [[ $IDLEMODE -gt 0 ]]; then
if [[ ! -e $HOME/.spool/sway-hidden ]]; then
kill -USR2 $(cat $HOME/.spool/sway-transparency)
if [[ ! -e $HOME/.local/state/sway-hidden ]]; then
kill -USR2 $(cat $HOME/.local/state/sway-transparency)
fi
fi
elif [[ $1 == "unfade" ]]; then
if [[ -e $HOME/.spool/sway-hidden ]]; then
kill -USR2 $(cat $HOME/.spool/sway-transparency)
if [[ -e $HOME/.local/state/sway-hidden ]]; then
kill -USR2 $(cat $HOME/.local/state/sway-transparency)
# TODO: This is a hack. There's no reason that waybar should be dead.
#$HOME/scripts/sway/displays.pl -w
fi
@ -130,7 +130,7 @@ elif [[ $1 == "unsleep" ]]; then
#$HOME/scripts/sway/displays.pl
cd $HOME/scripts/sway
source $HOME/.dotfiles/bash/plenv-path.sh
$HOME/scripts/sway/displays.pl 2>&1 >$HOME/.spool/display_unsleep
$HOME/scripts/sway/displays.pl 2>&1 >$HOME/.local/state/display_unsleep
elif [[ $1 == "hibernate" ]]; then
if [[ $IDLEMODE -gt 4 ]]; then
sudo systemctl suspend-then-hibernate.target

View File

@ -1,8 +1,8 @@
#!/bin/bash
rm $HOME/.swaylog
echo sway > $HOME/.spool/last_login_gui
echo sway > $HOME/.local/state/last_login_gui
export SSH_AUTH_SOCK=~/.ssh/ssh-agent.sock
export SWAYSOCK="$HOME/.spool/sway-ipc.sock"
export SWAYSOCK="$HOME/.local/state/sway-ipc.sock"
export QT_QPA_PLATFORM="wayland-egl;wayland;xcb"
export QT_QPA_PLATFORMTHEME=qt5ct
export QML_IMPORT_PATH="/usr/lib/qt/qml"

View File

@ -88,8 +88,8 @@ def set_all(ipc,opacity):
else:
window.command("opacity " + opacity)
flag = os.environ["HOME"]+"/.spool/sway-hidden"
pid = os.environ["HOME"]+"/.spool/sway-transparency"
flag = os.environ["HOME"]+"/.local/state/sway-hidden"
pid = os.environ["HOME"]+"/.local/state/sway-transparency"
opacity = "0.85"
if __name__ == "__main__":

View File

@ -1,6 +1,6 @@
#!/bin/bash
CURRENT=`cat /home/jpm/.spool/last_display`
CURRENT=`cat /home/jpm/.local/state/last_display`
if [ "$CURRENT" == "x13" ]; then
/home/jpm/scripts/sway/displays.pl Both

View File

@ -7,7 +7,6 @@ use v5.36;
use POSIX;
use File::Copy;
use lib "$ENV{HOME}/perl5/lib/perl5";
$ENV{PWD} = '/tmp' unless (defined($ENV{PWD}));
use constant ERROR => {

View File

@ -67,8 +67,8 @@
my $cur_file = "/sys/class/backlight/intel_backlight/brightness";
chmod('0644',$cur_file) unless ( -w $cur_file );
my $max_file = "/sys/class/backlight/intel_backlight/max_brightness";
my $cur_log = $ENV{HOME}."/.spool/blc.current";
my $last_log = $ENV{HOME}."/.spool/blc.last";
my $cur_log = $ENV{HOME}."/.local/state/blc.current";
my $last_log = $ENV{HOME}."/.local/state/blc.last";
sub to_percent
{

View File

@ -5,7 +5,7 @@ use warnings;
our $maxfile = "/sys/class/leds/tpacpi\:\:kbd_backlight/max_brightness";
our $current = "/sys/class/leds/tpacpi\:\:kbd_backlight/brightness";
our $sleepfile = "$ENV{HOME}/.spool/kbd_sleep";
our $sleepfile = "$ENV{HOME}/.local/state/kbd_sleep";
sub readFile
{

View File

@ -1,3 +1,3 @@
#!/bin/bash
rm /var/home/jpm/.spool/ssh-agent.sock
rm /var/home/jpm/.local/state/ssh-agent.sock
systemctl poweroff -i

View File

@ -1,3 +1,3 @@
#!/bin/bash
rm /var/home/jpm/.spool/ssh-agent.sock
rm /var/home/jpm/.local/state/ssh-agent.sock
systemctl reboot -i

View File

@ -6,21 +6,21 @@ if [[ $ARG == '' ]]; then
fi
if [[ $ARG == 'toggle' ]]; then
if [[ -e '/home/jpm/.config/waybar/.hidden' ]]; then
rm '/home/jpm/.config/waybar/.hidden';
if [[ -e '/home/jpm/.local/state/.waybar_hidden' ]]; then
rm '/home/jpm/.local/state/.waybar_hidden';
else
touch '/home/jpm/.config/waybar/.hidden';
touch '/home/jpm/.local/state/.waybar_hidden';
fi
elif [[ $ARG == 'hide' ]]; then
if [[ ! -e '/home/jpm/.config/waybar/.hidden' ]]; then
touch '/home/jpm/.config/waybar/.hidden';
if [[ ! -e '/home/jpm/.local/state/.waybar_hidden' ]]; then
touch '/home/jpm/.local/state/.waybar_hidden';
else
echo 'Already hidden. You may need to use the "invert" option if action is reversed';
exit;
fi
elif [[ $ARG == 'show' ]]; then
if [[ -e '/home/jpm/.config/waybar/.hidden' ]]; then
rm '/home/jpm/.config/waybar/.hidden';
if [[ -e '/home/jpm/.local/state/.waybar_hidden' ]]; then
rm '/home/jpm/.local/state/.waybar_hidden';
else
echo 'Already shown. You may need to use the "invert" option if action is reversed';
exit;
@ -29,4 +29,5 @@ elif [[ $ARG != 'invert' ]]; then
echo "Invalid argument";
fi
/home/jpm/scripts/waybar/toggle `pgrep waybar`
BARS=$(pgrep waybar | cut -d ' ' -f 1)
kill -s SIGUSR1 $BARS

View File

@ -48,5 +48,5 @@ else
fi
echo $NOTIFY_ID > /tmp/brightness-notification
echo $BRIGHTNESS > ${HOME}/.spool/last_brightness
echo $BRIGHTNESS > ${HOME}/.local/state/last_brightness
rm $LOCK

View File

@ -1,13 +1,13 @@
#!/bin/bash
if [ "$1" == 'bar' ]; then
if [ ! -e ${HOME}/.spool/apt-upgradeable ]; then
if [ ! -e ${HOME}/.local/state/apt-upgradeable ]; then
sudo apt update >/dev/null 2>/dev/null
COUNT=`apt list --upgradable 2> /dev/null | wc -l`
let COUNT--
echo $COUNT > /home/jpm/.spool/apt-upgradeable
echo $COUNT > /home/jpm/.local/state/apt-upgradeable
else
COUNT=`cat ${HOME}/.spool/apt-upgradeable`
COUNT=`cat ${HOME}/.local/state/apt-upgradeable`
fi
if [ $COUNT -eq 0 ]; then
echo '{"text": "🗹", "tooltip": "Up-to-date", "class": "up-to-date"}'
@ -22,7 +22,7 @@ elif [ "$1" == 'upgrade' ]; then
/usr/bin/uxterm -e "sudo apt-get update && sudo apt-get full-upgrade -y && sudo apt-get autoremove -y && sudo apt-get clean -y && exit"
COUNT=`apt list --upgradable 2> /dev/null | wc -l`
let COUNT--
echo $COUNT > /home/jpm/.spool/apt-upgradeable
echo $COUNT > /home/jpm/.local/state/apt-upgradeable
if [ -e /var/run/reboot-required ]; then
grep -B1 -A4 upgrade /var/log/apt/history.log | tail -n 6 | swaynag --config=${HOME}/.dotfiles/sway/swaynag --edge=bottom --message="New packages require restart" --button="Restart Now" "sudo systemctl reboot" --dismiss-button="Later" --detailed-message --detailed-button "Show/Hide Upgrade Details"
fi
@ -30,7 +30,7 @@ elif [ "$1" == 'update' ]; then
sudo apt update >/dev/null 2>/dev/null
COUNT=`apt list --upgradable 2> /dev/null | wc -l`
let COUNT--
echo $COUNT > /home/jpm/.spool/apt-upgradeable
echo $COUNT > /home/jpm/.local/state/apt-upgradeable
else
echo "Missing argument: update, upgrade, bar"
fi

View File

@ -11,11 +11,11 @@ function count() {
}
if [ "$1" == 'bar' ]; then
if [ ! -e ${HOME}/.spool/ostree-upgradeable ]; then
if [ ! -e ${HOME}/.local/state/ostree-upgradeable ]; then
count
echo $COUNT > /home/jpm/.spool/ostree-upgradeable
echo $COUNT > /home/jpm/.local/state/ostree-upgradeable
else
COUNT=`cat ${HOME}/.spool/ostree-upgradeable`
COUNT=`cat ${HOME}/.local/state/ostree-upgradeable`
fi
if [ $COUNT -eq 0 ]; then
echo '{"text": "🗹", "tooltip": "Up-to-date", "class": "up-to-date"}'
@ -29,10 +29,10 @@ elif [ $UID -eq 0 ]; then
elif [ "$1" == 'upgrade' ]; then
/usr/bin/uxterm -e "rpm-ostree upgrade"
count
echo $COUNT > /home/jpm/.spool/ostree-upgradeable
echo $COUNT > /home/jpm/.local/state/ostree-upgradeable
elif [ "$1" == 'update' ]; then
count
echo $COUNT > /home/jpm/.spool/ostree-upgradeable
echo $COUNT > /home/jpm/.local/state/ostree-upgradeable
else
echo "Missing argument: update, upgrade, bar"
fi

View File

@ -2,8 +2,8 @@
PID=$(pgrep gammastep)
RUNNING=0
if [ -e $HOME/.spool/gammastep.status ]; then
RUNNING=`cat $HOME/.spool/gammastep.status`
if [ -e $HOME/.local/state/gammastep.status ]; then
RUNNING=`cat $HOME/.local/state/gammastep.status`
fi
ACTION=$1
@ -17,9 +17,9 @@ elif [[ $ACTION == 'toggle' ]]; then
if [ ! -z $PID ]; then
kill -SIGUSR1 $PID
if [[ $RUNNING == 0 ]]; then
echo 1 > $HOME/.spool/gammastep.status
echo 1 > $HOME/.local/state/gammastep.status
else
echo 0 > $HOME/.spool/gammastep.status
echo 0 > $HOME/.local/state/gammastep.status
fi
else
echo 'Gammastep is not running'
@ -42,7 +42,7 @@ elif [[ $ACTION == 'enable' ]]; then
echo 'Already enabled'
else
kill -SIGUSR1 $PID
echo 1 > $HOME/.spool/gammastep.status
echo 1 > $HOME/.local/state/gammastep.status
fi
else
echo 'Gammastep is not running'
@ -51,7 +51,7 @@ elif [[ $ACTION == 'disable' ]]; then
if [ ! -z $PID ]; then
if [ $RUNNING ]; then
kill -SIGUSR1 $PID
echo 0 > $HOME/.spool/gammastep.status
echo 0 > $HOME/.local/state/gammastep.status
else
echo 'Already disabled'
fi
@ -63,8 +63,8 @@ else
fi
RUNNING=0
if [ -e $HOME/.spool/gammastep.status ]; then
RUNNING=`cat $HOME/.spool/gammastep.status`
if [ -e $HOME/.local/state/gammastep.status ]; then
RUNNING=`cat $HOME/.local/state/gammastep.status`
fi
if [[ $RUNNING == 0 ]]; then
echo '{"text":"ɣ","icon":"ɣ","tooltip":"Enable Gammastep","class":"disabled"}'

View File

@ -1,6 +1,6 @@
#!/bin/bash
FILE="$HOME/.spool/hibernate_inhibitor"
FILE="$HOME/.local/state/hibernate_inhibitor"
if [ -e $FILE ]; then
INHIBITED=1
else

View File

@ -1,6 +1,6 @@
#!/bin/bash
FILE="$HOME/.spool/idle_mode"
FILE="$HOME/.local/state/idle_mode"
if [[ -z $1 ]] || [[ "$1" == 'rotate' ]] || [[ "$1" == 'bar' ]]; then
if [[ -e $FILE ]]; then
MODE=$(cat $FILE)

View File

@ -1,6 +1,6 @@
#!/bin/bash
FILE=/home/jpm/.spool/onscreen-keyboard
FILE=/home/jpm/.local/state/onscreen-keyboard
if [ -f $FILE ]; then
rm $FILE
busctl call --user sm.puri.OSK0 /sm/puri/OSK0 sm.puri.OSK0 SetVisible b false

View File

@ -8,7 +8,7 @@ if [ -n "$VARIANT" ]; then
fi
# Build log file for upgradeable package counts/errors
COUNT_FILE="$HOME/.spool/upgradeable"
COUNT_FILE="$HOME/.local/state/upgradeable"
if [ -f "/run/.containerenv" ] || [ -f "/.dockerenv" ]; then
COUNT_FILE="$COUNT_FILE.$(echo "$HOSTNAME" | cut -d'.' -f1)"
fi

View File

@ -27,9 +27,9 @@ fi
VOLUME=$(pactl get-sink-volume $SINK | grep Volume | sed -r 's/.* (1?[0-9]?[0-9])% \/.*/\1/')
if [[ $ACTION != "set-sink-volume $SINK +1%" ]] && [[ $VOLUME -eq 0 ]]; then
echo $VOLUME > ${HOME}/.spool/last_volume
echo $VOLUME > ${HOME}/.local/state/last_volume
elif [[ $ACTION != "set-sink-volume $SINK -1%" ]] && [[ $VOLUME -eq 150 ]]; then
echo $VOLUME > ${HOME}/.spool/last_volume
echo $VOLUME > ${HOME}/.local/state/last_volume
elif [[ $ACTION != "get-sink-volume $SINK" ]]; then
pactl $ACTION
VOLUME=$(pactl get-sink-volume $SINK | grep Volume | sed -r 's/.* (1?[0-9]?[0-9])% \/.*/\1/')
@ -53,5 +53,5 @@ fi
VOLUME=$(pactl get-sink-volume $SINK | grep Volume | sed -r 's/.* (1?[0-9]?[0-9])% \/.*/\1/')
echo $NOTIFY_ID > /tmp/volume-notification
echo $VOLUME > ${HOME}/.spool/last_volume
echo $VOLUME > ${HOME}/.local/state/last_volume
rm /tmp/volume-lock