Reputation: 227
I am creating osx service with automator to show context menu items for a file like how dropbox shows the menu below.
I understand that these are not osx services but however i would to like accomplish the same thing with osx services. Hence i have created 2 osx services using automator for files and folders in Finder.app and attached a shell script action to this.
Now i could see all of my 2 services (Share with a, Share with b) in the contextual menu like below
From the shell script(actions for those services) am launching an app. I wanted to launch the app with the file path and service name as two command line args.
Any idea how to get service name of user selected service inside shell script like we get file name from the command line parameter "$@"
Upvotes: 2
Views: 472
Reputation: 474
"Basically my aim is to open a browser with an URL which is different for each of the menu item."
Something like the following AppleScript can be used to open a URL in the default web browser, using AppleScript:
tell application "Finder" to open location "http://learnbymac.com"
Something like the following shell script can be used to open a URL from the shell:
open -a "Finder" "http://learnbymac.com"
Using the Finder to open URLs is better than using Safari because when you use the Finder to open URLs, you get the default browser rather than always getting Safari.
" i will launch an app / exe from the shell script by passing path to the file & service name so that the app can construct url based on the service name by reading the file details from the data base and loads the url in the browser."
You may have to provide the name of your service in your workflow's "Run Shell Script" action when you launch your app. This might be best anyways because then if the user changed the name of the Service, your software would still run. I know that it would be ideal to not duplicate the name of the Service having it once in the workflow's bundle and again in your "Run Shell Script" action, but I don't know how to get the name of the currently running Service.
-- Kaydell
[email protected]
Upvotes: 1