LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (https://www.linuxquestions.org/questions/linux-general-1/)
-   -   how to detect that no one is using the pc: not mouse, not keyboard after one hour? (https://www.linuxquestions.org/questions/linux-general-1/how-to-detect-that-no-one-is-using-the-pc-not-mouse-not-keyboard-after-one-hour-859608/)

Xeratul 01-30-2011 03:16 PM

how to detect that no one is using the pc: not mouse, not keyboard after one hour?
 
Hello,

I would like to detect that with openbox (i avoid xscreensaver) and do manually xset dpms off for the screen.

So, anyone would please know that?


Thank you in advance!
Cheers

Perceptor 01-30-2011 03:45 PM

Check out xprintidle.

This is the script I use to activate my screensaver after 5 minutes of inactivity - added as a cron job.
Code:

#!/bin/bash
DISPLAY=:0
#check if screensaver is running
shekou="$(/usr/bin/ps -e | grep kscreenlocker)"
#check if I'm watching video
velo="$(/usr/bin/ps -e | grep vlc)"
#check the idle time
prii="$(/usr/bin/xprintidle)"
#if vlc or screensaver is running, do nothing
if [ -n "$shekou" -o -n "$velo" ]; then
exit 0
else
        if [ "$prii" -gt 300000 ];
        then
        /usr/bin/nice -n 19 /usr/lib/kde4/libexec/kscreenlocker
        fi
fi


Xeratul 01-30-2011 08:17 PM

Quote:

Originally Posted by Perceptor (Post 4242683)
Check out xprintidle.

This is the script I use to activate my screensaver after 5 minutes of inactivity - added as a cron job.
Code:

#!/bin/bash
DISPLAY=:0
#check if screensaver is running
shekou="$(/usr/bin/ps -e | grep kscreenlocker)"
#check if I'm watching video
velo="$(/usr/bin/ps -e | grep vlc)"
#check the idle time
prii="$(/usr/bin/xprintidle)"
#if vlc or screensaver is running, do nothing
if [ -n "$shekou" -o -n "$velo" ]; then
exit 0
else
        if [ "$prii" -gt 300000 ];
        then
        /usr/bin/nice -n 19 /usr/lib/kde4/libexec/kscreenlocker
        fi
fi


thank you. Cool. And it is a ligth application :)

btw


Quote:

ps aux | grep vlc | grep -v grep
ps aux | grep kscreenlock | grep -v grep
isnt better?

Perceptor 01-31-2011 03:46 AM

Glad to help a fellow Openbox user. :)
As for the process checking, the fastest way is
Code:

pgrep <processname>
but since I wrote this script a long time ago, I didn't bother to tweak it.


All times are GMT -5. The time now is 12:29 PM.