I have a java application built with Eclipse, for Mac OS X.
This app is installed via a .pkg file and supposed to be daemonized. Everything works fine, with Macbooks (Pro, Retina), but with the iMac I work on, when the application launches, i have an icon on the Dock, as you can see on the
following link.
I have already tried the solution in this topic: stackoverflow.com/a/620950/3641679 but it didn't work (I still have the Dock icon). Currently the Info.plist looks like this.
What can I do?
Thank you for the time you'll be taking to help me.
Informations (assuming the app name is testapp)
I stop or start the daemon using launchctl start/stop
When I double click on the executable (in testapp.app/Contents/MacOs/testapp) i have the testapp.app in the Dock (with the icon file specified in the Info.plist). Here is a screenshot res.cloudinary.com/doit0eqlo/image/upload/v1400750376/app_k3adzh.png
Sorry for some links, I must have 10 reputation to post more than 2 links.
So, I finally found the solution! The solution is in several steps.
Step 1: Editing the Info.plist
I had to add the LSBackgroundOnly key. It is a string and has to be set to 1.
As said in the Apple Documentation :
LSBackgroundOnly
specifies whether this app runs only in the background. If this key exists and is set to “1”, Launch Services runs the app in the background only.
Information:
Although the documentation specifies this key is a boolean, setting it to a string with the value 1 in it does the trick.
To do so:
Go to your app's folder
Go into the .app's folder then the Contents one (eg. /Applications/test.app/Contents)
Open the Info.plist with any text editor you want (SublimeText, TextEdit,Xcode, etc.)
Add the following lines before the closing dict tag (</dict>)
<key>LSBackgroundOnly</key>
<string>1</string>
Save everything.
Step 2: Edit the appname.ini
Initially I only did the part 1, so it wasn't enough. I found the solution in this question.
The file is in the 'Contents/MacOs' folder inside your application's .app (e.g /Applications/testapp.app/Contents/MacOs/testapp.ini).
Open the .ini file (with any text editor you want).
Before the -vmargs line, add the following line: -nosplash
After the -vmargs line, add the following two lines:
-Xdock:hidden
-Dapple.awt.UIElement=false
Save the file, and now you can launch the app: it shouldn't be any icon neither in the Dock nor in the 'Force Quit' window, but your app should be running in the background.
Hope this helps,
Add this to your info.plist: -
<key>LSUIElement</key>
<true/>
Note that the value here is set to 'true' and not 1
As the Apple docs state: -
Specifies whether the app is an agent app, that is, an app that should not appear in the Dock or Force Quit window. See “LSUIElement” for details.
Related
My appleScript-program runs several minutes and I don't wont see the script running. Can I hide it from the desktop a appleScript-command at the beginning of the program
I assume by "AppleScript-program" you mean an AppleScript app: an AppleScript saved as an application to run independently of Script Editor. If that's the case, the you want to set the LSUIElement property of the app to 'true'. There are two ways to do this:
Manually edit the Application's info.plist file
Locate the AppleScript app icon in the Finder
Right-click on the icon and choose "Show Package Contents"
Open the "Contents" folder that appears
Open the "info.plist" file in a plain-text editor (like BBEdit or TextEdit")
Check to make sure there isn't an 'LSUIElement' key in the plist
Add the following key-value pair to the plist, or edit one that's there, without breaking up any other key-value pairs:
<key>LSUIElement</key>
<true/>
Use terminal to set the value
Open Terminal.app (or an equivalent command-line application)
Type in the following command, and execute:
defaults write /Path/to/YourScriptApp.app/Contents/Info LSUIElement 1
Both methods produce the same outcome, so do whichever you're more comfortable with.
MacOS is continually using Xcode to open various files in my OS. I already know how to set a default app opener for all files with a particular extension (.txt, .py, etc...), but I can't use this feature with "extensionless" files like .bash_profile. Is there a workaround for this other than changing the default app for each file?
My preferred solution would be if I could tell MacOS to never use Xcode as a default app opener. I'm assuming there is some config file buried away that might help me achieve this but I haven't been able to find anything to help me with this.
Looking for the same I found this answer stop-xcode-from-hijacking-my-file-associations on apple.stackexchange.
It seems that XCode is pretty persistent but using this 3rd party app https://github.com/Lord-Kamina/SwiftDefaultApps you can achieve it!
Before;
After;
Instructions;
Step 1: After installing the app, go to System preferences > SwiftDefaultApps
Step 2: Go to the Uniform Type Identifiers tab and look for public data.
Step 3: Assign, under the Editor section, the desired editor.
Step 4: Apply (the app is a little bit clumsy and sometimes it doesn't show the confirmation popup, if this is the case, just close the preference window, open it again and check that everything is ok!)
Since asking this question, I stumbled upon this MacOS system file:
~/Library/Preferences/com.apple.LaunchServices/com.apple.launchservices.secure.plist
I've found that you can add your own dict entries into the LSHandlers array. For instance, I added the following entry to bind all public.data file types to my Sublime application:
<dict>
<key>LSHandlerContentType</key>
<string>public.data</string>
<key>LSHandlerPreferredVersions</key>
<dict>
<key>LSHandlerRoleAll</key>
<string>-</string>
</dict>
<key>LSHandlerRoleAll</key>
<string>com.sublimetext.4</string>
</dict>
Right click on a file where you want to change the default editor
Choose Get Info (Or simply select the file and press CMD+I)
Select the editor in the Open with section
Click Change All..
Now all files of this type will be opened with the editor you selected.
I created an apple script and placed on my desktop. I first saved it as .app and when double clicked it ran code successfully and closed. However in the time it would run it would show an icon in my dock.
So to avoid that i thought lets save it as a run only script. So I did that but now when I double click it, it doesn't run the script, it just says 'it was saved as read only and cannot open'.
You can edit the Contents/Info.plist (easy with Xcode) located in the app bundle and add a Application is agent (UIElement) - Key with value YES to it. Now it shouldn't show in the Dock when running.
The raw text to include is:
<key>LSUIElement</key>
<true/>
Change your run only script's extension from ".scpt" to ".app" and you should be able to run the thing.
More information can be found in this closely related question.
I am trying to make a keyboard shortcut to launch terminal in OS X Mountain Lion.
After some research I found out that I can use Automator to achieve this:
http://mac.tutsplus.com/tutorials/tips-shortcuts/how-to-launch-any-app-with-a-keyboard-shortcut/
It works, but I noticed that whenever I launch a terminal using this method, a process called WorkFlowServiceRunner starts and never terminates. To make matters worse when I launch more terminals (or launch different applications using shortcuts, again, through Automator) multiple WorkFlowServiceRunner processes start and quickly eat up the memory.
I've also tried writing my own applescripts but the problem does not go away. This clearly looks like a memory leak. Is this a bug in OS X Automator? Is there a way to write an applescript so that the WorkFlowServiceRunner terminates after doing its job (e.g. launch a terminal)? Automator seems to be the most "native" way of getting this done and I do not want to use any 3rd party apps.
I have noticed this from time to time.
One way around it would be to make your own service apps with a Cocoa-AppleScript Applet.
It is not very hard to do. And I will try and guide you through it. It should only take you a couple of minutes.
Step 1.
Open your Application Applescript Editor. And go to the "File" Menu -> "New from Template" -> Cocoa-AppleScript Applet.app
Step 2,
Paste this code into the new documents.
property NSWorkspace : class "NSWorkspace"
tell current application's NSApp to setServicesProvider_(me)
NSUpdateDynamicServices()
my runAService()
on runAService()
NSWorkspace's sharedWorkspace()'s launchAppWithBundleIdentifier_options_additionalEventParamDescriptor_launchIdentifier_("com.apple.Terminal", current application's NSWorkspaceLaunchDefault, missing value, missing value)
tell me to quit
end runAService
Step 3,
Compile
(click this to compile)
and Save the app.
*Make sure the show startup screen is unchecked in the Save dialogue.
Giving the app a name like LaunchTerminal.app
Step 4,
Click the "Bundle Contents" button on the top right hand side of the document.
This will open the applications contents view.
Click the Action button and then "Reveal in finder" sub menu.
step 5,
In the contents folder that opens in the finder you will see a file name "info.plist"
Open Terminal.app and type and run this code using the path to this file:
BUT make sure you do not include the ".plist" part of the name when entering it in Terminal.app
/usr/bin/defaults write /Users/YourUserNameHere/myServiceApps/LaunchTerminal.app/Contents/Info NSServices -array-add '{NSMenuItem={default="Launch Terminal";}; NSMessage="runAService"; NSSendTypes=();}'
( You can drag n drop the file into terminal to get the posix path string )
The path part looks like this: /Users/YourUserNameHere/myServiceApps/LaunchTerminal.app/Contents/Info
This code should add an array to the plist file which is part of the apps way of broadcasting it has a service.
step 6,
Compile and Save the App again.
Just to make sure it picks up the changes. ( I found I had to do this even though I should not have to)
step 7,
Double click the app to run it for the first time.
The App will quit straight away. But the first run should have broadcast that it has a service that should be registered with the system
step 8,
Open system Preferences and go to Services -> General (section)
And you will see the "Launch Terminal" service.
Set up your short cut as normal.
Hope this helps..
UPDATE :
I noticed that the tell application "Terminal" to activate. Would not open my default Window groups if I had closed them all and quit Terminal before. The normal behaviour if I have done this is for my default window group to open. ( I have two Tabs open at startup each cd'd to a different path).
So I have change the open application to a cocoa way of doing it.
A do shell script with open the/application/path/. will work also.
Try using Butler or QuicKeys. They both have endless "Trial periods."
Using AppleScript you can create a script that runs another application, and then save that script itself as an application and place it in the dock. The problem (not really a problem) is that when you click it, it will still show the other application on the dock. Is it possible to prevent the other application from showing in the dock, yet show its GUI as it would normally do when executed?
Thanks
The only solution I can think of is to actually modify the 'other app' to have no Dock icon. It works, but it's nasty:
•Yep, you're directly modifying the other app—not doing something from your script.
•Accordingly, it will change every launch of said other app, not just invocation from your script.
•It prevents OtherApp from having a menubar (though key combos and any in-window controls will still work).
It's easily reversed though, and can almost always be done just by adding a GUI mode flag to the app's Info.plist file:
Right- or Ctrl-click the other app and Choose 'Show Package Contents'
Open the 'Contents' folder
Open the Info.plist in your text/xml editor of choice*
Add these two lines right after the first line that says <dict>
<key>NSUIElement</key>
<true/>
Save, then fire up the app. Remember… no menubar, so make sure one of its windows has focus and -Q to quit when you verify it runs with no Dock icon.
*If you're squeamish with editing xml, or if the plist file is the binary variety, you'll need a dedicated plist editor. Apple's own Property List Editor is included with their free Dev Tools.
Add a Child to the root ("Information Property List").
Set the name to NSUIElement.
From the Edit (or context) menu, set the Value Type to Boolean.
Click the checkbox ON (sets the bool to true).
Building off the previous answer -- you can modify the Info.plist of your Applescript application with the same XML code. This will prevent the Applescript app from displaying an icon (and having a menubar, which in my experience is unusable anyway for this type of 'app'), but your main application -- the one you're launching from the applescript -- will display in the Dock as usual.
I tried this on OSX 10.7 Lion and it worked successfully.