Using 'defaults delete' command with com.apple.dock

I have been using the "defaults" command in my scripts to add an icon to a user's dock after a new application has been installed. But now, I'm having trouble trying to figure out how to remove an icon from the dock using the command line. For adding an icon, I use:
defaults write com.apple.dock persistent-apps -array-add '<dict><key>tile-data</key><dict><key>file-data</key><dict>
<key>_CFURLString</key><string>/Applications/NewApp/Program.app
</string><key>_CFURLStringType</key><integer>0</integer>
</dict></dict></dict>'
(take out all the carriage returns and spaces. I had to put them in here for the line to show properly on the post)
This works great for adding an icon. But, I cannot seem to write something similar using "defaults delete"
Any help is appreciated.
Thanks,
-Steve
PowerMac G5   Mac OS X (10.4.7)  

Hi Steve,
   If it froze then the code isn't robust against problems. In this case the problem is the web. The command has four spaces in a row in two of the matches. However, the browser smashes that down into a single space. I never understood that aspect of HTML but I know about it and should have considered it. I will replace the spaces with capital Xs. If you replace the Xs with regular spaces, the command should work:
defaults write com.apple.dock persistent-apps "$( defaults read com.apple.dock persistent-apps | awk 'BEGIN{ ARRAY = "("; ELEM = "" } /^XXXX{/{ while ( $0 !~ /^XXXX}/ ) { if ( ELEM == "" ){ ELEM = $0 } else { ELEM = ELEM "\n" $0 } if ( $0 ~ "_CFURLString\"" && $0 !~ /zzzz/ ){ FOUND = "true" } getline } ELEM = ELEM "\n" $0; if ( FOUND == "true" ){ ARRAY = ARRAY "\n" ELEM }; FOUND = "false"; ELEM = "" } END{ sub( /,[^\n]*$/, "", ARRAY); print ARRAY; print }' )"
In some sense that is poor coding but in the default syntax of the "defaults" command, the only way to determine depth is by how far something is indented. It would have been far more robust to actually count the number of opening parentheses and keep track of the depth but that would have been more complex to code. If I have time, I'll look into changing that.
   I assume that the reason the command hung is that it went into an infinite loop. I've also added a carat, '^', in front of the first group of four spaces that will keep that from happening. When typed correctly the command works without it but now it will fail without going into an infinite loop.
Gary
~~~~
   United Nations, New York, December 25. The peace and joy of the Christmas season was marred by a proclamation of a general strike of all the military forces of the world. Panic reigns in the hearts of all the patriots of every persuasion. Meanwhile, fears of universal disaster sank to an all-time low over the world.
      -- Isaac Asimov

