LinuxQuestions.org
View the Most Wanted LQ Wiki articles.
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 02-01-2011, 04:59 AM   #1
Gachl
LQ Newbie
 
Registered: Jun 2009
Posts: 12

Rep: Reputation: 0
Bash inactivity execute script


Hi!

Recently while tuning my bash and whatnot I thought about a nice (but quite unnecessary) little feature to add.

Basically, it's a screensaver for bash, so after a certain time of inactivity (eg. 2 minutes) on a bash it will automatically run a program on this bash which then shows some kind of ascii screensaver or what (eg. bb for AA, looks nice) and when I CTRL+C the screensaver I'd have to login again (unlock my session). The screensaver and the locking works quite well so far, the only missing part is the 2 minute timeout.

Is there any way to execute a script on a bash after a certain time of inactivity?

Thanks in advance,
Gachl
 
Old 02-01-2011, 07:38 AM   #2
redgoblin
Member
 
Registered: Jun 2005
Location: UK
Distribution: Debian
Posts: 189

Rep: Reputation: 41
You might want to look into GNU Screen. Screen locking is just the tip of iceberg as far as it's customisation is concerned.
 
Old 02-02-2011, 01:28 AM   #3
Gachl
LQ Newbie
 
Registered: Jun 2009
Posts: 12

Original Poster
Rep: Reputation: 0
redgoblin,

I think you might have misunderstood my problem, I'm not looking for a way to lock a session, I need to run a command after a time of inactivity on a bash. As I already started, the locking part works already.

Thanks,
Gachl
 
Old 02-02-2011, 07:41 AM   #4
redgoblin
Member
 
Registered: Jun 2005
Location: UK
Distribution: Debian
Posts: 189

Rep: Reputation: 41
Gachl

GNU Screen jumped to mind as it's locking can be set to happen after a certain amount of idle time. However it's an all in one solution and wouldn't necessarily fit in with what you have already.

There's a BASH environment variable called TMOUT. But all that can do is log you out after the set idle time.

Otherwise, looking around for a possible answer I came across this LQ thread (see third post) which might help. If not then I'm out of ideas but you can at least consider this post a friendly *bump* for your question.

Good luck.

Last edited by redgoblin; 02-02-2011 at 07:42 AM. Reason: forgot the link!
 
1 members found this post helpful.
Old 02-04-2011, 02:11 AM   #5
Gachl
LQ Newbie
 
Registered: Jun 2009
Posts: 12

Original Poster
Rep: Reputation: 0
For the moment this solution is working nice, thanks for the link!

If anyone else has other suggestions please do share.
 
Old 08-15-2013, 04:33 PM   #6
rjwilmsi
Member
 
Registered: Mar 2005
Location: UK
Distribution: opensuse 12.2 x86_64
Posts: 563

Rep: Reputation: 38
Adding a note to an old thread in case this is of use to anybody else:

This post at crunchbang http://crunchbang.org/forums/viewtopic.php?id=26447 details a bash script to determine the time in seconds since the last mouse or keyboard action in the system. It doesn't depend on any X session or user being logged in since it's just looking at hardware interrupts. You could modify the scrip to invoke the screensaver & lock rather than suspending the system.

So for keyword searches: bash script for user idle / inactive time
 
  


Reply

Tags
bash, screensaver, timeout, tuning


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
Bash script to execute on startup niravshah Linux - Newbie 11 09-09-2009 07:16 PM
How to execute bash script in C waqasdaar Programming 7 01-31-2009 06:56 PM
Can't execute Bash script. zbe Linux - Software 4 10-17-2008 08:05 AM
how to execute bash-script from .bashrc mrsvan Linux - General 3 07-21-2008 07:26 AM
remote execute a bash script vmware Linux - Enterprise 3 09-07-2006 03:01 PM


All times are GMT -5. The time now is 11:55 AM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration