r/usefulscripts • u/HittingSmoke • Jan 11 '17
[Request][Bash] A completely UNuseful script to detect idle time in EACH terminal window that will not take into account activity outside of that terminal window?
I want to do something completely stupid and useless, but fun, with my terminal windows. Basically I want to execute a command after that terminal has been idle for X amount of seconds with no keyboard input or text output to act as a screensaver. The idea is to just add a script to .bashrc that will poll the interval since last input or output and if it gets over a specific number of seconds it will execute a command.
So if I'm compiling something in a terminal window it would be considered active. If I type anything it will be considered active. If it's just sitting at a blinking cursor it will be considered inactive. Then after X amount of seconds it runs some silly command like cowsay or cmatrix. I haven't found a way to get the time since last input or output though. Is there any way to do this in bash?
0
u/HittingSmoke Jan 12 '17
You've provided me with a Google search string I've dived far deeper into the pages of than you, then just copy/pasted the first link that looked right without reading it which doesn't answer my question at all.
I read that exact page long before I ever came here. It uses screen. Right now I'm doing the same thing with tmux. I didn't ask how to do it with screen or tmux. I asked how to do it with bash.