diff options
| author | littleblack111 <jerrylam110209@gmail.com> | 2023-07-23 14:38:01 +0800 |
|---|---|---|
| committer | littleblack111 <jerrylam110209@gmail.com> | 2023-07-23 14:38:01 +0800 |
| commit | 80fe88409c8e8837d90a92f2cbcff94d345fb632 (patch) | |
| tree | 65b7659d5426e1f87a3458f923ca0c5e7546e097 /idle.sh | |
| parent | 9b8128a9342500fa4dd43331bd2eb6c8b4ed9b07 (diff) | |
updated
Diffstat (limited to 'idle.sh')
| -rwxr-xr-x | idle.sh | 20 |
1 files changed, 13 insertions, 7 deletions
@@ -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 |
