Red HatThis forum is for the discussion of Red Hat Linux.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
anybody knows how to do it? i issue the command to start xmms and i pass a list with songs to it that i want to be played. if i have xmms already open it works fine, the list is loaded and the music is playing. however if i did not have xmms running already this is the response that i get:
With most cron processes, the environment needs to be set, in this case. For example, in
cron.daily, logrotate is a script that contains...
#!/bin/sh
/usr/sbin/logrotate /etc/logrotate.conf
the require environment to execute this is /bin/sh. If you want to spawn xmms, then you will also have to tell it how to connect to X, since this will not be set up. It MIGHT be picked up by creating the script like this....
#!/bin/sh
xmms --playlist (Or whatever syntax you are using).
You will have to leave X running, however, something like this should work...
Script xmmsplay in desired cron directory...
#!/bin/sh
export DISPLAY=localhost:1
xmms --playlist (Or whatever syntax you are using).
R.O.
P.S. The reason it works when already running is because you have the option 'Allow only one instance to run', and it simply connects to the existing process.
as the user, then try again. I don't know why root is not allowed to connect to the X session, which is how cron runs...but these things happen. If it works, then you can add
xhost +
to the end of
/etc/rc.local
file and the command is executed each time X starts as a user.
WOW! it works! ("it's alive! it's alive"). it starts without the playlist or eq but that is really not important. not if i can bug you for a minute more to explain to me what is the command:
xhost + localhost
and is this something i can run every time as a part of my script so that this works all of the time? again, thanks a lot for your help.
No, xhost + is the way the owner of the current X session can block or allow other users to connect to the X session. For example, if I wanted to 'push' a picture to your workstation (PC), then I could
export DISPLAY=YourIP:0
then xv <picture>
You can block or allow this with xhost + <MyIP> or xhost - <MyIP>. That is why I suggested that you put it as the last line in
/etc/rc.local
Then, whomever logs into the PC as any user, xhost + localhost will be executed automatically.
Looking at the options, xmms --help, shows that you can specify
xmms -p and it will start playing the current playlist. The reason it isn't starting the playlist or equilizer is du to it starting as root, and you haven't opened them as root, and then exited. Cron runs as root, you use xmms, normally, as a regular user.
Hey, try this, if you usually log in as a single user other than root, such as 'Steve'
#!/bin/bash
export DISPLAY=:0.0
su - Steve -c '/usr/bin/xmms -p'
Then it will start playing whatever was loaded when you last exited, and you aren't running xmms as root (a VERY small security breach), and you won't need the xhost + at all, case Steve owns the X session.
P.S. localhost is the name from your /etc/hosts that is linked to the IP of your machine. You could just as easily done
xhost + 127.0.0.1
su - username -c 'command to execute'
means that change to user 'username', and execute the command in these quotes. Since root is the one doing the su, no password is required.
one thing:
"Cron runs as root, you use xmms, normally, as a regular user."
while trying to get this working i was logged on as root. (and i had started xmms as root before.) how come root did not have the rights to connect to x session?
Well, like I said, some things just make you go hmmmm? Has to be something with the cron load environment. There is a reason, but I don't know what it is, just how to get around it. So, as regualr user, maybe try logging out and back in, to see if you do need the 'xhost + localhost'. It really can't hurt to add it to your
/etc/rc.local file though, so this kind of thing doesn't happen again.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.