Skip to content
accelerando

Tag Archives: Mac OS X

ALT+Click all the things

05-Dec-14

Here’s a list of things you can ALT+Click (Option key ⌥ + left mouse button) in Mac OS X:

  • ALT+Click on the WiFi icon in the menubar gives you detailed information about your selected WiFi network
  • ALT+Click on the volume icon in the menubar lets you quickly select audio input and output device
  • ALT+Click on any of the triangles on a tree-ish view (Finder in listmode, IDEs etc.) expands or collapses all subitems
  • If you have multiple Time Machine volumes attached, ALT+Click on the Time Machine icon in the menubar lets you browse other Backups than the default with that spacy interface
  • ALT+Click on the BlueTooth icon shows some information about your device id
  • ALT+Click on the battery icon shows the health of your laptops battery
  • ALT+Click on the maximize icon in the title bar restores the old behavior of Mac OS X to maximize the window to the desktop and not going fullscreen
  • ALT+Click on the notification icon in the menubar toggles “Do not disturb” mode for notifications

If you know more, please leave a comment because:

56833531

Archiving OS X Mavericks tags (and other data) with git

25-Oct-13

For the last 6 months i’ve been archiving all my paper work (OCR’ing and than trashing it) to a personal documents repository.

There are some document managers out there but every single one felt like overkill to me, so i just stick to a pretty simple directory structure which is enough for me.

Although i need those documents across devices, i didn’t want to use a cloud service to sync them. git does a pretty good job here.

With Mac OS X Mavericks comes a great new feature: Tagging. Certainly we’ve all used tags somewhere on the internet and i really like this kind of taxonomies. It’s way better than a fixed folder structure.

So, i can now tag all my documents without the need for an external program.

But what about sync? Those tags are stored in the extended file attributes of the Mac OS X filesystem (along with other stuff, for example if the file has been download from the web or email). git does not include those extended attributes in a repository so they will be lost.

xattr to the rescue. xattr can dump all extended attributes for all files in a directory and also can write them back.

I use the following pre-commit hook to dump all extended attributes of my archive to a file named .metadata

#!/bin/sh
 
xattr -lrx . > .metadata
git add -f .metadata

This can be a problem if only tags are modified as nothing will be committed. This can be handled by an empty commit:

git commit --allow-empty -m "New Tags

To restore them i use the following post-merge hook which is also executed after a pull (i’m pretty much doing only pulls on this repository anyway).

#!/usr/bin/env ruby
# Be careful, this can be something you don't want:
# strip all existing extended attributes
system("xattr -cr .")
 
pattern_header = /([^\0]+): (.+):/
pattern_data = /\d{8} (.+) +\|.+\|/
 
data, current_file, current_attribute = '', nil, nil
 
File.readlines('.metadata').each do |line|  
  # collect hex data
  if(m = pattern_data.match(line) and current_file)
    m = pattern_data.match line
    data += m[1].to_s.strip if m and m[1]  
  # starting hex data for a new file
  elsif(m = pattern_header.match(line))
    # we have some data for the current file
    if current_file and data != ''
      system("xattr -wx #{current_attribute} #{data.gsub(/ /, '')} \"#{current_file}\"")
    end   
    data, current_file, current_attribute = '', m[1], m[2] 
  elsif current_file   
    m = pattern_data.match line
    data += m[1].to_s.strip if m and m[1]  
  end
end

This hook is pretty simple and one can surely think of better ways for storing (and / or parsing) the data and add some error handling, but this works quite well for my purpose.

This hook also stores every extended attribute. If you’re only interested in meta tags, than only sync the “com.apple.metadata:_kMDItemUserTags” attribute.

Mac OS X Lion loses network connection after sleep

05-Jan-12

Sleep related problems have never been a problem for me with OS X (at least the sleep of the machine) since Lion.

Sleep works perfectly fine but after wake my machine has no internet connection anymore, at least it looks like this. It’s only domains that aren’t resolved anymore. It also affects wired and wifi networks. There are a lot of threads in the Apple forums that blame USB drives, Optical drives and the like but this sounds a bit like voodoo.

I found the following working solution:

Edit “/System/Library/LaunchDaemons/com.apple.mDNSResponder.plist” like so:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
	<key>Label</key>
	<string>com.apple.mDNSResponder</string>
	<key>OnDemand</key>
	<false/>
	<key>UserName</key>
	<string>_mdnsresponder</string>
	<key>GroupName</key>
	<string>_mdnsresponder</string>
	<key>ProgramArguments</key>
	<array>
		<string>/usr/sbin/mDNSResponder</string>
		<string>-launchd</string>
		<string>-AlwaysAppendSearchDomains</string>
		<string>-DisableSleepProxyClient</string>		
	</array>
	<key>MachServices</key>
	<dict>
		<key>com.apple.mDNSResponder</key>
		<true/>
	</dict>
	<key>Sockets</key>
	<dict>
		<key>Listeners</key>
		<dict>
			<key>SockFamily</key>
			<string>Unix</string>
			<key>SockPathName</key>
			<string>/var/run/mDNSResponder</string>
			<key>SockPathMode</key>
			<integer>438</integer>
		</dict>
	</dict>
	<key>EnableTransactions</key>
	<true/>
