0

I'm using Linux Mint, and I run the below service with system start up to0 take automatically screenshots, but I need it to stop taking screenshots if the computer is idle, and run again when it is active(for example, the mouse is moved). How can this be accomplished?

while true; do
  scrot -d 70 '%Y-%m-%d-%H:%M:%S.jpg' -e 'mv $f 
~/TMP/TempScreenShots'
done

closed as unclear what you're asking by Kusalananda, jimmij, msp9011, Anthony Geoghegan, Mr Shunz Mar 25 at 15:52

Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

2

Use xprintidle:

xprintidle is a utility that queries the X server for the user's idle time and prints it to stdout (in milliseconds).

while :; do
    [ $(xprintidle) -lt 10000 ] && echo do_something
    sleep 3;
done

This will echo do_something every 3 seconds if last keyboard or mouse activity was less than 10 seconds ago.


You might need to install it, e.g.:

sudo apt install xprintidle

or build it yourself from source.

  • should i replace do_something with my service ? sorry because i'm new in Linux – MoSalah Mar 25 at 16:48
  • Put your command after && – pLumo Mar 25 at 17:10

Not the answer you're looking for? Browse other questions tagged or ask your own question.