The Living Thing / Notebooks : Passive-aggressive advice on making OSX behave itself

See also command lines it is tedious to remember for general unix/osx/BSD commands.

Things I have to do so often to keep my laptop running that I’d prefer not to google them.

Most of these commands are supposed to be run sudo root, and each may irremediably fuck up your computer, your life, and everything you have ever loved. Then it might challenge you to a break dance battle, I dunno. It won’t be my fault.

UPDATE: So many of these were filesystem-specific hacks that I broke out those into an article on filesystem-specific hacks. And others were about easing the pains of using osx in the low-bandwidth majority world or OSX server.

The mothership of hints

Mathias Bynens’ and his incredible atomic dotfiles.

Argh stop stealing focus from me Atom I clicked on you like 30 seconds ago

How to keep applications from stealing focus.

Sierra adds still more useless timewasting nonsense

Disable a bunch of suspect stuff:

I’m not sure if this is sane, but it is satisfying.

# Agents to disable
TODISABLE=(
  'com.apple.photoanalysisd'
  'com.apple.telephonyutilities.callservicesd'
  'com.apple.AirPlayUIAgent'
  'com.apple.AirPortBaseStationAgent'
  'com.apple.CalendarAgent'
  'com.apple.DictationIM'
  'com.apple.iCloudUserNotifications'
  'com.apple.familycircled'
  'com.apple.familycontrols.useragent'
  'com.apple.familynotificationd'
  'com.apple.gamed'
  'com.apple.icloud.findmydeviced.findmydevice-user-agent'
  'com.apple.icloud.fmfd'
  'com.apple.imagent'
  'com.apple.cloudfamilyrestrictionsd-mac'
  'com.apple.cloudpaird'
  'com.apple.cloudphotosd'
  'com.apple.DictationIM'
  'com.apple.assistant_service'
  'com.apple.CallHistorySyncHelper'
  'com.apple.CallHistoryPluginHelper'
  'com.apple.AOSPushRelay'
  'com.apple.IMLoggingAgent'
  'com.apple.geodMachServiceBridge'
  'com.apple.syncdefaultsd'
  'com.apple.security.cloudkeychainproxy3'
  'com.apple.security.idskeychainsyncingproxy'
  'com.apple.security.keychain-circle-notification'
  'com.apple.sharingd'
  'com.apple.appleseed.seedusaged'
  'com.apple.cloudd'
  'com.apple.assistantd'
  'com.apple.parentalcontrols.check'
  'com.apple.parsecd'
  'com.apple.identityservicesd')


for agent in "${TODISABLE[@]}"
do
  sudo launchctl unload -w /System/Library/LaunchAgents/${agent}.plist
  launchctl unload -w /System/Library/LaunchAgents/${agent}.plist
  echo "[OK] Agent ${agent} Disabled"
done


# Daemons to disable
TODISABLE=('com.apple.netbiosd'
  'com.apple.preferences.timezone.admintool'
  'com.apple.preferences.timezone.auto'
  'com.apple.remotepairtool'
  'com.apple.rpmuxd'
  'com.apple.security.FDERecoveryAgent'
  'com.apple.icloud.findmydeviced'
  'com.apple.findmymacmessenger'
  'com.apple.familycontrols'
  'com.apple.findmymac'
  'com.apple.AirPlayXPCHelper'
  'com.apple.SubmitDiagInfo'
  'com.apple.screensharing'
  'com.apple.appleseed.fbahelperd'
  'com.apple.apsd'
  'com.apple.AOSNotificationOSX'
  'com.apple.FileSyncAgent.sshd'
  'com.apple.ManagedClient.cloudconfigurationd'
  'com.apple.ManagedClient.enroll'
  'com.apple.ManagedClient'
  'com.apple.ManagedClient.startup'
  'com.apple.iCloudStats'
  'com.apple.locationd'
  'com.apple.mbicloudsetupd'
  'com.apple.laterscheduler'
  'com.apple.awacsd'
  'com.apple.eapolcfg_auth'
  'com.apple.familycontrols')


for daemon in "${TODISABLE[@]}"
do
  sudo launchctl unload -w /System/Library/LaunchDaemons/${daemon}.plist
  launchctl unload -w /System/Library/LaunchDaemons/${daemon}.plist
  echo "[OK] Daemon ${daemon} Disabled"
done

OSX claims it forgot my email/contacts/calendar password again

Then an hour later it forgets again again?

Argh I fixed this once then I forgot how I did it.

Linkdump while I sort it out again again again:

Continuous [sic] request for the CalDav password

Here’s one solution:

  1. Go to the  Apple menu and choose System Preferences
  2. Choose the ‘iCloud’ preference pane
  3. Sign in to iCloud at the OS X preference panel – note if you’re already signed in here but still seeing the pop-up message, you can sign out then sign back in to stop that password prompt from happening again
  4. Close System Preferences as usual

distnoted freezes my computer

This is the desktop notifications daemon. I have no idea why it is out of control. One possible candidate is flux, (which I run) but the problem only seems to occur when my backup drive is plugged in. Hmmph.

