LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
Search this Thread
Old 06-30-2006, 10:04 AM   #1
chobin
LQ Newbie
 
Registered: May 2006
Location: Italy
Distribution: Fedora Core 4 - Suse 10.0
Posts: 24

Rep: Reputation: 15
launching amarok player from cron


Hi everybody,
Is it possible to launch amarok player from a cron job?
I have a script that, after a certain condition, loads amarok player.
If I use the script from terminal it works well, but if I put it in a cron job, amarok doesn't work.
Thanks in advance
 
Old 06-30-2006, 10:41 AM   #2
taylor_venable
Member
 
Registered: Jun 2005
Location: Indiana, USA
Distribution: OpenBSD, Ubuntu
Posts: 892

Rep: Reputation: 41
IIRC cron will email the user when a task has failed by exiting with a non-zero value. I recommend the following: after you try to launch amarok from your script, save the value of $? to some other variable. (The $? variable is the exit value of the last-executed statement.) Then at the end of the script, finish by calling "exit" with the parameter that is the exit value of amarok. In that way you should be emailed by cron when amarok fails to exit cleanly after being launched by your script. Even better, if possible, would be to have your script exec to amarok rather than simply invoking it as a command.

If I could hazard a guess as to what is wrong, it would be that your environment information isn't available to the script that cron starts. It may likely be that amarok can't connect to the X server; check the values of DISPLAY and XAUTHORITY in your script prior to launching amarok.
 
Old 06-30-2006, 10:46 AM   #3
xpromisex
Member
 
Registered: Apr 2004
Location: Statesboro, GA
Distribution: Arch Linux 2007.05 "Duke" (Kernel 2.6.21)
Posts: 447

Rep: Reputation: 30
You can run amarok from cron. It will start playing automatically if you attach the -p switch. If you want amarok to run at one minute past the hour, every hour:
Code:
01 * * * * amarok -p
12 noon every day:
Code:
00 12 * * * amarok -p
I'm not sure how to run the script correctly though...

EDIT: just fixed a mistype

Last edited by xpromisex; 06-30-2006 at 10:47 AM.
 
Old 06-30-2006, 11:02 AM   #4
chobin
LQ Newbie
 
Registered: May 2006
Location: Italy
Distribution: Fedora Core 4 - Suse 10.0
Posts: 24

Original Poster
Rep: Reputation: 15
Quote:
Originally Posted by taylor_venable
IIRC cron will email the user when a task has failed by exiting with a non-zero value. I recommend the following: after you try to launch amarok from your script, save the value of $? to some other variable. (The $? variable is the exit value of the last-executed statement.) Then at the end of the script, finish by calling "exit" with the parameter that is the exit value of amarok. In that way you should be emailed by cron when amarok fails to exit cleanly after being launched by your script. Even better, if possible, would be to have your script exec to amarok rather than simply invoking it as a command.

If I could hazard a guess as to what is wrong, it would be that your environment information isn't available to the script that cron starts. It may likely be that amarok can't connect to the X server; check the values of DISPLAY and XAUTHORITY in your script prior to launching amarok.
Yes, I think the problem is the connection to X server as you say, but how can I check these values in my script?
 
Old 06-30-2006, 01:55 PM   #5
taylor_venable
Member
 
Registered: Jun 2005
Location: Indiana, USA
Distribution: OpenBSD, Ubuntu
Posts: 892

Rep: Reputation: 41
How about echo'ing the value of the variables to a file; 'echo "[ $DISPLAY ]" > /home/username/some-scrap-file'. If the file shows up with just empty brackets, then X server connection is most likely where the problem is.
 
Old 06-30-2006, 04:13 PM   #6
chobin
LQ Newbie
 
Registered: May 2006
Location: Italy
Distribution: Fedora Core 4 - Suse 10.0
Posts: 24

Original Poster
Rep: Reputation: 15
Quote:
Originally Posted by taylor_venable
How about echo'ing the value of the variables to a file; 'echo "[ $DISPLAY ]" > /home/username/some-scrap-file'. If the file shows up with just empty brackets, then X server connection is most likely where the problem is.
ok, I'll try, but if the problem is x server, have you got any suggestion to solve it?
Is there a way to use amarok without graphic interface?
 
Old 06-30-2006, 04:42 PM   #7
xpromisex
Member
 
Registered: Apr 2004
Location: Statesboro, GA
Distribution: Arch Linux 2007.05 "Duke" (Kernel 2.6.21)
Posts: 447

Rep: Reputation: 30
if you want to use something without a graphical interface, you can check out xmms2 and mpd. As far as I know, Amarok does not have a CLI mode, but xmms and mpd are rather easy to set up and can be used both in CLI and GUI modes. (xmms2 is however, beta software - but just about everything is working pretty well)
 
Old 06-30-2006, 06:08 PM   #8
taylor_venable
Member
 
Registered: Jun 2005
Location: Indiana, USA
Distribution: OpenBSD, Ubuntu
Posts: 892

Rep: Reputation: 41
Quote:
Originally Posted by chobin
ok, I'll try, but if the problem is x server, have you got any suggestion to solve it?
Ah, there's the rub. Unfortunately, no; hopefully somebody else will be more wise than me in this regard. xpromisex has a good workaround suggestion, though. Also, most multimedia files have specific command-line players, for example mpg123 for MP3 files and ogg123 for OGG Vorbis files.
 
Old 07-03-2006, 05:10 AM   #9
chobin
LQ Newbie
 
Registered: May 2006
Location: Italy
Distribution: Fedora Core 4 - Suse 10.0
Posts: 24

Original Poster
Rep: Reputation: 15
Quote:
Originally Posted by xpromisex
if you want to use something without a graphical interface, you can check out xmms2 and mpd. As far as I know, Amarok does not have a CLI mode, but xmms and mpd are rather easy to set up and can be used both in CLI and GUI modes. (xmms2 is however, beta software - but just about everything is working pretty well)
Ok, xpromisex suggestion was right!!!
I installed xmms and used it in my script instead of amarok and it works well when launched from cron job.
Thanks very much to everybody, your help is always precious
 
Old 07-04-2006, 07:19 AM   #10
aluser
Member
 
Registered: Mar 2004
Location: Massachusetts
Distribution: Debian
Posts: 557

Rep: Reputation: 42
use "DISPLAY=:0 amarok -p" in your cron script instead of "amarok -p" and it should work fine
 
  


Reply


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 Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Questions about Cron, Microphones, Networking and Amarok with Gstreamer roastedmnm Suse/Novell 2 02-17-2006 10:02 PM
Trying to install amarok media player waelaltaqi Linux - Software 1 12-10-2005 11:45 AM
amaroK Music Player canuck_barlow Linux - Newbie 7 11-29-2005 11:52 PM
AmaroK - drag and drop to MP3 player (how?) aysiu Linux - Software 0 08-20-2005 01:38 PM
launching xmms with cron djidji Red Hat 12 01-15-2004 09:09 PM


All times are GMT -5. The time now is 09:18 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