Mac OS X Services: enable without user interaction? - macos

I wrote a simple Mac 'Service' for Finder, that executes a command.
Basically: this adds a ContextMenu in Finder.
If I right-click a file in Finder, a menu item pops up. If the user clicks it, it executes my script. (kind of like 'Send to Bluetooth device, ...')
In OS X Leopard (10.5) and earlier, all services are enabled.
In 10.6 (Snow Leopard), Apple changed the behavior, services now have preferences, and can be enabled or disabled by the user. (which is a good thing)
However, I wrote the service, but there seems to be no way to enable it automatically (in our installer).
I tried doing it with Applescript, going to the System Preferences and ticking the checkbox that way, but it requires some accessibility features to be turned on. (off by default).
Is it possible? If so, how?
Or do I need something else to provide Context Menus in Finder.

I tracked File changes on my filesystem while changing the preferences and discovered there was a plist file:
~/Library/Prefrences/pbs.plist
which contains what I need.
If I edit that manually, it seems to work. So, problem solved :)

Related

Create custom right-click menu for OS X app, developed on Linux

I am creating an app for Mac OS, but it is being built on Linux. Because of this, I am not able to use tools such as Xcode, and I am not developing in swift. Rather, the .app directory is being put together according to Apple's documentation, and the entrypoint/executable of my app is a shell script.
I need to customize the menu which appears when you right click on the app (either on the dock icon or in Finder). Is there a way to do this, without using cocoa, etc.?
The menu I believe you are referring to is called "Services".
In order to add a menu item there for your application you would create a script to enable including it there. Xcode isn't needed or required, however, you'll need to know at the very least some basic AppleScript or Javascript to accomplish what you want. (see examples from the link)
↳ Mac Automation Scripting Guide

Accessibility disabled for app in Mac OS X 10.9

After upgrading to Mac OS X 10.9 and running my app (which executes various AppleScripts as part of its execution) I get a dialog that the app has to be specifically enabled via the System Preferences Security/Privacy screen. So I do this and the app then functions properly.
However, when I recompile and build the app, it will no longer execute the AppleScripts and does not show the dialog. When I look in the System Preferences Security/Privacy I see that my app is still listed there but has been disabled (i.e. checkbox reset).
BY trial and error, I have found the following:
If you change the Bundle Version string in the apps info.plist and rebuild the app even without making any other changes such as code, etc this will happen; it will be disabled from accessibility.
If you make all kinds of changes to the app (code, resources, etc) but do not change the Bundle Version string in info.plist, it will still be allowed to have accessibility access.
My question is: is there a way to circumvent disabling after rebuilding?

Creating feature in mac app to override the users security setting

I'm a newbie at mac osx development. I would like to know if there's any way to override the mac desktop security settings to allow an application - which is not registered in the Mac App Store, to be installed?
The setting should come from the app that I'm trying to install. That means, whenever I install the app to any mac computer, regardless of its security settings as the following,
Allow applications downloaded from:
Mac App Store
Mac App Store and identified developers
Anywhere
The app should set the settings to Anywhere, allowing it to be installed.
Any help would be very much appreciated.
Launch System Preferences from the Apple menu.
Choose “Security & Privacy” and then click the “General” tab, followed by clicking the lock icon in the corner to unlock the settings.
Look for “Allow applications downloaded from:” and choose “Anywhere”.
Accept the security warning and allow.
Note that you should be careful and aware that now the job of protecting the system from malicious apps belongs to you instead of the OS.
Right click the (app) icon and click 'open' in contextual menu - no need to disable the OS security.
This is not possible. The existence of that setting is intended to protect users from malicious executables. If there were a way for any arbitrary executable to override that setting, what protection would it offer? Malicious executables would simply change the setting to "Anywhere" like you suggest, bypassing the security features of Mac OS X.
You need to sign your application using a Mac Developer certificate, which you can obtain from Apple. That will mark your app as built by an "identified developer" and it will launch just fine without changing any settings.
Control Click the app icon to override this security feature. This is a one off, you don't have to change your settings, you can do it per-app.
There is one other way...
All you have to do to do it manually is to open up Terminal, cd into the .app application, cd into the Contents folder, then cd into the MacOS folder, then type ./YourAppNameHere and execute by typing Enter.

how to add item in right click context menu of file and folder in objective c

I am developing an cocoa application for Mac and what i need is to add an item in the context menu that appears when user right-clicks on specific file and folder (i.e. when user click on file or folder by pressing ctrl key of keyboard).
I am new to Cocoa application development. I have searched in google for it and found that it can be implemented by using CFPlugIn. Does anyone know how to use CFPlugIn to implement this or any other method to add item in context menu of specific file or folder??
Thanks in advance
You can use system services for contextual menu. you should refer Services Implementation Guide. take a look at Services step out in Snow Leopard article.
If you wish to sell your product on apple app store than you should not follow dropbox.
This is no longer supported in Mac OS X 10.6 and Mac OS X 10.7. Earlier versions of Mac OS X had support for contextual menu plugins, but this feature has since been removed.
What is it you're trying to accomplish in the broader sense? If you give us an idea of what your goal is, we may be able to suggest an alternate way to accomplish it.
Using System Extensions and a FinderSync extension you can accomplish this.
https://developer.apple.com/library/content/documentation/General/Conceptual/ExtensibilityPG/Finder.html

Autorun for Mac?

I've got a Flash projector which I plan to distribute on CD. I'm making a projector for Mac and Windows. I know how to do Autorun on Windows, but I want to do so on Mac as well.
How does that work?
It doesn't. Mac OS 7–9 had a similar system but Mac OS X has nothing of the sort.
Your best bet is to make a nice Finder window design that makes it clear what to do. DropDMG may be useful.
There is no autorun in OSX anymore.
You can't set an application to autorun for security reasons. However you can set a Finder window to auto open on insert. I've seen a lot of CDs do this then have a "Click here to start" icon.
This is the terminal command to set it up on your diskimage before burning. discName should be the name of your disk image.
sudo bless -folder "/Volumes/discName" -openfolder "/Volumes/discName"
More info here
There is an easy way to do it. Just right-click the icon in the dock, chose "Options", then "Open at Login"
Then the selected app will launch every time OSX boots.

Resources