LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 06-22-2013, 06:18 AM   #1
Glenn D.
Member
 
Registered: May 2009
Location: ACT - Australia
Distribution: Opensuse x86_64 (Latest)
Posts: 132

Rep: Reputation: 26
Is there away to detect in linux if the keyboard is in use, or mouse is moved.


Hello
Is there away to detect in linux if the keyboard is in use, or mouse is moved, just need to determine if either is being used.
If neither is being is being used say after an hour, initiate a system shutdown.
Thanks Glenn
 
Old 06-22-2013, 06:55 AM   #2
jpollard
Senior Member
 
Registered: Dec 2012
Location: Washington DC area
Distribution: Fedora, CentOS, Slackware
Posts: 4,912

Rep: Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513
Depends on the definition of "used".

That is what the screen lock function does when it locks the display.

The problem is that if the system is being used (watching a video), then neither the keyboard or mouse will be used - and that could cause the system to shutdown.

If the system is being used to compute some long running job (gene mapping/splicing/finite element analysis/animation generation...) then again neither the keyboard and mouse will be used.

Then there is the issue when multiple keyboards and mice are used...
 
Old 06-22-2013, 08:19 AM   #3
archShade
Member
 
Registered: Mar 2006
Location: Delft NL
Distribution: Debian; Slackware; windows 7
Posts: 218

Rep: Reputation: 53
Which desktop enviroment are you running? I beleive both KDE and Gnome have a way built in.

A more generic way (should work for any X windows based system) would be to use xautolock.

running the command when you start your session should do it:
Code:
xautolock -time 60 -locker poweroff
This has all the problems above it is only based on keyboared/mouse activity. So it may cut out if you watching TV or doing somthing that takes more than an hour. Check out the man pages for xautolock for more details. Alternative would be to hibernate or suspend (pm-hibernate or pm-suspend instead of poweroff) it will still break the flow but at least you will be able to resume and not lose work.

You could also just meassage users if this would be an issue, xautolock supports this to.
Code:
xautolock -time 50 -locker "xmessage "system will shutdown in 10 mins unless you do something"" -killtime 10 -killer poweroff
Warning: I can not test this now (I am just reading man pages, so take with a pinch of salt. and please test before actually using it).
 
Old 06-22-2013, 10:03 AM   #4
haertig
Senior Member
 
Registered: Nov 2004
Distribution: Debian, Ubuntu, LinuxMint, Slackware, SysrescueCD, Raspbian, Arch
Posts: 2,331

Rep: Reputation: 357Reputation: 357Reputation: 357Reputation: 357
Maybe hack into your screensaver and put a hook in there to initiate a shutdown script? I don't know the answer to this - but are screensavers that you choose from the GUI configuration actual executables? If so, replace one with your own shutdown executable.
 
Old 06-22-2013, 10:13 AM   #5
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,415
Blog Entries: 55

Rep: Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600
Something with /proc/interrupts?
 
  


Reply



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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
How to detect that the pc is currently used (keyboard/mouse use)? Xeratul Linux - General 2 09-01-2012 02:34 PM
gdm3 fails to start if usb keyboard or usb mouse are moved to different ports sr_25 Debian 2 08-27-2011 05:07 PM
how to detect that no one is using the pc: not mouse, not keyboard after one hour? Xeratul Linux - General 3 01-31-2011 03:46 AM
moved to debian and it does'nt detect the wifi. arik barnes Linux - Wireless Networking 1 02-01-2008 06:56 PM
Morphix Linux Does Not Detect PS2 Mouse dhatcher2 Linux - Laptop and Netbook 4 04-02-2006 06:34 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 05:31 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