</dict>
</plist>

and relaunch the mDNSResponder like so:

sudo launchctl unload -w /System/Library/LaunchDaemons/com.apple.mDNSResponder.plist 
sudo launchctl load -w /System/Library/LaunchDaemons/com.apple.mDNSResponder.plist

This fixes to things: The domain resolution described here and the 2 hourly automatic wake from sleep described here.

Update:

It seems that fixed the problem just for that one time. To fix it every wake i use “SleepWatcher” by . Installed as said in the read me, save this file somewhere as restart_mDNSResponder

#!/bin/bash
killall -HUP mDNSResponder

and copy this

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
        <key>Label</key>
        <string>de.bernhard-baehr.sleepwatcher</string>
        <key>ProgramArguments</key>
        <array>
                <string>/usr/local/sbin/sleepwatcher</string>
                <string>-V</string>
                <string>-w /path/to/restart_mDNSResponder</string>
        </array>
        <key>RunAtLoad</key>
        <true/>
        <key>KeepAlive</key>
        <true/>
</dict>
</plist>

to /Library/LaunchDaemons/de.bernhard-baehr.sleepwatcher-20compatibility.plist.

and execute

sudo launchctl load -w /Library/LaunchDaemons/de.bernhard-baehr.sleepwatcher-20compatibility.plist

This did the trick for me.

XML / XSD Schema validation on Mac OS X

16-Jan-09

I found no fancy graphical xml validator on OS X, but this isn’t a problem.

OS X includes libxml which comes with xmllint.

To validate a xml file against a schema:

xmllint --noout --schema sitemap.xsd sitemap.xml

3 days with Linux

08-Feb-08

Since Tuesday i installed Debian Linux 4 times on my new Dell Vostro 200.

The choice of hardware was kinda stupid. I thought, well this thing is not a special thingy but plain standard. Well, seems, it isn’t.

The first setback was, that the Debian installer booted from CD-Rom but didn’t recognize it afterwards. Yippie… I had to change the SATA Bios settings from IDE to RAID which means in reality, to AHCI. 2 things changed: Debian can be installed from CD-Rom and the dualboot Windows went nuts, i.e. crashed with a BSOD, even in safe mode. Solution to that was first switching back to IDE mode, installing some Intel driver for RAID thingies (really, there’s no raid in the machine… *sigh*), switch back et voila.

Next thing: The ethernet controller was to new. It’s kinda e1000 but not yet supported in the current testing kernel. The driver can be downloaded at intels site. I’ve chosen to skip network while installation and downloaded a full image. If you want to install from a netinstall image and have no 2nd nic at hand, here you’ll find a precompiled module. The blogs seems well written, but i wouldn’t call the Vostro a bunch of crap. The thing is very low noise, with Windows XP rock solid (at least at my workplace {i actually have two of them, at work and now at home}) and i appreciate the Dell pickup service. Another great howto is presented at the Ubuntu forums.

The next closed source thing i installed where the ATI drivers from here without a problem.

The things that lead to multiple reinstalls where the decision between KDE and GNOME. I just wanted to test them and didn’t want to purge every single package afterwards. In the end i went for GNOME.

So now i have a Desktop with the preinstalled Vista on a one partition and my new all day Debian system on a fully encrypted LVM partition. The later one was really no big deal to create with the Debian installer. The whole filesystem is encrypted except a boot partition and a relatively big space which i wanna spent on virtual machines.

prego stated that i should spent some energy into compiz. I already are accustomed to continuous zoom in the whole desktop, some nice effects and semi transparent windows through Mac OS X, for that to say, but i didn’t want to add non “official” repositories. In the end, i give it a try and followed the instructions here and used the instructions for the xorg.conf from here without that Xgl thingies. What can i say: It works and looks great. The wobbling windows are hilarious :D

For my photo collection i already installed digiKam, which is a great tool.

Next steps are migrating my email from Apple Mail.app to a local IMAP server. Anyone suggestions which email client to use?

A friend tried to convince me several times to reinstall my Macbook for good but i don’t want to. Things used to work and broke with an OS update. And no, i’m not using *any* of the OS X system hacks. I used to be able to upgrade from release to release (hell, the iMac made it from 10.3.8 to 10.5.1 without a problem) and all of sudden i’m back in windows times: Upgrade and you’re doomed. Suck my dick… I don’t wanna go this path ever again. And then there the recent developments with Apple. I’ve been wearing a t with “Think different” know for about 5 years, i always like their products, the integration of Unix and eyecandy. But the apps are getting worse with every new release the last months. Apples behaviour to make you pay for a simple software upgrade (sarbane oxley my ass…, i’m expecting the first bugfix to be payed because the OS is no abo related model). OS Xs unablity to encrypt the whole volume (it can encrypt your home folder in some silly image file) without external tools (recently, Truecrypt can do this.

Stop. Must… breath… again.

In the end, i think three days without much sleep were well spend.

As before, i’ll keep you updated, if you like :)