You are not logged in.

#1 2010-07-22 23:37:27

Basu
Member
From: Cornell University
Registered: 2006-12-15
Posts: 296
Website

Setting off a beep every 20 minutes

I read somewhere that a good way to keep your eyes from hurting staring at a screen is to look away every 20 minutes. What's a cheap way to have my Arch box set off beep or two every 20 minutes? A friend of mine suggested running a shell loop that sleeps for 20 minutes and does something, question is: what? Man pages show a beep system call but I don't want to write a C program if i can get away with a script. Any ideas?


The Bytebaker -- Computer science is not a science and it's not about computers
Check out my open source software at Github

Offline

#2 2010-07-22 23:42:47

Inxsible
Forum Fellow
From: Chicago
Registered: 2008-06-09
Posts: 9,183

Re: Setting off a beep every 20 minutes

These might be of interest :

http://eyedeal.team88.org/node/86

http://www.workrave.org/


and best of all its in [community]

Last edited by Inxsible (2010-07-22 23:45:02)


Forum Rules

There's no such thing as a stupid question, but there sure are a lot of inquisitive idiots !

Offline

#3 2010-07-23 00:06:38

karol
Archivist
Registered: 2009-05-06
Posts: 25,440

Re: Setting off a beep every 20 minutes

> a shell loop that sleeps for 20 minutes and does something, question is: what?
I have the answer:

