You are not logged in.
Ok, this question may sound weird, so here's some background: I have to work on the computer a lot and I have all sorts of back problems.
Doc said I should stop every 30-40 minutes and stretch and stuff. I have a timer running but sometimes I lack the discipline to respect my
breaks, so I need a way to force myself to do that (yeah, I know, that's a bit pathetic).
So, to my question. I need a script that completely freezes everything for 5 minutes, every 35 minutes. I'm not sure what the best definition
of "freeze" is; maybe stop receiving input from the mouse or the keyboard*. The requirements are:
1. It is not easy or possible to override while in "freeze mode"
2. It is safe (no danger for losing current work, etc)
3. It does *not* run on startup; I enable it whenever I want
4. If not in "freeze mode", I can disable it anytime I want
If it is possible to also have some kind of countdown timer (time remaining to freeze/unfreeze) somehow, that would be a neat extra feature.
Any ideas? Is something like that possible?
Many thanks in advance.
* Just realized no input from mouse and keyboard is not the perfect "freeze" situation, as this does not help much when I watch youtube or
something.
Last edited by geo909 (2013-12-01 17:20:53)
Offline
It lacks the visible timer function, but for similar reasons I used this kind of approach:
#!/bin/bash
while true; do
sleep 35m
chvt 10
kbd_mode -s
sleep 5m
kbd_mode -u
chvt 1
done(Must be run by root.)
When not in freeze mode, you can press Ctrl+C whenever you want to stop it. When in freeze mode you are dropped to an unused VT with no keyboard.
A sidenote for the countdown timer feature: are you sure that if you know the next freezing to come in say 5 seconds, will you be able to stand the temptation to stop the script? ![]()
“First principle, Clarice. Simplicity” – Dr. Hannibal Lecter
Offline
It lacks the visible timer function, but for similar reasons I used this kind of approach:
#!/bin/bash while true; do sleep 35m chvt 10 kbd_mode -s sleep 5m kbd_mode -u chvt 1 done(Must be run by root.)
When not in freeze mode, you can press Ctrl+C whenever you want to stop it. When in freeze mode you are dropped to an unused VT with no keyboard.
Great, thanks! I'll read a bit about those commands, but a quick one:
I assume it takes you back to the VT you were currently using, so you don't need any manual intervention to go back, right?
And another question:
If sounds are played (youtube or music player), is this going to continue playing the sounds without me being able to stop,
or the sounds are going to be stoped as well?
Btw I would try it myself but I'm in the middle of work right now, with many open windows in specific places, etc.
A sidenote for the countdown timer feature: are you sure that if you know the next freezing to come in say 5 seconds, will you be able to stand the temptation to stop the script?
Didn't think about that! Yeah, that's a good idea to skip the timer for the 35 minutes.
Offline
Yes, “chvt 1” takes you back to the 1st VT, which is probably the one you were using before freezing (as far as I know X launches from there by default since the transition to systemd) but you may need some tuning.
No, sound is not stopped. You may add some further lines to the script to achieve this goal:
killall -SIGSTOP plugin-container
killall -SIGSTOP mplayer
…to freeze processes related to sound, and
killall -SIGCONT plugin-container
killall -SIGCONT mplayer
…to thaw them.
Or as an alternative you might SIGSTOP and SIGCONT X itself. But in this case the script MUST be run outside of X.
EDIT: by syslinux I actually meant systemd…
Last edited by barto (2013-12-02 21:18:23)
“First principle, Clarice. Simplicity” – Dr. Hannibal Lecter
Offline
You're the best, thank you!:)
Offline