Mac: Run Script before or after Wake from Sleep

I have a few scripts that I want want my macbook to run just before I put it to sleep (by simply closing the lid).

To achive this I did the following:

  1. I installed sleepwatcher via brew
    brew install sleepwatcher
  2. Then I copied the launchd files to the ~/Library/LauchAgents directory
    cp /usr/local/Cellar/sleepwatcher/2.2/de.bernhard-baehr.sleepwatcher-20compatibility-localuser.plist ~/Library/LaunchAgents
  3. I restarted my Macbook and created the ~/.sleep script which contains the commands that will run before sleep.. (You could also create a ~/.wakeup script that runs when the mac wakes up.)

Source: EchoDitto Labs, Stack Overflow

How to install Huawei e173 on Mac OS Lion

I live in Sweden and bought a Huawei e173 from the Swedish operator Telia. The only problem is that the 3G modem came with drivers and software for Snow Leopard (Mac OS X 10.6).

To start off, I installed the modem on a windows machine and disabled the PIN-code on the simcard. I personally get quite annoyed when I have to enter a PIN-code everyone I connect a 3G modem..

Next, I downloaded the drivers on my own from mobinil.com, installed them and configured the modem with the following settings:

Dial: *99#

Vendor:Generic

Model: GPRS (GSM/3G)

APN: online.telia.se

Note that the APN is different on every carrier. Just Google it…

How to force TotalTerminal to always display on top of the dock

I have been using TotalTerminal for a while now. But since the latest 1.1.1 the visor is displayed under the dock. (I have my dock on the left side of my screen) This is both annoying and renders the TotalTerminal useless.

This is all due to a bug fix in 1.1.1. There is a way to fix this issue.

Open a new terminal.app window and enter the following line:

defaults write com.apple.Terminal TotalTerminalVisorWindowOnHighLevel -bool YES 

Restart Terminal.app with TotalTerminal.

The TotalTerminal visor is now shown on top of the dock.

Source: GetSatisfaction

Ejecting USB drives takes two tries with CleanMyMac

Some time ago I found that when I tried to eject any external drives  from my Mac it always failed on the first try, but succeeded on the second.

This is very annoying, as I’m using alfred to speed up pretty much every command on my Mac. So basically I had to type “eje” (the start of the Eject command) two times instead of one..

It turned out that CleanMyMac checked the drives as they where being unmounted, thereby locking the drive. So I disabled these settings and voila, everything worked.

Linked: How to Ensure Ethernet Connects Before AirPort on Your Mac

Some time ago I found this great blog-post about how to prioritize the Ethernet connection over Wi-Fi. In my case this is when I’m at home.

Sometimes, your Mac will connect to a janky Wi-Fi network. The connection is slow or you’re on the other side of a lead wall and you’re getting a really poor signal. When you finally find an Ethernet jack to plug into, you may notice you’re still connected to the Wi-Fi network that was giving you problems. This is because your Network Service Order list is out of its proper order to allow the Ethernet to take over when plugged in. Don’t fret, we’ll show you how to reset the Service Order list on your Mac to ensure that Ethernet takes priority over AirPort.

Read the full post at maclife.com

Mac Tweak: Lose Name When Copying Email Address

I found this the other day! It’s just awesome.

Great post at maclife.com!

If you frequently copy email addresses out of Mail using the Control-click contextual menu. By default, Mail.app includes the user’s real name as well as their email address — that is, until you take a visit to Applications > Utilities > Terminal and type in the following with Mail.app closed: defaults write com.apple.mail AddressesIncludeNameOnPasteboard -bool NO — goodbye, real name, hello email address only!

Source: maclife.com | 6 Secrets of the Mac OS X Mail App

Linked: How To Rebuild LaunchServices to Remove Duplicates from “Open With” Menu

Have you ever used the right-click “Open With” feature in Finder when opening a specific type of file?  While this feature is usually pretty handy, if you install and remove applications on a regular basis there may still be traces of those applications that have been long-gone from your Mac. In this how-to, we’ll show how you can rebuild this list so it remains up-to-date and only shows what you currently have on your hard drive.

Basically you open a terminal and run the following command…And wait.

/System/Library/Frameworks/CoreServices.framework/Frameworks/LaunchServices.framework/Support/lsregister -kill -r -domain local -domain system -domain user

Source