LINUX.ORG.RU

Как обнулить значение бездействия после standby?


0

1
#!/bin/bash
set -x

# Wanted trigger timeout in milliseconds.
IDLE_TIME=$((1*60*1000))

# Sequence to execute when timeout triggers.
trigger_cmd() {
   # echo "Triggered action $(date)"
   systemctl suspend
}

sleep_time=$IDLE_TIME
triggered=false

# ceil() instead of floor()
while true; do
# while sleep $(((sleep_time+999)/1000)); do
   idle=$(xprintidle)
   if [ $idle -ge $IDLE_TIME ]; then
       if ! $triggered; then
           trigger_cmd
           triggered=true
           sleep_time=$IDLE_TIME
       fi
   else
       triggered=false
       # Give 100 ms buffer to avoid frantic loops shortly before triggers.
       # sleep_time=$((IDLE_TIME-idle+100))
   fi
   sleep 1
done

после пробуждения xprintidle тикает дальше

★★★★

а не должна? как по-твоему она работает, поясни.

В исходниках(?) прямо написано

This program prints the "idle time" of the user to stdout.  The "idle
time" is the number of milliseconds since input was received on any
input device.  If unsuccessful, the program prints a message to stderr
and exits with a non-zero exit code.

anonymous ()