[karol@black ~]$ type beep
beep is aliased to `speaker-test -t sine -f 1000 -l 2 2>&1'

big_smile Don't play it too loud in the middle of the night.

Offline

#4 2010-07-23 00:30:38

Bushman
Member
Registered: 2010-05-27
Posts: 32

Re: Setting off a beep every 20 minutes

If you can manually set the binary to be world-executable (chmod u+x), you could install a package called "beep," which uses the PC speaker (technically a square wave synth).  If you want to set it off every 20 minutes, you're best off with cron.  For every 20 minutes, the entry in your crontab (insert it via pasting into `crontab -e`) would be as follows:

*/20 * * * * beep -l 500 -r 3

Note that this would do it every 20 minutes regardless of what you are doing at the time; thus, a better alternative would be something like

*/20 * * * * [[ "$BEEPING" == "1" ]] && beep -l 500 -r 3

, where BEEPING is an environmental variable.  Environmental variables are set with the `export` command, like so: `export BEEPING=0`.  You could also make aliases in your .bashrc to turn the beeping on and off, like so:

alias beep_on="export BEEPING=1"
alias beep_off="export BEEPING=0"

Offline

#5 2010-07-23 02:03:07

ataraxia
Member
From: Pittsburgh
Registered: 2007-05-06
Posts: 1,553

Re: Setting off a beep every 20 minutes

Bushman wrote:

Note that this would do it every 20 minutes regardless of what you are doing at the time; thus, a better alternative would be something like

*/20 * * * * [[ "$BEEPING" == "1" ]] && beep -l 500 -r 3

, where BEEPING is an environmental variable.  Environmental variables are set with the `export` command, like so: `export BEEPING=0`.  You could also make aliases in your .bashrc to turn the beeping on and off, like so:

alias beep_on="export BEEPING=1"
alias beep_off="export BEEPING=0"

This will NOT work. Setting a variable in your shell will not affect how it's set in a cron session.

Offline

#6 2010-07-23 06:02:48

fsckd
Forum Fellow
Registered: 2009-06-15
Posts: 4,173

Re: Setting off a beep every 20 minutes

Basu wrote:

I read somewhere that a good way to keep your eyes from hurting staring at a screen is to look away every 20 minutes. What's a cheap way to have my Arch box set off beep or two every 20 minutes? A friend of mine suggested running a shell loop that sleeps for 20 minutes and does something, question is: what? Man pages show a beep system call but I don't want to write a C program if i can get away with a script. Any ideas?

ASCII has a bell character.


aur S & M :: forum rules :: Community Ethos
Resources for Women, POC, LGBT*, and allies

Offline

#7 2010-07-23 06:12:19

karol
Archivist
Registered: 2009-05-06
Posts: 25,440

Re: Setting off a beep every 20 minutes

> ASCII has a bell character.
Do you know how can I enable it but disable the beep readline (?) makes when I remove "too much" characters?

Offline

#8 2010-07-23 08:41:31

fsckd
Forum Fellow
Registered: 2009-06-15
Posts: 4,173

Re: Setting off a beep every 20 minutes


aur S & M :: forum rules :: Community Ethos
Resources for Women, POC, LGBT*, and allies

Offline

#9 2010-07-23 08:47:14

karol
Archivist
Registered: 2009-05-06
Posts: 25,440

Re: Setting off a beep every 20 minutes

Yeah, I know about that, but it seems I can set it only as all or nothing. The world is so cruel ...
Thanks anyway :-)

Back on topic: maybe ejecting the CD/DVD-ROM tray would be a good indication?

Last edited by karol (2010-07-23 08:48:03)

Offline

#10 2010-07-23 08:55:18

fsckd
Forum Fellow
Registered: 2009-06-15
Posts: 4,173

Re: Setting off a beep every 20 minutes

If we're going in that direction, ThinkGeek has USB rocket launchers. OP could script them to fire at his head every 20 minutes. The time spent bandaging the wound and re-attaching the rockets should be plenty enough to rest the eyes. big_smile

edit: np Karol

Last edited by fsckd (2010-07-23 08:56:12)


aur S & M :: forum rules :: Community Ethos
Resources for Women, POC, LGBT*, and allies

Offline

#11 2010-07-23 09:03:40

karol
Archivist
Registered: 2009-05-06
Posts: 25,440

Re: Setting off a beep every 20 minutes

fsckd wrote:

If we're going in that direction, ThinkGeek has USB rocket launchers. OP could script them to fire at his head every 20 minutes. The time spent bandaging the wound and re-attaching the rockets should be plenty enough to rest the eyes. big_smile

edit: np Karol

Basu, do you have a webcam? :-D

There are various tools that will show a message e.g. "You need to take a break (doctor's orders)."
Maybe you can automatically (s)lock your computer every n minutes?

Offline

#12 2010-07-23 09:05:44

knopwob
Member
From: Hannover, Germany
Registered: 2010-01-30
Posts: 239
Website

Re: Setting off a beep every 20 minutes

or maybe

 xset dpms force off

This will turn of your monitor until you move your mouse or press a key.

Last edited by knopwob (2010-07-23 09:06:30)

Offline

#13 2010-07-23 09:15:39

karol
Archivist
Registered: 2009-05-06
Posts: 25,440

Re: Setting off a beep every 20 minutes

knopwob wrote:

or maybe

 xset dpms force off

This will turn of your monitor until you move your mouse or press a key.

Nice idea, but if the user is constantly doing sth it doesn't make much sense.

Offline

#14 2010-07-23 09:17:26

yasen
Member
From: Bulgaria
Registered: 2009-03-05
Posts: 39

Re: Setting off a beep every 20 minutes

Just download a nice sound sample that you like and use it with mplayer or whatever. I prefer a kitchen timer-like 'ding' sound.
Put in a shellscript something like:

while true; mplayer ding.wav && sleep 20m; done > /dev/null

and you're off.

Offline

#15 2010-07-23 09:22:06

karol
Archivist
Registered: 2009-05-06
Posts: 25,440

Re: Setting off a beep every 20 minutes

yasen wrote:

Just download a nice sound sample that you like and use it with mplayer or whatever. I prefer a kitchen timer-like 'ding' sound.
Put in a shellscript something like:

while true; mplayer ding.wav && sleep 20m; done > /dev/null

and you're off.

Either Rickroll or this ;P
I had the latter as an alarm for quite some time.

Offline

#16 2010-07-23 10:10:11

knopwob
Member
From: Hannover, Germany
Registered: 2010-01-30
Posts: 239
Website

Re: Setting off a beep every 20 minutes

karol wrote:
knopwob wrote:

or maybe

 xset dpms force off

This will turn of your monitor until you move your mouse or press a key.

Nice idea, but if the user is constantly doing sth it doesn't make much sense.

good point. here's another idea if libnotify is installed:

 notify-send "There's someone behind you"

edit:
or to get annoyed as hell

 shutdown -h now

tongue

Last edited by knopwob (2010-07-23 10:14:51)

Offline

#17 2010-07-23 14:16:25

Basu
Member
From: Cornell University
Registered: 2006-12-15
Posts: 296
Website

Re: Setting off a beep every 20 minutes

@Inxsible: workrave looks good, but there a bunch of Gnome dependencies which are fine when I"m actually in Gnome, but I'd rather not pull up something like that when I'm in Xmonad.

@ataraxia Can you recommend how I could get something that works the same way? Without turning cron on and off?

I think turning off my monitor or shutting down entirely is a bit overkill. But thanks for all the suggestions


The Bytebaker -- Computer science is not a science and it's not about computers
Check out my open source software at Github

Offline

#18 2010-07-23 14:42:15

ataraxia
Member
From: Pittsburgh
Registered: 2007-05-06
Posts: 1,553

Re: Setting off a beep every 20 minutes

Basu wrote:

@ataraxia Can you recommend how I could get something that works the same way? Without turning cron on and off?

You could use a file:

*/20 * * * * [[ -f "/tmp/beeping" ]] && beep -l 500 -r 3
alias beep_on="/bin/touch /tmp/beeping"
alias beep_off="/bin/rm -f /tmp/beeping"

Offline

#19 2010-07-23 14:45:09

Intrepid
Member
Registered: 2008-06-11
Posts: 254

Re: Setting off a beep every 20 minutes

Use yasen's script with karol's speaker-test beep code, and just have it run at startup.  Put it in /etc/rc.local to start it at startup.


Intrepid (adj.): Resolutely courageous; fearless.

Offline

#20 2010-07-23 17:43:04

Anikom15
Banned
From: United States
Registered: 2009-04-30
Posts: 836
Website

Re: Setting off a beep every 20 minutes

Python script:

#!/usr/bin/env python

while True:
    time.sleep(1200)
    print('\a')

It's heavier but it works well. PC speaker needs to be enabled of course.


Personally, I'd rather be back in Hobbiton.

Offline

#21 2010-07-23 18:40:07

Intrepid
Member
Registered: 2008-06-11
Posts: 254

Re: Setting off a beep every 20 minutes

Right, Anikom's script is also very good.  Use one of these scripts and rc.local, and you won't have to start it up or worry about Cron jobs.


Intrepid (adj.): Resolutely courageous; fearless.

Offline

Board footer

Powered by FluxBB