Michael Rourke says do this every minute:

#!/bin/sh
#
# check for runaway distnoted, kill if necessary
#
PATH=/bin:/usr/bin
export PATH

ps -reo '%cpu,uid,pid,command' |
    awk -v UID=$UID '
    /distnoted agent$/ && $1 > 100.0 && $2 == UID {
        system("kill -9 " $3)
    }
    '

But note that weirdly, this breaks backups.

Now my machine won’t boot properly heeeeeelp

I wouldn’t panic yet, probably the boot loadey whodangle thingy is broken again.

(Also applies if your CPU fan is going all the time, your machine is pausing lots, you are having trouble getting laid, or a global geopolitical malaise is leading to the ineluctable slide of civilisation into ecosocial catastrophe.)

Do these things:

Other boot key combos of note

Alt
offer a boot menu
C
boot up off CD/USB
Command-R
Recovery OS
Shift
Safe mode
Command-V
verbose mode
Command-S
single user prompt

Which file is crashing that process?

Perpetual monitoring natively:

fs_usage PID | grep /path/to/file

or the classic unix way:

lsof -r -p PID | grep /path/to/file

See here for some tips on debugging runaway processes in more ways. “See what syscalls does the process actually try to do and if there are any failed ones (status is not 0)” :

sudo dtruss -p PID

Reset semaphores

I can’t even remember why I needed to do this, or how I worked it out, but geez it saved my bacon from something or other.

:

ipcs -s | grep " 0x" | awk '{ print $2; }' | xargs -n 1 ipcrm -s

My arbtrary server process is running out of file handles

Hmm, who knows how this works on the latest versions?

But the traditional advice is:

ulimit -S -n 2048

How do I stop my disk filling up with temporary backups?

WHAT CRAP IS THIS: OS X’S MOBILEBACKUPS:

sudo tmutil disablelocal

This shouldn’t be necessary, but I noticed that my spotlight indexing was stuck on the mobilebackups folder for some reason.

FFS iTunes never finishes syncing my phone it just stays stuck on “importing photos”

Because you don’t use iCloud, right? For one thing, why would you voluntarily put your private photos in the hands of some notoriously secretive third party? For another, even if you wanted to, if you live in a bandwidth-poor country, iCloud sync is not just bad, it’s comedically bad. Atrociously, OS-floggingly slow and glitchy. “iClod”, let us call it. So you sync using a cable and iTunes, of course.

Except that, every couple of days, that breaks. Heres how to fix it. (Note that this question refers to “iPhoto”, but the same bug has been faithfully carried over and reproduced in Aperture and Photos by diligent Apple devs, and the same fix works.)

Using Chromium (“open-source chrome”)

Harder than it should be; Google really wants you to use their furtively modified alternate branch, Google Chrome.

Anyway, here is a mainline supplier of unsullied Chromium.

Creating GUIs for shell scripts

Various options.

Automatically anonymized system stats

Etrecheck

Change default shell

Re-time stupid alarms

By default, if you use notifications from Apple Calendar, the notification for events is at 9am, right in the middle of the first meeting of the day. So you are half way through the report-back presentation about your recent conference visit, your laptop pops up RECTAL EXAMINATION TODAY.

You aren’t supposed to be able to change this because the thought of this cruelty is all that gets jaded Apple executives out of bed in the morning, but there is a hack they forgot to stop.

Stop gamed and other processes leaking your data and wasting precious network sockets for no reason

binary bob says :

sudo defaults write /System/Library/LaunchAgents/com.apple.gamed disabled -bool true

or:

launchctl unload -w /System/Library/LaunchAgents/com.apple.gamed.plist

in reference to this.

If you are reading this you are enough of a geek to need xcode

Run this:

xcode-select --install

Saving 300MB from skype on general principle

Note

Update: the new version of Skype actually keeps this offal in the cache folder. (I imagine this is purely because of my passive-aggressive complaining.) So now you don’t need to delete it. Unless you are deleting skype, in which case the command is:

rm -f ~/Library/Caches/com.skype.skype/fsCachedData/*

Since Skype is spookware I keep on my hard disk out of necessity, I am always mildly offended that it takes up 300MB of hard disk space for cached emoji for every single skype username. (update: last time I checked they had managed to get it down to 200mb; still too much.)

This is all to store videos of Fozzie Bear and Christmas ornaments. The biggest Emoji-jockey on earth will never use 90% of this shit, and even though it claims to be a “cache”, it’s not in a cache folder, so it clogs up your backups with Fozzie Bear pictures. Put this in a launch agent:

rm -rf ~/Library/Application\ Support/Skype/*/media_messaging/*_cache_*

Don’t worry, Skype still works, and recreates the folder for you with the obsessiveness of a meth addict trying to polish your windshield; really you just need to remember that some Skype calls might be free in dollars, but they bill you 300mb of disk space/bandwidth for every call as well as the recordings of your cybersex, but you can get the 300MB disk space back afterwards, whereas the dick pics are lost to the US government forever. (It doesn’t seem to work if you trigger it from a folder action, so I set up a cron job to run that command every 10 minutes.)

To file