I have a project on mac that has to start the login app once the stick is inserted , the app will run from the stick, For the moment i did an automator workflow, but it seems that it is not reliable so i`m looking for a helper or something that will be installed on fist time the app starts manually and then to monitor the /Volumes for usbx name and once detected to start the app that is on the stick.
As far as i know apple does not allow autolaunch but as far as i see on the 3g sticks for example, once the stick inserted in the usb it launches the connection interface, so i need same functionality .
Any ideas ? on the sample apps it seems that does not shows something similar.
Thanks in advance.
Did you have a look at NSWorkspace? The DidMount event should fire in case a new device was mounted:
Ah, no, I seem you want some kind of autostart. I guess you should install a daemon checking for the kind of mounted media the other way round should be impossible.
Edit: And you could run the helper app automatically by adding it to the startup items. NSWorkSpace should be the right class for that: You can also start applications with selected files from it.
ve look on your sample but as you said i need something to start with the os and to monitor always the mounts, but no idea how to do that, for now im using one automator folder action, but it seems that after the last update it does not work anymore so i don`t know what else to try honestly, i put the workflow in the bundle and try to install it on the first run but it works from time to time
I can imagine creating a small maybe even UI-less app that could be added to system prefs/user account/startup items, watches the mounts via NSWorkspace and in case starts the real app should do the trick or do I miss something?
Thanks, for your reply, i
ve looked on the mac side on where and how to make apps, and it seems that somehow, i have to install the app without user interaction for the first time and then the app to monitor when the certain stick is inserted in the usb and to start the app within so the locations where i guess it will be the app installed will be /Library/StartupItems or maybe im wrong. The app i was thinking to make it a console app that will monitor the /Volumes folder for the folder named X and once detected, to check if the app is running or not and if not to start it, with a timer for every 2 seconds i guess.
Now as far as i read it can be kind of dangerous to put the apps in the wrong place so i want to be sure before i`m putting them in order not to brake something.
Thanks again and please let me know if that location is the good one and if in case the app side does not interfere with the apple restrictions.
I have used the same approach to bring the bundle document folders to Windows, where a small program started upon launch monitors folders opening and when one has an info.plist, it offers to open the compatible files inside.
It is fairly simple to do for a volume as well, and launch an associated app if needed.
See http://www.vdsc.eu/files/HelperIntegratorHowto.zip to have an app start automatically upon launch. Alternatively, you can instruct your user how to right click on the app icon in the dock and set its options to open at login. Any app in the Applications folder can be used that way.
This is the only way I know how to do it also, Backup To Go uses it to know a disk is inserted, in order to backup.
Thanks guys, it seems that for me the launchd it does not want to work, i`ve tried with those playlists, timings, apple scripts, nothing,
So finally i
ve made a simple apple script that checks if the desired usb is mounted, if mounted to check if the app is running and if not , to start it, and ive put a sleep for 10 seconds and it is always running, i
ve exported that as an application, put it in the applications folder, added to login and fixed the problem, and thanks to a small tweak in the info.plist i managed to make it run without showing the icon on the doc, i still have pending to automate this in the XOJO app to do the installing and thats it .
Thanks again for your ideas.
On the vdsc i did tried that but it seems that the latest app it crashed while setting up the process so i prefer to doit my way than to rely on an option that is not safe.