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 #!/bin/sh
# distrobox_binary # distrobox_binary
# name: debian # 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 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 " 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; my $pid = fork;
unless ($pid) { unless ($pid) {
open(my $fh, ">", $ENV{HOME}."/.spool/gammastep.pid"); open(my $fh, ">", $ENV{HOME}."/.local/state/gammastep.pid");
print $fh $$; print $fh $$;
close($fh); close($fh);
open($fh, ">", $ENV{HOME}."/.spool/gammastep.status"); open($fh, ">", $ENV{HOME}."/.local/state/gammastep.status");
print $fh 1; print $fh 1;
close($fh); close($fh);

View File

@ -1,17 +1,17 @@
#!/bin/bash #!/bin/bash
if [ -e "${HOME}/.spool/ssh-agent.sock" ]; then if [ -e "${HOME}/.local/state/ssh-agent.sock" ]; then
PID=$(tail -n 1 "${HOME}/.spool/ssh-agent.env" | sed 's/echo Agent pid \([0-9]*\);/\1/') PID=$(tail -n 1 "${HOME}/.local/state/ssh-agent.env" | sed 's/echo Agent pid \([0-9]*\);/\1/')
if [ -z "$PID" ]; then 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 pkill ssh-agent
else else
CMD=$(ps -p "$PID" -o comm | tail -n 1) CMD=$(ps -p "$PID" -o comm | tail -n 1)
if [ -n "$CMD" ] && [ "$CMD" == 'ssh-agent' ]; then 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 exit
fi fi
fi 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) # "width": __WIDTH__ (optional)
my $waybar_template = "$ENV{'HOME'}/.dotfiles/waybar/config.template"; 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 # Path to actual config file generated from template
my $waybar_config = "$ENV{'HOME'}/.dotfiles/waybar/config"; 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"; my $waybar_bin = "/usr/bin/waybar";
# File to log and recover last used layout name # 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 # 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 # 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; my @wallpapers;
######################################################################## ########################################################################

View File

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

View File

@ -1,8 +1,8 @@
#!/bin/bash #!/bin/bash
rm $HOME/.swaylog 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 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_PLATFORM="wayland-egl;wayland;xcb"
export QT_QPA_PLATFORMTHEME=qt5ct export QT_QPA_PLATFORMTHEME=qt5ct
export QML_IMPORT_PATH="/usr/lib/qt/qml" export QML_IMPORT_PATH="/usr/lib/qt/qml"

View File

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

View File

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

View File

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

View File

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

View File

@ -5,7 +5,7 @@ use warnings;
our $maxfile = "/sys/class/leds/tpacpi\:\:kbd_backlight/max_brightness"; our $maxfile = "/sys/class/leds/tpacpi\:\:kbd_backlight/max_brightness";
our $current = "/sys/class/leds/tpacpi\:\:kbd_backlight/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 sub readFile
{ {

View File

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

View File

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

View File

@ -6,21 +6,21 @@ if [[ $ARG == '' ]]; then
fi fi
if [[ $ARG == 'toggle' ]]; then if [[ $ARG == 'toggle' ]]; then
if [[ -e '/home/jpm/.config/waybar/.hidden' ]]; then if [[ -e '/home/jpm/.local/state/.waybar_hidden' ]]; then
rm '/home/jpm/.config/waybar/.hidden'; rm '/home/jpm/.local/state/.waybar_hidden';
else else
touch '/home/jpm/.config/waybar/.hidden'; touch '/home/jpm/.local/state/.waybar_hidden';
fi fi
elif [[ $ARG == 'hide' ]]; then elif [[ $ARG == 'hide' ]]; then
if [[ ! -e '/home/jpm/.config/waybar/.hidden' ]]; then if [[ ! -e '/home/jpm/.local/state/.waybar_hidden' ]]; then
touch '/home/jpm/.config/waybar/.hidden'; touch '/home/jpm/.local/state/.waybar_hidden';
else else
echo 'Already hidden. You may need to use the "invert" option if action is reversed'; echo 'Already hidden. You may need to use the "invert" option if action is reversed';
exit; exit;
fi fi
elif [[ $ARG == 'show' ]]; then elif [[ $ARG == 'show' ]]; then
if [[ -e '/home/jpm/.config/waybar/.hidden' ]]; then if [[ -e '/home/jpm/.local/state/.waybar_hidden' ]]; then
rm '/home/jpm/.config/waybar/.hidden'; rm '/home/jpm/.local/state/.waybar_hidden';
else else
echo 'Already shown. You may need to use the "invert" option if action is reversed'; echo 'Already shown. You may need to use the "invert" option if action is reversed';
exit; exit;
@ -29,4 +29,5 @@ elif [[ $ARG != 'invert' ]]; then
echo "Invalid argument"; echo "Invalid argument";
fi 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 fi
echo $NOTIFY_ID > /tmp/brightness-notification echo $NOTIFY_ID > /tmp/brightness-notification
echo $BRIGHTNESS > ${HOME}/.spool/last_brightness echo $BRIGHTNESS > ${HOME}/.local/state/last_brightness
rm $LOCK rm $LOCK

View File

@ -1,13 +1,13 @@
#!/bin/bash #!/bin/bash
if [ "$1" == 'bar' ]; then 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 sudo apt update >/dev/null 2>/dev/null
COUNT=`apt list --upgradable 2> /dev/null | wc -l` COUNT=`apt list --upgradable 2> /dev/null | wc -l`
let COUNT-- let COUNT--
echo $COUNT > /home/jpm/.spool/apt-upgradeable echo $COUNT > /home/jpm/.local/state/apt-upgradeable
else else
COUNT=`cat ${HOME}/.spool/apt-upgradeable` COUNT=`cat ${HOME}/.local/state/apt-upgradeable`
fi fi
if [ $COUNT -eq 0 ]; then if [ $COUNT -eq 0 ]; then
echo '{"text": "🗹", "tooltip": "Up-to-date", "class": "up-to-date"}' 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" /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` COUNT=`apt list --upgradable 2> /dev/null | wc -l`
let COUNT-- let COUNT--
echo $COUNT > /home/jpm/.spool/apt-upgradeable echo $COUNT > /home/jpm/.local/state/apt-upgradeable
if [ -e /var/run/reboot-required ]; then 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" 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 fi
@ -30,7 +30,7 @@ elif [ "$1" == 'update' ]; then
sudo apt update >/dev/null 2>/dev/null sudo apt update >/dev/null 2>/dev/null
COUNT=`apt list --upgradable 2> /dev/null | wc -l` COUNT=`apt list --upgradable 2> /dev/null | wc -l`
let COUNT-- let COUNT--
echo $COUNT > /home/jpm/.spool/apt-upgradeable echo $COUNT > /home/jpm/.local/state/apt-upgradeable
else else
echo "Missing argument: update, upgrade, bar" echo "Missing argument: update, upgrade, bar"
fi fi

View File

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

View File

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

View File

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

View File

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

View File

@ -1,6 +1,6 @@
#!/bin/bash #!/bin/bash
FILE=/home/jpm/.spool/onscreen-keyboard FILE=/home/jpm/.local/state/onscreen-keyboard
if [ -f $FILE ]; then if [ -f $FILE ]; then
rm $FILE rm $FILE
busctl call --user sm.puri.OSK0 /sm/puri/OSK0 sm.puri.OSK0 SetVisible b false 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 fi
# Build log file for upgradeable package counts/errors # 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 if [ -f "/run/.containerenv" ] || [ -f "/.dockerenv" ]; then
COUNT_FILE="$COUNT_FILE.$(echo "$HOSTNAME" | cut -d'.' -f1)" COUNT_FILE="$COUNT_FILE.$(echo "$HOSTNAME" | cut -d'.' -f1)"
fi 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/') 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 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 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 elif [[ $ACTION != "get-sink-volume $SINK" ]]; then
pactl $ACTION pactl $ACTION
VOLUME=$(pactl get-sink-volume $SINK | grep Volume | sed -r 's/.* (1?[0-9]?[0-9])% \/.*/\1/') 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/') VOLUME=$(pactl get-sink-volume $SINK | grep Volume | sed -r 's/.* (1?[0-9]?[0-9])% \/.*/\1/')
echo $NOTIFY_ID > /tmp/volume-notification echo $NOTIFY_ID > /tmp/volume-notification
echo $VOLUME > ${HOME}/.spool/last_volume echo $VOLUME > ${HOME}/.local/state/last_volume
rm /tmp/volume-lock rm /tmp/volume-lock