From 80fe88409c8e8837d90a92f2cbcff94d345fb632 Mon Sep 17 00:00:00 2001 From: littleblack111 Date: Sun, 23 Jul 2023 14:38:01 +0800 Subject: updated --- idle.sh | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) (limited to 'idle.sh') diff --git a/idle.sh b/idle.sh index c2a5813..138764f 100755 --- a/idle.sh +++ b/idle.sh @@ -2,13 +2,15 @@ mutev=true # stop volume/sound(mute) - comment or un-comment pmusic=true # stop/start music from playing - command or un-comment +IDLETIME=1800000 +IDLEBACKTIME=100 while true; do if [[ "$(systemctl is-system-running)" == "running" || "$(systemctl is-system-running)" == "degraded" ]]; then - if [[ "$(xprintidle)" -gt 600000 && ! -f /var/lock/idle.lock ]]; then # Changed from 600000 (10 minutes) to 3600000 (1 hour) - printf "User is afk in %s\n", "$(date)" - sudo touch /var/lock/idle.lock + if [[ "$(xprintidle)" -gt $IDLETIME && ! -f /tmp/lock/idle.lock ]]; then # Changed from 600000 (10 minutes) to 3600000 (1 hour) + printf "User is idle(afk) in %s\n", "$(date)" + sudo /sbin/touch /tmp/lock/idle.lock #if [ $mutev ]; then # soundlevel=$(awk -F"[][]" '/Left:/ { print $2 }' <(amixer sget Master)) # amixer set Master 0% @@ -27,17 +29,21 @@ while true; do if [ $pmusic ] && [ $m ]; then NekoMC --pause & fi - # killall picom; bspcomp & # paused in freezeapp and unfreezeapp + #killall picom; bspcomp & # paused in freezeapp and unfreezeapp + # Disable mouse just in case accidental awake for high DPI rate mouse + xinput --disable 12 freezeapp & continue - elif [[ "$(xprintidle)" -le 100 && -f /var/lock/idle.lock ]]; then - printf "User is back from afk in %s\n", "$(date)" + elif [[ "$(xprintidle)" -le $IDLEBACKTIME && -f /tmp/lock/idle.lock ]]; then + printf "User is back from idle(afk) in %s\n", "$(date)" #if [ $mutev ] && [ $soundlevel ]; then # amixer set Master $soundlevel # unset $soundlevel #elif [ $mutev ] && [ ! $soundlevel ]; then # notify-send "ERROR: \$soundlevel is not set, unknown sound level..." #fi + # Re-enable mouse + xinput --enable 12 if [ $mutev ] && [[ $(pactl get-sink-mute @DEFAULT_SINK@) == "Mute: yes" ]]; then amixer set Master unmute elif [ $mutev ] && [[ $(pactl get-sink-mute @DEFAULT_SINK@) == "Mute: no" ]]; then @@ -51,7 +57,7 @@ while true; do NekoMC --play & unset m fi - sudo rm -f /var/lock/idle.lock + sudo /sbin/rm -f /tmp/lock/idle.lock continue else sleep 1 -- cgit v1.2.3