LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 01-30-2011, 03:16 PM   #1
Xeratul
Senior Member
 
Registered: Jun 2006
Location: UNIX
Distribution: FreeBSD
Posts: 2,656

Rep: Reputation: 255Reputation: 255Reputation: 255
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
 
Old 01-30-2011, 03:45 PM   #2
Perceptor
Member
 
Registered: Jul 2007
Location: the Future
Distribution: Slackware
Posts: 128

Rep: Reputation: 64
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

Last edited by Perceptor; 01-30-2011 at 03:50 PM. Reason: Adding script
 
Old 01-30-2011, 08:17 PM   #3
Xeratul
Senior Member
 
Registered: Jun 2006
Location: UNIX
Distribution: FreeBSD
Posts: 2,656

Original Poster
Rep: Reputation: 255Reputation: 255Reputation: 255
Quote:
Originally Posted by Perceptor View Post
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?

Last edited by Xeratul; 01-30-2011 at 08:25 PM.
 
Old 01-31-2011, 03:46 AM   #4
Perceptor
Member
 
Registered: Jul 2007
Location: the Future
Distribution: Slackware
Posts: 128

Rep: Reputation: 64
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.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Cron job issue - every hour works, but specific hour fails lunarleviathan Linux - Newbie 6 11-20-2009 12:19 AM
detect keyboard - no way ninguem_vj Linux - Hardware 3 09-25-2006 12:08 PM
Keyboard stops working after an hour or two cartwright Linux - Newbie 3 11-20-2005 04:08 PM
change clock from 24 hour to 12 hour in suse 9.2/KDE 3.3 jmlumpkin Linux - Newbie 1 01-22-2005 11:45 PM
Need help to detect keyboard sugreer Linux - Hardware 1 07-11-2003 07:51 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 12:43 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration