[SOLVED] Need to delay startup of startup application

Ubuntu Mate 15.04 on a Dell Latitude 2100. I have an old netbook setup as a jukebox to play my mp3 collection to my Bose radio in the shop. I have a relatively powerless user account “dj” setup to automatically login when I power up the machine. Using System; Preferences; Personal; Startup applications I have “dj” launch Audacity (the mp3 player) and caja from which I can select the tracks to play. This is working great so of course I decided to “improve” my process and broke things. But that is how I learn…

I have my album collection converted to mp3 files and for my next trick I loaded them onto a 32 GB SD card instead of the hard drive which I had been using. Previously I would launch caja thusly:

caja /data/music 

The music collection is now located on the SD card so I changed the startup command to the new location"

caja /media/dj/SD32/music

However, it seems that the application is launched before the SD card has mounted. I therefor need to delay caja to allow time for the card to mount. I have tried changing the command to:

sleep 30;  caja /media/dj/SD32/music

That does not work. I then tried pointing the startup applications entry to a script:

#!/bin/bash
sleep 30
caja /media/dj/SD32/music &
exit

That does not work either. I am looking for suggestions.

TIA,

Ken

I have a number of applications I open as startup scripts with the sleep command because of precisely the same difficulties you have mentioned and it usually works for me. I have just tried these commands both in a terminal and also as a script, both manually and as an autostart script and they work for me.

This suggests that either the caja path you have put in your command is not right and so it is not opening because it doesn’t actually exist or that you have some kind of problem with permissions. In which case it might help to edit the visudo file to give this user permission to carry out operations without needing to use the sudo password. I should say, this command you are using does not appear to need sudo password. But, I only mention this because it is something I have different to you as I need it to run a script at startup which does require the sudo password. One way to test if the command is requiring the sudo command is to manually run it in a terminal. I am assuming you have done that and it works OK? If you want to know exactly how to edit the visudo file, let me know on here and I will post up instructions. Though, like I said, that’s really just a stab in the dark on my part.

Finally, it could be that your SD card has not mounted, even though you have left a 30 second delay with the sleep command. Thus, it doesn’t matter how long the delay, if it is not yet mounted. With that in mind, have you tried to run the commands manually in a terminal immediately following booting up and PRIOR to actually trying to open the SD card from the the caja graphical user interface via the places menu etc? I mention this because if you try to open an external media using the places menu, it will automatically mount the external media at that point and so it is easy to miss the fact it was not mounted up to that point. The way to test if this is the case is, as I said, to try and load the said external media by trying to open it in caja from a terminal. As far as I am aware, this does not attempt to mount the external media in order to open caja at this location. Thus, if it is not already mounted, you will get a message along the lines of the location does not exist.

If that happens, then your problem would not be your commands, but the fact your SD card is not automatically mounting at boot-up. I have experienced precisely this problem with some of my external drives. I fixed it with something called ARIOS Automount, which automatically mounts all external media without having to touch the fstab file. The version I have found to work with UM 14.04 (which is what I am using) is Arios Automount 1.

You can find it here:

http://sourceforge.net/projects/arios/files/repo/arios-automount-1.0_all.deb/download?use_mirror=kent

You might want to install gdebi first (sudo apt-get install gdebi). this allows for very quick and efficient installation of deb files. Though, the first time you try and install a deb file with gdebi, you will need to right click the deb file and choose “properties” and then “opens with” and choose gdebi as the default program to run it. However, you can still use the software center to run it if you wish. It will just take a bit longer to load it and you may also get a message saying this software is “unknown” etc. If that happens, you can just ignore it and install anyway. The only problem would be if you got a “dependencies not satisfied” message. In which case that might mean arios automount 1 does not run automatically with your version of UM and so you should not try to install it. Or, at least, not immediately. This would still be potentially fixable, But, I wont go into that here unless you report back with it as an issue.

Beyond all of the above, I have run out ideas. Though, I am sure there will be others on here who wont have.

You could removing the & symbol and exit, since this is exiting the parent script and may also kill off the processes attached to them. Usually, caja would already be running and open a new window to the already existing process.


Do you also have the script set to be executable? For security reasons, if it’s not marked with “Allow executing file as program” then the script will not run. Right-click your script, choose “Properties”, and check the mark under the permissions tab.

It may be useful if you elaborate on the “does not work” - does an error appear? Nothing happen at all?

Thanks stevecook172001,

I have done some more experimenting and the fact is, as you state, that the SD card is not mounted. I created a launcher to execute caja and point to the SD card. I booted the PC, waited for a while and clicked the launcher. It barfed on location does not exist or something like that. If I navigate from Places to SD32 it appears to be mounted - actually I suspect that it is being auto-mounted at that instant.

As a further test I dragged some tracks from the SD card to Audacious (I said Audacity in the original post - my error) and started playing. I closed Audacious and rebooted. My autologin user account dj has Audacious as one of its startup applications. I was presented with a whole screen full of cannot find the file errors representing all of the tracks in the playlist. I closed and manually launched Audacious. Same errors. Again, it seems that Audacious trying to access the files is not sufficient to cause the SD card to automount.

If I decide to continue using the SD card I will simply mount it via fstab and be done with it. On the other hand I have room on the internal SSD for all 400+ albums so I have for the moment reverted to the original scheme. The SD card became free from another use and I had decided to give it a try.

Thank lah7,

As stated above the issue seems to be with the SD card not automounting without some sort of kick in the pants. Yes the script was executable. The idea of the & and exit were to start the application, leave it running and close any terminal window which might have been launched.

Again my thanks to you both. I will either leave the music on the SDD or manually mount the SD card in fstab. Just as a learning experience I will build a script to do something so that I can learn how to do a delayed initiation from the startup applications list.

Cheers,

Ken

If it helps, the program Disks in the package gnome-disk-utility can easily write to fstab and mount it at system start up for you.

Screenshot that automatically mounts my Data drive.

Thanks lah7 - I have sort of become used to using sudo vim :slight_smile: A good tip for those who might read this thread and not be experienced with working directly with fstab.

Ken

1 Like

Thanks again for the replies. I am not sure why my original script did not do anything. However, it turned out that I was trying to solve the wrong problem. Still I wanted to prove to myself that I could execute a script at startup and include a delay. I created the following script:

#!/bin/bash

firefox&
sleep 10
xeyes&

exit

When added to the Pesonal; Startup applications for my autologin user it works as expected. Firefox launches and then 10 second later xeyes pops up to observe what the user is browsing :smiley: Not real useful but it proves the process.

Regards,

Ken

p.s. Now all I have to do is figure out how to mark this thread SOLVED on this forum.

1 Like

Good to hear it’s all working. :slight_smile: Simply rename the title of your first post - maybe they’ll be a button one day.