I have a speaker that automatically turns off after a certain period of inactivity, and my use case typically is open the laptop, turn the speaker on, and when the Bluetooth driver is acting normal, they will automatically reconnect. In case of Permission denied, set the file permissions so that you can run the script with chmod 755 mount_afp_when_itunes_running.sh, then try again.įinally, if everything works, you could then launch this script automatically via a Launch Agent.I seem to be having persistent issues with Bluetooth connectivity, especially after waking up my Macbook Pro from a long sleep. To check if the thing works in principle: Let’s say the script is on the Desktop, in Terminal type cd ~/Desktop/, then. VOLUMENAME is the name from the normal AFP connection dialog ( ssd in this case): You’ll have to configure the script before running it for the first time, see the variables on top of the script. If so, it checks whether your AFP volume is mounted already, and does so if not. If [ ! -d "/Volumes/$."īasically, it runs in an infinite loop and checks every two seconds if iTunes.app is running. If Tunes.app/Contents/MacOS/iTunes ") ]] then VOLUMENAME="your_volume_name" # name of volume to be mounted, typically username on AFP server. PASS="your_password" # for connection to AFP server USER="your_user_name" # for connection to AFP server You can download it from this gist page (look for the "raw" download link). I made a script that connects to a network drive when iTunes is running. ![]() Right now this script just displays the results but you can make it do whatever you want at this point. it sets up the application parameters in the "on run" handler and then in "on idle" it can check those parameters. You set how often it runs by returning a number of seconds at the end of the handler. "on run" runs once at application launch. The way a stay-open script works is there's 2 main handlers, the "on run" and the "on idle". Save it as an application and check the "stay open" box to make it stay open after you launch it. So here's an example applescript for you. What you need is an applescript that stays open all the time and performs its tasks periodically. Run a script whenever an application opens I could not get it to work on Lion, some syntax issues need to be resolved. Lastly, it looks like it may possible to write an Apple Script that does exactly what you want, here is a link to something that may be able to work with some modification. Run the script, you can treat it like any other Application. Name it what you like but be sure to set the file format to "Application" on the "File Format:" dropdown. wait 10 seconds adjust this time to meet your needs ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |