I have an app and I want to add the feature that allows the user to hide and show the dock icon. I know that you can make it hide all the time by adding
LSUIElement
1
to the .plist in the XCode file.
So, to include this feature I simple want the app to read that file and add or take out those 2 lines based on whether or not the user wants them. However, I have two issues.
I don’t know how to access that file, but I’m guessing its something like
Example.app/contents/example.plist
I’m not sure is applscript can write to .plist files now, but i know it will be able to in Leopard, so will i have to wait to intergrate my code?
I tried that, and I’m getting a “2007-10-25 11:41:59.487 defaults[875]
There is no (LSUIElement) default for the (/Applications/Example.app/Contents/Info) domain.
Defaults have not been changed.”
Also, now for some reason the writing one isn’t working, either. I didn’t delete the .plist, i checked.
try this: it toggles the state of LSUIelement (1 or not existing)
property theApp : "PodNod"
set i to (path to startup disk as Unicode text) & "Applications:" & theApp & ".app:"
try
(i & "Contents:Info.plist") as alias -- check if Info.plist exists
set infoPlist to quoted form of POSIX path of (i & "Contents:Info")
try
do shell script "defaults read " & infoPlist & " LSUIElement"
do shell script "defaults delete " & infoPlist & " LSUIElement"
display dialog "Dock Icon of application " & theApp & " will be showed"
on error
do shell script "defaults write " & infoPlist & " LSUIElement 1"
display dialog "Dock Icon of of application " & theApp & " will be hidden" buttons {"OK"} default button 1
do shell script "touch " & quoted form of POSIX path of i
end try
on error
display dialog "file Info.plist of application PodNod doesn't exist"
end try
Hey, that works almost perfectly, thanks! It weird though in that the app has to be running when switching the icon on, but when switching the icon off, it doesnt have to be running.