PDA

View Full Version : How to put a script in the Launchpad?




RA23
Dec 13, 2012, 02:53 AM
I just got myself a MBPR yesterday after 15 years of only using Linux (so pls. be patient).

I have some scripts that I use regularly and I would like to run them from the Launchpad. So in the Applications folder I created a folder SomeScript.app/Contents/MacOS/ and put my script SomeScript in that (like I found googling around)
Then I assigned an icon to this folder.

It appears to work: if I open the Applications folder in Finder, I see the icon and when I click on it, the script executes.

But whatever I do, it does not appear on the Launchpad, also not on the 2nd page, dragging it to the Launchpad icon also does not work, neither does rm. ~/Library/Application\ Support/Dock/*.db; killall Dock

Anyone know why it won't work? do I need more "magic" files in the Contents folder?



Weaselboy
Dec 13, 2012, 10:43 AM
Is this an Applescript? How about just save the script as an application then put it in the Applications folder. I believe that would make it appear in Launchpad.

rhoydotp
Dec 13, 2012, 11:39 AM
i saw this link via google that might help.

http://jitsik.com/wordpress/?p=275

it's not actually adding anything but seems like you can play around with the database if you're familiar with sql queries

looks interesting, though. I might try when I get home tonight.

RA23
Dec 13, 2012, 08:39 PM
@Weaselboy: No they are bash and python scripts. But how do I save a script as an application? Or is that only possible for Applescripts?

@rhoydotp: thanks for that link, I hadn't come across that one yet. I checked the dbase and indeed, my script was not in it. I could try to manually enter it, but I am not sure if the other columns are critical, so I'll hold off on that for now.
Incidentally, that link also spoke about spotlight. I did not know about that as an Apple newbie, so I tried entering the name of my script in the spotlight and it found the script itself (clicking on that opens it in an editor), but it did *not* find the script.app folder in the Applications folder. Isn' t that strange?

rhoydotp
Dec 13, 2012, 10:35 PM
really interesting stuff, i must say :)

well, i did some looking around and here's what I got regarding the table so you might be able to try to add your script via an "insert" operation (i didn't try it myself though)


sqlite> .tables
app_sources dbinfo image_cache widgets
apps downloading_apps items
categories groups widget_sources
sqlite> .schema apps
CREATE TABLE apps (item_id INTEGER PRIMARY KEY, title VARCHAR, bundleid VARCHAR, storeid VARCHAR,category_id INTEGER, moddate REAL, bookmark BLOB);


sqlite> select * from apps where title == "Skype";
160|Skype|com.skype.skype||7|376286430.0|book?
sqlite> select * from apps where title == "Terminal";
134|Terminal|com.apple.Terminal||3|361922519.0|book?
sqlite>

RA23
Dec 14, 2012, 02:50 AM
Yes, inserting manually in the db is what I was considering, but I don' t know how relevant the other fields are. If nobody else comes up with alternative ideas, that is what I will do.

I still find it strange that nobody has apparently needed to do this before... seems a very common task to me.

Weaselboy
Dec 14, 2012, 08:45 AM
@Weaselboy: No they are bash and python scripts. But how do I save a script as an application? Or is that only possible for Applescripts?

You can call both bash and python from within an Applescript by using the "do shell script" command.

For example the below is part of an Applescript I use to launch some apps/files after my machine starts.

do shell script "open ~/Documents/ibank_data.ibank"


This has the same effect as typing "open ~/Documents/ibank_data.ibank" in Terminal (bash).

Python will do the same thing. You can Google "python in Applescript" and find examples.

So make your Applescript then and click the run button in Applescript Editor to make sure it is doing what you want. Once you are happy with it, do command-s to save the script. The window below will come up. Change File Format from script to Application and click save.

You will now have a regular Mac application that runs your python or bash script and you can put it in Applications and it should then show in Launchpad.

http://i.imgur.com/RcJgc.png

RA23
Dec 14, 2012, 11:31 PM
Thanks Weaselboy, that worked flawlessly.
I am starting to like the Mac more and more :)