LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 04-07-2009, 04:59 PM   #1
linus72
LQ Guru
 
Registered: Jan 2009
Location: Gordonsville-AKA Mayberry-Virginia
Distribution: Slack14.2/Many
Posts: 5,573

Rep: Reputation: 470Reputation: 470Reputation: 470Reputation: 470Reputation: 470
How to autostart a bash script when DSL loads the Desktop??


Exactly-what is the procedure for autostarting a script/app when X starts-in DSL or most distro's??
 
Old 04-07-2009, 05:01 PM   #2
MasterC
LQ Guru
 
Registered: Mar 2002
Location: Salt Lake City, UT - USA
Distribution: Gentoo ; LFS ; Kubuntu ; CentOS ; Raspbian
Posts: 12,613

Rep: Reputation: 69
Typically if you are just looking to have it start with a particular user:

Edit the .xinitrc file, but this depends on how you start X. If you use a graphical login manager (KDM or GDM for example) then you will want to edit .xsession (typically, depends on the distro).

In the .xinitrc file if you wanted to start, for example, xterm in a fluxbox wm:
/usr/bin/xterm &
exec /usr/bin/fluxbox

Would suffice.

-Chad
 
Old 04-07-2009, 05:17 PM   #3
linus72
LQ Guru
 
Registered: Jan 2009
Location: Gordonsville-AKA Mayberry-Virginia
Distribution: Slack14.2/Many
Posts: 5,573

Original Poster
Rep: Reputation: 470Reputation: 470Reputation: 470Reputation: 470Reputation: 470
OK-now how would I auto-invoke a bash script when the dsl desktop appears?
Basically I want to autostart whatever app, autostart a sound/tune that plays for a few seconds when the Desktop opens(as in Ubuntu,etc), and autostart a bash script when the desktop loads
Is all that possible in DSL?
Thank you
OH the script will be in the root directory of a remastered cd-so how do i auto-start/invoke the script when the dsl desktop loads??

Last edited by linus72; 04-07-2009 at 05:19 PM.
 
Old 04-07-2009, 05:30 PM   #4
MasterC
LQ Guru
 
Registered: Mar 2002
Location: Salt Lake City, UT - USA
Distribution: Gentoo ; LFS ; Kubuntu ; CentOS ; Raspbian
Posts: 12,613

Rep: Reputation: 69
Hmmm, I'm not sure I quite follow how that is any different.

If you place them in order in .xinitrc they will start in that order. If you are saying that it starts your sound too early, you could use a sleep or something like that. Maybe:

sleep 3 ; /usr/bin/mplayer filename.mp3 &
/usr/bin/bash-script.sh &
exec /usr/bin/fluxbox

HTH

-Chad

Afterthought:

If you are going to be calling the script from the CDROM you'll want to probably use something like this instead:

sleep 3 ; /usr/bin/mplayer filename.mp3 &
mount /mnt/cdrom &
sh /mnt/cdrom/start-script.sh &
exec /usr/bin/fluxbox

You will have to ensure your user can mount the cd by editing /etc/fstab and putting in the users option and ensure /mnt/cdrom exists.

Good luck!

-Chad

Last edited by MasterC; 04-07-2009 at 05:33 PM. Reason: CD portion
 
Old 04-07-2009, 05:54 PM   #5
linus72
LQ Guru
 
Registered: Jan 2009
Location: Gordonsville-AKA Mayberry-Virginia
Distribution: Slack14.2/Many
Posts: 5,573

Original Poster
Rep: Reputation: 470Reputation: 470Reputation: 470Reputation: 470Reputation: 470
Your a smart guy MasterC, you and Repo, HTexMex, Alien Bob, and too many others to name...all you guys rock!
BuT...I'm still a Newb bro, dig?
I guessed about part of your answer right as I hit the save reply button....
Now, I don't wanna send you on a long mission-but for backround I'm remastering DSL-embedded and, with Repo "the Reepster"'s (A fellow Cannabi) great help I made a bash script (and fixed the dsl scripts/.bat in embedded) that can execute multiple/infintesimal instances of Qemu playing the actual remastered CD when the script is invoked.
With the script in the "/" root directory of the CD I just open a terminal and enter # cd /mnt/cdrom and then # ./repolator.sh
Then the Qemu's pop up and play DSL with the same Desktop, etc as the live CD your already in-so basically your playing multiple instances of
DSL within the DSL live CD environment. You can also play it out of a folder on your Desktop too.
Anyway-so I want the repolator.sh to autostart when fluxbox starts (or a second after-a delay?) and play a tune, then the tune cuts off after so many seconds, and thats it.
At the below link see the screenshot in reply#92(liveCD-running dsl-linux.sh and 3 qemu's) and the screenshot at reply#94(Qemu playing DSL out of my folder on my Ubuntu Desktop, playing 3 more Qem's inside the virtual environment-Note that this is the Qemu in the dsl-embedded folder I fixed-
So, if that helps....or see reply#94 of my post here-
( http://www.linuxquestions.org/questi...322/page7.html )
 
Old 04-08-2009, 01:12 PM   #6
MasterC
LQ Guru
 
Registered: Mar 2002
Location: Salt Lake City, UT - USA
Distribution: Gentoo ; LFS ; Kubuntu ; CentOS ; Raspbian
Posts: 12,613

Rep: Reputation: 69
So I am not exactly sure still, it sounds like you want to have your base desktop start, and while that is starting a little medly plays, and then you want to start repolator.sh which in turn boots the disk again in qemu and does the same thing (assumingly over and over until you hit the power button or something?). If so, I would give the above a shot. To recap:

When you start X using startx it looks at your .xinitrc and launches the applications in order. The applications have the ampersand at the end to tell X to move onto the next line whether or not the current line is complete (returns it's status). You typically see the exec line last (and I'm not for sure but I think most people expect that) but it doesn't absolutely have to be your wm in that line, or you can run your wm in an above line and call your script in your exec line; when the script is done though you'll be dropped back to CLI or your gui will restart (depending on your script for launching your gui).

So if you have:
Code:
/usr/bin/fluxbox &
exec sh /mnt/cdrom/repolator.sh
Fluxbox will launch and repolator will be run. When repolator is done, your X session will end (the command will "complete") and restart.

In one of your other threads I read you explain to the user they will have to mount the CD drive. You probably will want to automate that instead so that when exec is called the /mnt/cdrom/repolator.sh will exist. Just throw in the auto line in options since it's basically dependant upon that existing for this to work anyway. If you want to be a little fancier you can use autofs/dbus or something to auto detect the media and mount it; simply change your referenced location in xinitrc if that is the case (something like /media/sdc1).

Good luck! Sounds like fun and a great learning experience!

-Chad

Last edited by MasterC; 04-08-2009 at 01:13 PM.
 
  


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
Shell script adding autostart gnome script Coolrunr Programming 3 01-01-2009 02:23 PM
Bash script to launch a terminal window on another user's desktop Excalibre Linux - Software 7 09-29-2008 02:01 AM
Trigger bash script when screen saver starts of desktop gets locked BinWondrin Programming 4 08-01-2008 03:40 AM
Having problems launching a script from the desktop in DSL lantian2004 Linux - Newbie 1 06-01-2006 05:55 AM
Bash aliases won't autostart? Ollir Mandriva 7 08-22-2004 02:10 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 02:36 AM.

Main Menu
Advertisement
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
Open Source Consulting | Domain Registration