Puppy Linux Discussion Forum Forum Index Puppy Linux Discussion Forum
Puppy HOME page : puppylinux.com
"THE" alternative forum : puppylinux.info
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

The time now is Thu 27 Nov 2014, 15:45
All times are UTC - 4
 Forum index » Advanced Topics » Additional Software (PETs, n' stuff) » Unsorted
Alarmclock-CLI v1.1
Moderators: deshlab, Flash, GuestToo, Ian, JohnMurga, Lobster
Post new topic   Reply to topic View previous topic :: View next topic
Page 1 of 2 [24 Posts]   Goto page: 1, 2 Next
Author Message
Pizzasgood


Joined: 04 May 2005
Posts: 6270
Location: Knoxville, TN, USA

PostPosted: Mon 28 Aug 2006, 19:45    Post subject:  Alarmclock-CLI v1.1
Subject description: Can run any app or play audio/video
 

This is a simple alarm clock for the commandline. It can use your media player to play a song when it goes off, or you can set it to run any command you want. It could play a movie, start a text editor, open a website, or delete a file. Basically, it can do whatever you want at the specified time.

alarmclock-CLI-v1.1.pup
alarmclock-CLI-v1.0.pup
alarmclock-CLI-v0.5.pup

Current version is 1.1.

Code:
Usage: alarmclock-CLI [-t HH:MM]|[-H hour -M minute] [-s|-f song/file] [-a app]
                      [-c] [-q --quiet] [-h]

  -h  --help  Show this message
  -t          The time for the alarm to go off, in 24-hour format: HH:MM
  -s  -f      The path to the song or file you want the alarm to use
                   default=/usr/share/audio/error.wav
  -a  --app   The application to run when the alarm goes off
                   default=defaultmediaplayer
  -c          Prompts for a custom command
  -q          Causes the alarm to not run any apps

alternate time format:
  -H          The hour you wish for the alarm to go off (in 24-hour time)
  -M          The minute you wish for the alarm to go off


If you provide no app, song, or command, it will default to defaultmediaplayer and /usr/share/audio/error.wav.

examples:

alarmclock-CLI -t 9:55
alarmclock-CLI -t 4:15 -q
alarmclock-CLI -H 17 -M 30
alarmclock-CLI -t 22:00 -a firefox -f http://www.murga-linux.com/puppy/
alarmclock-CLI -t 14:12 -s /root/JukeBox/SimCity/SC2Ktheme.ogg
alarmclock-CLI -t 12:01 -a mplayer -f /mnt/sda7/cartoons/MegasXLR/xlr-intro.mov
alarmclock-CLI -t 15:27 -c
Please type the command and hit enter:
for i in *; do mv "$i" "${i}.file"; done



Original post for version 0.5

This is an alarm clock that runs in a terminal window. It isn't fancy, just something I whipped togeather in under an hour. You type a command like this:
Code:
alarmclock-CLI -H 18 -M 30 -s /root/music/coolsong.mp3

That will set it to start playing coolsong.mp3 at 18:30 (6:30 PM). Yes, you have to use 24-hour time (millitary time). -H is for hour and -M is for minute. -s is for song, NOT second. (If people want seconds also, I can add them. I don't see a need for it though)
-h will display a help message.
-q will make it not play the music.

It doesn't run in the background (yet) or have a fancy gui (yet) or show a count-down. That's why it's version 0.5. It's half done, but entirely usable. It does say how many seconds it will take before it goes off when you set it, though Very Happy

I will augment this when I get the chance, hopefully adding a gui and maybe multi-day support and stuff. I don't have a lot of time, though, so don't hold your breath. If anyone wants to modify this on their own, go ahead. That's the fun of open-source.

Oh, it installs to /usr/local/bin/ and is named alarmclock-CLI, in case you need to find it. I haven't added any uninstall capabilities yet either (it's only a small textfile anyway).

Enjoy!

Last edited by Pizzasgood on Tue 16 Jan 2007, 00:56; edited 3 times in total
Back to top
View user's profile Send private message Visit poster's website 
Ted Dog


Joined: 13 Sep 2005
Posts: 2474
Location: Heart of Texas

PostPosted: Mon 28 Aug 2006, 21:15    Post subject: Turn on computer cron for atx pwr supply  

http://tcron.sourceforge.net/
If you hook this up you can have the computer turn on at the time needed.
How to build a costly alarm clock
Back to top
View user's profile Send private message 
Nevermore

Joined: 26 Nov 2005
Posts: 365
Location: Italy

PostPosted: Wed 10 Jan 2007, 18:48    Post subject:  

hello
i was trying your script on my 2.11 and i found the following problem (i dunno if is only in my lap)
first of all i must say that i am running a script that syncs the time with a timeserver every 5 mins, because puppy time works strangerly with my laptop (usually is twice faster), then assume is 22 and i want the script to wake me up at 9am next morning:
i enter:
Code:

alarmclock-CLI -H 09 -M 00 -s /mymusic.mp3 or a streamer

the result is pretty odd, since the script tells me that the alarm is in 33 hours and 00 minutes (look is exactly 24+9) however the seconds are shown correct..
the strange thing is that yesterday i set up to wake me at 7am
actually he woke me at 3am instead..
but the time in puppy was correct..
so i wonder it was either some problems with the timeserver (like puppy couldn't synch and ran faster, then after the alarm went on it was able to synch, or there was something else more strange..
i did many times today and the alarm seems fine as long as is IN the same day, if in the next one, problems arise..
now is 23.48here and i am waiting for the alarm at 00.15
if it behave strangerly again i will make you know

_________________
--
/sbin/Nevermore
Back to top
View user's profile Send private message 
Pizzasgood


Joined: 04 May 2005
Posts: 6270
Location: Knoxville, TN, USA

PostPosted: Wed 10 Jan 2007, 19:05    Post subject:  

Well, better early than late I guess Neutral

What it does, is after it calculates the number of seconds, it uses the 'sleep' command to sleep for that long. I don't know how the sleep command works internally. It might decide what time it should be done sleeping and then wakes up (alarm-clock style), but it probably tries to time itself (kitchen-timer style). If it uses the latter, re-sycing the clock might not fix it.

As for the computational errors, I'll look into it. I might try running it overnight too, but I'll have to make sure I won't need to reboot during the interval.

One solution would be to re-write it to enter a while loop and check the system time. It could use shorter sleeps to keep it from eating resources, and calculate how long of a sleep is safe. For example, if it has several hours, it can be every ten minutes. When it gets close, it could speed up. Eventually it would have to calculate the exact amount to sleep and follow it with the wakeup (otherwise it would start running in a full-speed while loop).

Another way is to have it run normally, but double-check the time before doing the wake-up. Then it could go back to sleep. That way wouldn't work with slow clocks though, just fast ones.

_________________
Between depriving a man of one hour from his life and depriving him of his life there exists only a difference of degree. --Muad'Dib

Back to top
View user's profile Send private message Visit poster's website 
MU


Joined: 24 Aug 2005
Posts: 13644
Location: Karlsruhe, Germany

PostPosted: Wed 10 Jan 2007, 19:13    Post subject:  

I think sleep is not very precise.

You might need a routine, that compares the time-values.
see
date --help

Mark
Back to top
View user's profile Send private message Visit poster's website 
Nevermore

Joined: 26 Nov 2005
Posts: 365
Location: Italy

PostPosted: Wed 10 Jan 2007, 19:20    Post subject:  

it is 00.20 and the alarm still doesn't go on..
seems this time is gonna be late..
ok i went now 15 mins late..
considering i put on only 2 hours ago :p

_________________
--
/sbin/Nevermore
Back to top
View user's profile Send private message 
Pizzasgood


Joined: 04 May 2005
Posts: 6270
Location: Knoxville, TN, USA

PostPosted: Wed 10 Jan 2007, 19:32    Post subject:  

The reported time is the time it will go off, not in how long (that's what the seconds are). I neglected to have it subtract 24 when it goes over Rolling Eyes

Hmm.. It also won't let you set it to the same hour as the current one, but several minutes earlier. I'll fix that too.

Well, I guess I'll look into precise-icizing it then. While I'm at it, I'll fix the stupid interface it uses, so you can input times as 18:31 if you like. I wrote the current version very quickly with the intention of returning, then I forgot Rolling Eyes

_________________
Between depriving a man of one hour from his life and depriving him of his life there exists only a difference of degree. --Muad'Dib

Back to top
View user's profile Send private message Visit poster's website 
Nevermore

Joined: 26 Nov 2005
Posts: 365
Location: Italy

PostPosted: Wed 10 Jan 2007, 19:49    Post subject:  

actually pizzas, it works pretty good,
just i changed the mediaplayer line
and opens xmms playing the stream with no problem!
gxins instead NEVER EVER was able to play a stream Very Happy

_________________
--
/sbin/Nevermore
Back to top
View user's profile Send private message 
Pizzasgood


Joined: 04 May 2005
Posts: 6270
Location: Knoxville, TN, USA

PostPosted: Wed 10 Jan 2007, 20:43    Post subject:  

You mean it's accurate now because you used XMMS?

I never realized it before, but if it's set to Gxine or Mplayer, you could also point it to a movie, without having to edit the code. By editing the code, you could easlily set it to run any app with any file or options. I might make the next version have an option to change the command, so you could do it easier.

_________________
Between depriving a man of one hour from his life and depriving him of his life there exists only a difference of degree. --Muad'Dib

Back to top
View user's profile Send private message Visit poster's website 
marksouth2000

Joined: 05 Apr 2006
Posts: 620

PostPosted: Thu 11 Jan 2007, 02:21    Post subject: Re: Alarmclock-CLI v0.5  

Pizzasgood wrote:
Yes, you have to use 24-hour time (millitary time)

The 24-hour clock was originally developed during the 19th century for use by the railways to avoid trains turning up 12 hours late or early. The military were relatively late adopters. Most of the world's railways were using 24 hour time before the military even began using clocks. Most orders were of the form "we attack at dawn" until the 20th century.

I notice MU put the Swiss railway clock into Muppy, BTW. Despite the Swiss association with clocks and precision railway time, the leading manufacturers of railway watches and clocks were mostly American and British during the 19th century.

I guess that I'm trying to say: thanks for this useful utility PG.

Cheers,
Mark Cool
Back to top
View user's profile Send private message 
Nevermore

Joined: 26 Nov 2005
Posts: 365
Location: Italy

PostPosted: Thu 11 Jan 2007, 06:16    Post subject:  

Pizzasgood wrote:
You mean it's accurate now because you used XMMS?

I never realized it before, but if it's set to Gxine or Mplayer, you could also point it to a movie, without having to edit the code. By editing the code, you could easlily set it to run any app with any file or options.


unfortunately no
i just noticed that is either early or late. and that gxine doesn't play streams Very Happy

_________________
--
/sbin/Nevermore
Back to top
View user's profile Send private message 
muggins

Joined: 20 Jan 2006
Posts: 6690
Location: lisbon

PostPosted: Thu 11 Jan 2007, 07:07    Post subject:  

hey pizzasgood,

were you aware of an xmms alarm plugin? see here:

http://freshmeat.net/projects/xmmsalarm/

http://ubuntu.wordpress.com/2006/01/22/how-to-use-your-linux-machine-as-an-alarm/
Back to top
View user's profile Send private message 
Nevermore

Joined: 26 Nov 2005
Posts: 365
Location: Italy

PostPosted: Thu 11 Jan 2007, 08:09    Post subject:  

that would be perfect
however the script does something different, runs something at a defined time
doesn't matter if is another program, a sound, a movie, or whatever..
in any case, if someone could make a .pup of the plugin it would be great!
or i can make under ubuntu?
thanks

_________________
--
/sbin/Nevermore
Back to top
View user's profile Send private message 
Pizzasgood


Joined: 04 May 2005
Posts: 6270
Location: Knoxville, TN, USA

PostPosted: Fri 12 Jan 2007, 12:13    Post subject:  

alarmclock-CLI-v1.0.pup

support for time formatted HH:MM, with the -t option
support for time with -H <hour> -M <minute> format
custom application with -a or --app option
song, file, website, whatever, with the -s or -f option (identical)
don't run an app or make noise: -q (why use -q? Maybe to put it in a script:
Code:
...
alarmclock-CLI -H $hour -M $minute -q
<do other stuff here>
...


If you provide no app or file parameters, it will default to defaultmediaplayer and /usr/share/audio/error.wav.

examples:

alarmclock-CLI -t 9:55
alarmclock-CLI -t 4:15 -q
alarmclock-CLI -H 17 -M 30
alarmclock-CLI -t 22:00 -a firefox -f http://www.murga-linux.com/puppy/
alarmclock-CLI -t 14:12 -s /root/JukeBox/SimCity/SC2Ktheme.ogg
alarmclock-CLI -t 12:01 -a mplayer -f /mnt/sda7/cartoons/MegasXLR/xlr-intro.mov


This version also doesn't sleep for the entire period. Instead, it sleeps for periods of 60 minutes, checking and re-calculating the remaining time each between period. When the remaining time is under 30 minutes, it will shorten the period to every minute. When the time remaining is under a minute, it will sleep for the exact amount, then go off.

Hopefully that will keep it more accurate on system's such as Nevermore's.

To modify the interval times for fine-tuning, they are at line 148 of /usr/local/bin/alarmclock-CLI.

_________________
Between depriving a man of one hour from his life and depriving him of his life there exists only a difference of degree. --Muad'Dib

Back to top
View user's profile Send private message Visit poster's website 
darkerror05


Joined: 17 Jun 2006
Posts: 277
Location: Rochester NY, USA

PostPosted: Mon 15 Jan 2007, 14:47    Post subject:  

nice app works great. But could you add the feature to execute a custom command instead of say just a song? It would e great to use it as also a general automation application. For exaple I want to execute the command "cdplay play 4" when the alarm goes off. Thanks for the great work pizza.
_________________
-darkerror
Back to top
View user's profile Send private message 
Display posts from previous:   Sort by:   
Page 1 of 2 [24 Posts]   Goto page: 1, 2 Next
Post new topic   Reply to topic View previous topic :: View next topic
 Forum index » Advanced Topics » Additional Software (PETs, n' stuff) » Unsorted
Jump to:  

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group
[ Time: 0.0955s ][ Queries: 12 (0.0034s) ][ GZIP on ]