Similar Messages

  • Using defaults in command line

    Greetings,
    I am trying to learn if I can set a screensaver hotcorner using defaults, such as bottom left to "on". Something like:
    defaults -currentHost write com.apple.screensaver hotCorners somevalue
    I would really be grateful for the answer to this one, but it also presents a bigger question. Is there a way to glean the available defaults commands for a particular application? For instance, I would like to determine the configurable attributes of the screensaver.
    Thanks for sharing your knowledge.
    Regards,
    Tim

    ..."I am trying to learn if I can set a screensaver hotcorner using defaults, such as bottom left to "on"."...
    The "hot corner" functions all appear to be stored in the com.apple.dock.plist file, with an integer value of "5" denoting the assigned action to be screensave activation. So a 'defaults' command to set the "bottom left" corner to activate the screensaver might be something like:<pre>defaults write com.apple.dock wvous-bl-corner -int 5
    osascript -e 'tell application "Dock" to quit'</pre>
    The second command restarts the "Dock" so that the preference file is read.
    ..."Is there a way to glean the available defaults commands for a particular application?"...
    Of course, anything actually set from the application's preferences, or "System Preferences.app" can just be read from a .plist file so it's just a matter of finding the file and comparing the contents "before" and "after". For those that aren't, there probably is, but I don't know it - there was something posted a long time ago at macosxhints.com for earlier versions of OS X but it was already out of date and didn't work when I tried it, I think in Panther. There is currently another thread on this site discussing using 'strings' to try to find "candidate" words that might be used as property list keys - maybe join in there...

  • "com.apple.dock.extra" & MBP Overheating

    My MBP (17" Unibody, Early 2009, 2.66GHz Intel Core 2 Duo, 8 GB 1067 MHz DDR3, NVIDIA GF 9400M 256MB)  has always run very hot. According to smcFanControl, it runs at 65-75 degrees celsius normally, and 95-107 degrees when I burn dvds. I've heard countless opinions about what temps are normal and no two people say the same thing. My MBP has never shutdown due to overheating, so I have to assume it's fine.
    Recently I installed Lion osx and have not found any improvements or upgrades that makes me think this OS is any better than Snow Leopard. Better yet, several developers say that Mountain Lion lacks any significant improvements over Lion. One article title said it best, "Apple Better Give Mountain Lion Away for Free!" I'll be holding out on the upgrade, and may be downgrading back to Snow Leopard. Currently I'm dealing with overheating issues, and not just when I'm converting and/or burning dvds. According to Activity Monitor, something called, "com.apple.dock.extra" and also something called "Calendar agent" keep popping up. The moment I quit these processes, the temp. of my MBP drops. Then they start-up again and the temp.goes back up. I deleted both files from their appropriate locations, and saved copies of them on my external drive just in case I needed to put them back.
    Anybody know how to stop these processes for good w/o harming any system files? Could I ruin my MBP by erasing those two files? This serves me right, no doubt, but I can't remember where the "com.apple.dock.extra" Unix Executable File should be located if I needed to put it back. Can someone please give me the HD/System/Library/ . . . . . .etc. location? Now my MBP overheats the same way, but now the Finder.app appears to be the culprit according to Activity Monitor. What I mean is -  if I force quit Finder when my Mac get too hot, the fans slow down and the temperature of my MBP lowers to a reasonable level. When I say temperature I'm referring to the temp. displayed by smcFanControl.app. I have no idea what the difference is between: a) the temperature of the HD,  b) the CPU temp, c) the temp of "Heatsink B", d) the temp of "Enclosure Bottom", or e) the temp of "Northbridge 1." I thought I might mention that.

    What do you have in the Dock? Any dynamic/animated icons (graphs, progress bars, etc.)?

  • Can I use two different devices with different apple ID for backing up data on one machine without losing any data that was backed up with one device earlier?

    Can I use two different devices with different apple ID for backing up data on one machine without losing any data that was backed up with one device earlier?

    The link is to a discussion started on 12/18 in the FiOS Internet forum.  Here's the link I get now, however it is different than the link I pulled a few hours ago.  If this system changes the link again, it may not work.
    http://forums.verizon.com/t5/FiOS-Internet/Frustration-and-just-confused-with-internet-help-please/t...
    You can also look for the topic, "frustration and just confused" in the FiOS Internet forum.
    Here's a link that is in the thread that gives more detail.
    https://secure.dslreports.com/faq/15984
    Good Luck!
    P.S.  "Copper Contributor" is my "rank."  gs0b is my user name.
    If a forum member gives an answer you like, give them the Kudos they deserve. If a member gives you the answer to your question, mark the answer as Accepted Solution so others can see the solution to the problem.

  • HT204153 How do I use a satellite subscription with my Apple TV?

    llooking to use a satellite subscription with my Apple TV how do I do that?

    Hello gigimaid,
    If your satellite service connects to a modem or router, you should be able to use either Wi-Fi or ethernet to connect your Apple TV to the internet. This resource should help:
    Switch between wired and wireless networks on your Apple TV
    Disconnect the Ethernet cable from the Apple TV.
    Navigate to Settings > General > Network to join a Wi-Fi network.
    A list of available wireless networks will appear. Using the up and down buttons on your remote, navigate to the network you wish to join and select it.
    If your wireless network requires a password, a keyboard will appear, allowing you to enter the password using your remote.
    If the network you wish to join is hidden, click Other. Then enter the network name using the onscreen keyboard and the remote. Enter the password if necessary.
    After Apple TV has joined the network, a Connection Succeeded screen should appear. Click Done. The screen now should display the wireless network information, including network name, IP address, Wi-Fi address, and signal strength.
    To switch back to a wired connection, connect the Ethernet cable. Apple TV will switch to the wired connection automatically. Apple TV prioritizes a wired Ethernet connection.
    Thank you for using Apple Support Communities.
    Cheers,
    Sterling

  • HT1539 How can a digital copy be used in a household with multiple apple ids, synced on the same computer?

    How can a digital copy be used in a household with multiple apple ids, synced on the same computer?  I want to put a digital copy on my device, and on my wife's device.
    Please help.

    you're welcome.
    actually, unless you take an extra step, the first opened swf will close.  if you want the 2nd to close, the initial receiving lc will send a message to sender that causes the sender to close.

  • Can i use someone else iPad with my apple id

    Can i use someone elses ipad with my apple id and download items?

    That should not be a problem if you wish to use other's apple id for your IOS device.
    However, if in the future you need to update the apps, which is needed to be done from time to time, you need to have the password of that person's apple id as well.
    It is better to have your own apple id for convenience.

  • Can I use Find My iPhone with my Apple Watch?

    Can I use Find My iPhone with my Apple Watch? Is there an app for it on Apple Watch? Can I add my Apple Watch to my Find My iPhone Account?

    No. No. And No.
    You can 'ping' your phone and have it play a sound (even if it's muted) from the watch, but it must be in range... That's intended to help you locate it if it's nearby but you forgot where you put it, or it slipped behind a couch cushion or something.

  • Can't Delete icloud with old Apple ID (which is not an email address)

    Alright a couple of years ago apple made the switch to an email address as the main log on, which I was cool with.  Fast forward to today now that I am interested in backing my phone up to the cloud I can not because it is prompting me for the password of my log in due to the fact the find my phone is on.  Meaning my log on back in the day was a random word same as my screen name "VERSE13" not an email.
    Any help would be apreciated.  I tried all the switching of emails to holding magical massage rocks on the back of my phone. 

    This is what worked for me. Should also work with the other problems with old email address and what not.
    First save all your important data.  I backed up all my contacts to OUTLOOK and took all my photos off the iphone.   This is important as you won't be restoring from an early sync. 
    The next thing I did was went into my itunes library and deleted all the apps that were associated with my old log in name.  (I made a note so I could redownload these later).  In Itunes library click on apps then click list.  Right click on app and select get info.  On the summary tab you will see the apple ID it was purchased/associated with.
    The next thing I did was restored my iPhone using the following instructions (which will get you around the whole not knowing the password thing):
    With Iphone connected to computer hold power and home button until the phone resets. 
    When the apple icon comes on release the power button (continue to hold home button). 
    The iphone screen will display something that is tell you to connect your phone to itunes.  On your computer you will receive the following message "Itunes has detected an Iphone in recovery mode.  You must restore this iphone before it can be used with iTunes." 
    Click Ok. 
    Then click restore iphone. 
    Then confirm to restore and update.
    When complete a screen that says "Welcome to your New Iphone" will be displayed.
    Do not select restore from backup.  This will just cause the same problems with screen IDs. 
    At this point just disconnect your Iphone and go through the startup steps on your phone. 
    Sign in with the Apple ID/Cloud ID that you want to use.
    When you are complete with that sync with Itunes library. 
    Make sure you select to set up as a new Iphone.  Place all your APPS and music back on your phone.  Set it up how you like it and sync to create a new restore point.
    So basically it is just like you got a new phone.   So it is very important you save your contacts and pics and video to your local hard drive.

  • Boot key commands with non-Apple keyboard

    I seem to be unable to perform any "Startup key" sequences (resetting PRAM, boot into recovery mode, boot from CD etcetera).
    I'm using a Logitech USB (model Y-BF37) keyboard directly connected to the computer but no startup key commands works. (The keyboard is designed for use with apple and has apples command-key symbols on the key nearest the spacebar).
    I have tried searching but the general opinion seem to be that any USB keyboard should work.
    I have this otherwise well working keyboard and I didn't want to spend money on an Apple keyboard.
    Do I have to buy an Apple keyboard to use boot key commands??? I don't think I can borrow an apple keyboard from anywhere and I need to be able to boot into recovery mode...

    It is indeed strange that it doesn't work, unless...
    Firmware password protection in Mac OS X ...
    http://support.apple.com/kb/HT1352
    It would block usage of all the startup keys, like C, N, T, D, CMD+s, CMD+Option+p+r, CMD +v, Option boot will show a lock, and Shift, as well as booting from anything but the Hard Drive.

  • Problems with com.apple.IconServicesAgent taking up lots of memory

    In efforts to clean up my Mac (Mavericks 10.9.4 on a 2008 iMac with 4GB memory, 278 BG free), I starting noticing a new process called com.apple.IconServicesAgent. It was the second largest hog of memory on my computer behind kernel_task. Kernel_task was taking up about 460MB (too much?) and this com.apple.IconServicesAgent was taking up 163MB.  Since I've only got 4GB memory, I wanted to curb this.
    In Activity Monitor, I could easily click to Force Quit that process and suffered no ill effects. It would, however, within a few minutes, reappear at around 12-14MB. Over time, even with the computer idle, it would grow back to around 160MB. It doesn't seem to get much bigger than that, but it seems fruitless to delete this ever so often to get memory relief.
    Since you can stop this process and force quit it with no side effects, is this just some superfluous file that Apple has put in to monitor something that doesn't need monitoring?  I can't seem to find anyone that knows anything about this process.
    Perhaps one of you have had this same issue? There seem to have been a few questions, but none of them that I saw were definitive.  I clicked on a couple and they wouldn't open for one reason or another.
    Thank you for your help, in advance.  Just trying to cut down on memory, since after boot I have about 2.80-3.2 GB consumed out of my 4.0 GB.

    Check this site. Works miracles on this problem.
    http://kieranhealy.org/blog/archives/2014/01/07/an-issue-in-mavericks-with-com-d ot-apple-dot-iconservicesagent/

  • Has anyone else had difficulty using WPA2 Internet sharing with their Apple TV? Any solutions?

    Hi.
    I've seen references to this on here, but no solutions.
    I use my 27" 2010 iMac to share Internet in my home, latest versions of OSX and iOS.. Works fine, sharing with iPhones, an iPad and my Apple TV 2.
    Recently though, I changed to WPA2, and the Apple TV can't see Home Sharing is on. If I switch security (ie WPA2) off, then it can see it again.
    So has anyone found a way to use WPA2 successfully with their Apple TV?
    Thanks in advance.

    I’d suggest uninstalling:
    Blackberry software
    the cycling74 driver
    Any HP “utilities” (regarding the HP IO. Apple told developers to stop using Startup Items back in 10.3.)
    any Adobe software you have (the “not loaded” ones are not loading because they’re incompatible.
    the com.apple.CSConfig one.
    facebook
    google keystone agent
    Unfortunately you have a lot of very questionable old, incompatible, and probably bad software on your Mac that is not playing well with Mavericks.  Some of these can be difficult to uninstall, particularly if you are not familiar with poking around in Mac system folders.
    You might consider cutting to the chase and doing a clean install:
    backup your documents and passwords, network settings, etc.
    Completely erase your hard drive
    Reinstall mavericks and your apps from scratch (not from backups)
    and finally replacing your documents.
    It can be a good thing. Spring cleaning. If you want to go this route, let me know, I can give you some more detailed suggestions for how to do it. The advantage is you can get Mavericks running really fast and reliably, and then be more selective about what you reinstall. A lot of the stuff you have on there is probably from apps you don't even use anymore (like for your Blackberry), or that really aren't necessary.

  • Can not use default screen saver with this version of Mac OS X

    Hello,
    I created a 10.6.4 image on a Mac Pro that I have installed on a new 27" iMac. Every thing works fine, as expected, except the screen savers (all Apple default). All screen savers appear in the list when booted off the Mac Pro, but when booted off the iMac, all but 2 disappear (Computer Name and Flurry). Also, the ones listed under Pictures show up, but when I try to use one it says "Can not use 'screen saver name' with this version of Mac OS X - Contact your vendor."
    Also, the flurry screen saver runs extremely slow.
    Unfortunately, I don't have another iMac to compare versions with, but I've compared with a new Macbook Pro and they are exactly the same. Is there a cache or a pref I can flush?

    The old screensavers were about the first things that didn't work when moving to Snow Leopard, so my guess would be the iMac is booting in 32-bit vs 64-bit mode (or whichever mode is incompatible with your screensavers).

  • Constant loop with com.apple.universalaccessAuthWarn

    Hi folks,
    since upgrade to Mavericks my Imac & Mac Book runs hot. I checked via console and found a constant loop with this error message:
    13.06.14 14:53:16,424 com.apple.launchd.peruser.501[180]: (com.apple.universalaccessAuthWarn) Throttling respawn: Will start in 1 seconds
    13.06.14 14:53:17,517 com.apple.launchd.peruser.501[180]: (com.apple.universalaccessAuthWarn[25916]) Exited with code: 1
    wich i can stop with the following command:
    launchctl remove com.apple.universalaccessAuthWarn
    Any hint how to stop permanently this loop (after a restart of the mac)  ?
    Thanks in advance,
    Sascha

    Hi i have same problem, tried to run the command sudo /Applications/Server.app/Contents/ServerRoot/usr/share/devicemgr/backend/wipeDB .sh but freeze and i get this error
    ***    Failed to create/update new Profile Manager database!           ***
    *** Please check /Library/Logs/ProfileManager/migration_tool.log       ***
    *** for more information. Profile Manager will be non-functional until ***
    *** the database can be successfully updated or a new one is created.  ***

  • TS1741 Can I use my IPad mini with my Apple TV 2

    Can I use my iPad mini with Apple TV 2

    hit the home button twice on your ipad mini.
    swipe from left to right.
    tap the airplay icon and pick apple tv
    you can also stream certain videos that have the airplay icon while you are playing the video.

Maybe you are looking for

  • Awesome 3.4.5-1 video issues (lingering visuals)

    I recently upgraded to awesome 3.4.5-1. I didn't reboot at the time, just restarted x. I rebooted when my house burned down, and at the same time had to change my nvidia settings [back to a single screen]. Since rebooting and changing settings, my aw

  • Spry Menu Bar Submenus Not Showing

    Hi! This is the first time I have ever used Spry .My Horizontal Spry Menu Bar Submenus are not working in ANY browsers whatsoever and I'm not sure whats wrong. My website is www.poor2chic.com. I have pasted a copy of my SpryMenuBarHorizontal.css as w

  • HT1203 Using the same Apple ID for more than one ipod.

    I am soon going to be purchasing a new ipod, so i was wondering if i can use my previous apple ID for my new ipod or if i have to create new apple ID and make a new itunes on my computer? (using windows)

  • Exclude top 10 in BEx query

    Hi Experts, I need to exclude top 10 from the query result. Creating condition in the query with top 10 is easy but how to exclude the top 10 in the query output? Thanks

  • Import and export under file is light grey

    I assume my scanner and printers did not install on Photoshop Elements 12 when I upgraded. How do I do that ?  I am running OS 10.8.5   I had just installed that prior to installing Elements. I can print from other programs just not Elements 12.