mirror of
https://codeberg.org/andyscott/dotfiles.git
synced 2024-12-22 01:43:10 -05:00
Removed gawk extensions, added test for XDG_STATE_HOME env var
This commit is contained in:
parent
37a45f2075
commit
6ee3946a3d
1 changed files with 12 additions and 10 deletions
|
@ -1,22 +1,24 @@
|
|||
#!/bin/sh
|
||||
|
||||
time=$(date +"%b %d, %Y %T")
|
||||
log_file=$XDG_STATE_HOME/idle.log
|
||||
|
||||
echo "--- $time ---" > "$log_file"
|
||||
if test -n "$XDG_STATE_HOME"; then
|
||||
log_file=$XDG_STATE_HOME/idle.log
|
||||
else
|
||||
log_file=$HOME/.local/state/idle.log
|
||||
fi
|
||||
echo "--- $(date +"%Y-%m-%d %T") ---" > "$log_file"
|
||||
|
||||
# kill process if already running
|
||||
user=$(id -u)
|
||||
pid=$(ps -u "$user" | awk '/\<swayidle\>/ {print $1}')
|
||||
pid=$(ps -o pid,comm -u "$user" | awk '$2=="swayidle" {print $1}')
|
||||
if [ "$pid" != "" ]; then
|
||||
echo "Sending SIGTERM to swayidle." >> "$log_file"
|
||||
echo "Restarting... Sending SIGTERM." >> "$log_file"
|
||||
kill "$pid"
|
||||
sleep 1
|
||||
fi
|
||||
|
||||
pid=$(ps -u "$user" | awk '/\<swayidle\>/ {print $1}')
|
||||
pid=$(ps -o pid,comm -p "$pid" | awk '$2=="swayidle" {print $1}')
|
||||
if [ "$pid" != "" ]; then
|
||||
echo "Sending SIGKILL to swayidle." >> "$log_file"
|
||||
echo "Restarting... Sending SIGKILL." >> "$log_file"
|
||||
kill -9 "$pid"
|
||||
sleep 1
|
||||
fi
|
||||
|
@ -26,12 +28,12 @@ fi
|
|||
brightness="/sys/class/backlight/amdgpu_bl1/brightness"
|
||||
prev_brightness="${XDG_STATE_HOME}/prev_brightness"
|
||||
swayidle -w \
|
||||
timeout 120 "cat $brightness > $prev_brightness && echo 1 > $brightness" \
|
||||
timeout 120 "cat $brightness > $prev_brightness && echo 0 > $brightness" \
|
||||
resume "cat $prev_brightness > $brightness" \
|
||||
timeout 300 'waylock-launcher' \
|
||||
resume "cat $prev_brightness > $brightness" \
|
||||
timeout 900 "cat $prev_brightness > $brightness && wlr-randr --output eDP-1 --off" \
|
||||
resume "wlr-randr --output eDP-1 --on && kanshictl reload" \
|
||||
resume "wlr-randr --output eDP-1 --on && kanshictl reload" \
|
||||
timeout 3600 "loginctl suspend-then-hibernate" \
|
||||
resume "wlr-randr --output eDP-1 --on && kanshictl reload" \
|
||||
lock "waylock-launcher" \
|
||||
|
|
Loading…
Reference in a new issue