OS X Mail – Organization Technique

Ok, I have to start by saying that if you don’t have at least Mac OS X Lion (10.7) you are out of luck on this one.

With that out of way I’ll show you how I’ve been organizing my mail. Note that I just started this week, so it’s still a work in progress.

First let me show you my inbox:

My inbox

So close to inbox zero I can taste it!

To get the all the flags to show up, instead of just “Flagged” you need to first flag a few items with different colors in your inbox. Now, you’ll have the reveal arrow next to “Flagged”. Once you have that you can rename them at your leisure by double clicking on the name in the sidebar.

Ok after you have the flags you want to use set up, you will probably want to have an inbox that doesn’t show flagged items. I’ve done this using smart mailboxes.

There is no way to create a smart mailbox (below) by itself with a rule matching “not flagged”, so you have to create two smart mailboxes:
1) Create a Smart Mailbox named “Flagged Messages”. It should have one rule: Mail is flagged
2) Create a second Smart Mailbox named “******** Real Inbox ********”: It should have two rules: Mailbox is NOT “Flagged Messages”, Mailbox IS Inbox. Make sure to select “all” at the top where it says “Contains message that match ALL of the following conditions”.

My Real Inbox Smart Mailbox Settings

Now I only look at my smart mailbox “******** Real Inbox ********”. When I flag an item in here it disappears from my inbox and will show up in the one of the “Flagged” sections shown at the top. A caveat here is that for some reason the smart mailbox doesn’t update until you click another mailbox, then go back to the “Real Inbox”. I believe this could be a feature (just in case you accidentally use the wrong flag, you can change it before it disappears from the mailbox).

The last step for me (so far), was to set up rules for automatically processing mail as it came in. An example rule I use is “Notes to self”. I do this all the time and is probably a habit I won’t break soon. It gets my attention and is easy to do. This rule is simple: From and To are me, make sure you select “If all of the following conditions are met”.

Make sure to select All instead of Any!

One other rule I use often is my “Awaiting Reply” rules. The way I use these is whenever I send an email that I know I want a reply to, I BCC myself. This rule finds messages BCC’d to myself and automatically flags them. This rule says if “To” does NOT contain my email address, and “From” does contain my email address, then flag it. This works because rules are only applied to incoming messages, so it won’t flag messages in your sent folder, only things that are BCC’d to yourself.

Again, make sure to select All instead of Any!

Ok, I hope someone finds this helpful. If you any have questions or suggestions feel free to comment.

UPDATE (9/25/12, 6 months in): In OS X 10.8 if you go to Mail’s Preferences-> General, you can set it to use the “Real Inbox” for the “Dock unread count” and for “New message notifications”.

Also, I definitely recommend setting up a time each day (or every few days, once a week, etc) to make sure you go through your flagged messages. This ensures you keep up on everything and keeps the flagged messages mailboxes manageable. Set a reminder on your calendar, or use Reminders, but do something to make sure you go though them. This system works pretty well once you get it down. It keeps mail organized and ensures you follow-up when needed.

Mute Optical Output On OS X

This is truely frustrating. Not being able to control the system volume when using optical output I could definitely deal with, IF I could at least mute it. After some Googling I realized this just wasn’t going to happen – at least not without some creative thinking. This solution is not exactly elegant, but, it does work.

I had recently installed Plex which installed SoundFlower. SoundFlower allows you to send all system output to an application for processing (normally, to record or send audio to another computer/device). I don’t use it at all though, so as I expected activating this effectively muted my audio. If you do use it, well, you may need to figure out another way to do this.

So the first step here is if you don’t have SoundFlower installed, go grab it and install it. Now, I like everything to be controled via the keyboard, but if you don’t care about this then don’t worry about the rest of this post. You can change the audio output via the sound menu in your menubar by holding down option when clicking on it.

If you want to control this with a key command, then here goes.

First download this: SwitchAudioSource. I put it in /usr/local/bin, but thats up to you.

Next I wrote a simple Applescript to execute the command. Applescript editor is located at “/Utilities/Applescript Editor”.

If you plan to use Growl notifications, just run this Applescript first, you only need to run it once to register the notifications we’ll be using.

tell application “GrowlHelperApp”
set appName to “System Preferences”
set notificationName to “Sound Muted”
set notifs to {“Sound Muted”, “Sound Un-Muted”}
register as application appName all notifications notifs default notifications notifs
end tell

Next up, save the following script somewhere:

set curOut to (do shell script “/usr/local/bin/SwitchAudioSource -c”)
if (curOut = “Built-in Output”) then
do shell script “/usr/local/bin/SwitchAudioSource -s ‘Soundflower (2ch)’”
set notificationName to “Sound Muted”
set growlString to “Muted”
my pause_itunes()
do shell script “/usr/local/bin/SwitchAudioSource -s ‘Built-in Output’”
set notificationName to “Sound Un-Muted”
set growlString to “Un-Muted”
my play_itunes()
end if

tell application “GrowlHelperApp”
set appName to “System Preferences”
notify with name notificationName application name appName title notificationName description growlString
end tell

on pause_itunes()
tell application “Finder” to get (every process whose name is “iTunes”)
if result is not {} then — only update when iTunes running
tell application “iTunes”
if player state is playing then
end if
end tell
end if
end try
end pause_itunes

on play_itunes()
tell application “Finder” to get (every process whose name is “iTunes”)
if result is not {} then — only update when iTunes running
tell application “iTunes”
if player state is paused then
end if
end tell
end if
end try
end play_itunes

As you can see I added a little more to this. The basic stuff is just the do shell script calls to SwitchAudioSource. I added Growl notifications to tell me when this runs, as well as checking with and pausing/playing iTunes when I mute/unmute.

I run this script with a keyboard command thanks to the excellent application Proxi from Griffin. You could even just save it as an application and keep it in your dock if that suits you.

Disclaimer: There is almost certainly a more elegant way to do this, namely it can almost certainly all be accomplished via just the command line, but getting it working in Applescript was the fastest way for me to do it. This runs in less than a second under heavy load on my system, so, it’s a not a problem for me.

iTunes Sleep Timer – With Fade Out Applescript

I like to listen to music or an audiobook as I fall asleep, but don’t want it to continue playing all night, so I put together this little script to implement an iTunes “Sleep Timer”. It also fades the volume down which makes it very difficult to notice and seems to help falling asleep (could be all in my head though).

How it works: When run it asks how many minutes you want to wait before “going to sleep”. It then waits until “fade_for_minutes” minutes (default is 10) less than the time you specified and starts to fade out iTunes. It pauses after the fade completes, then restores the volume to the setting it was started with.

Run at: 10:00pm
Sleep time: 60 minutes
fade_for_minutes: 10 minutes
initial volume: 100 (iTunes volume ranges from 0 to 100)

At 10:50 fade_sound will start running. It will decrease the iTunes volume by 1 every 6 seconds ((fade_for_minutes*60)/initialVolume).
At 11:00 it will pause the currently playing track, reset the volume to 100, and quit itself.

You can either try to copy/paste the script below in to Applescript Editor, then save as an application and be sure to check off “Stay Open”, or you can download the Application.

property lastSleepLength : 5
property fade_for_minutes : 10

global endTime, initialVolume

on idle
-- Wait until fade_for_minutes before the end time
-- Then call fade_sound which will fade the sound, pause itunes, and reset the volume
set curTime to current date
if ((curTime + (fade_for_minutes * 60)) ≥ endTime) then
my fade_sound()
quit me
end if
return 1
end idle

on run
set endTime to (current date) + getSleepLength()
tell application "iTunes" to set initialVolume to sound volume

on error number -128
-- user canceled
quit me
end try
end run

on fade_sound()
set timeBetweenDecreases to ((fade_for_minutes * 60) / initialVolume)
repeat with i from 0 to initialVolume
delay timeBetweenDecreases
tell application "iTunes" to set the sound volume to (sound volume) - 1
end repeat
my iTunesReset()
end fade_sound

-- Pause iTunes and reset volume
on iTunesReset()
tell application "Finder"
if process "iTunes" exists then
tell application "iTunes"
if player state is playing then
end if
set the sound volume to initialVolume
end tell
end if
end tell
end iTunesReset

-- gets the amount of minutes till we go to sleep
on getSleepLength()
set dialogResult to display dialog "How many minutes till we go to Sleep?" default answer lastSleepLength
if text returned of the dialogResult is not "" then
set sleepLength to text returned of dialogResult as number
exit repeat
end if
end try
end repeat

set lastSleepLength to sleepLength

return (sleepLength * 60) -- Return in seconds
end getSleepLength

SizeUp – Resize/Position Windows Using The Keyboard

I’ve posted a few scripts I’ve written to solve some window placement issues on OS X (especially when removing an external display). I actually haven’t been using my scripts as much recently since I found this application. Put simply: it allows you to move and position windows using the keyboard. Check out the web site for full details including a video of it in action. At $13 for a license, it’s a no brainer, give it a try: SizeUp

iTunes Won’t Play Songs OS X Fix

I was just playing around with the Boxee Beta and it hung. I force quit it, and subsequently tried to play a song in iTunes. It wouldn’t play. I tried playing a new song and took note: the time didn’t move from 0:00, the song information was scrolling at the top, and there was a speaker icon next to the song. Yes, the volume was up. Quitting iTunes and reopening it didn’t fix it (tried a few times).

So, I opened up Activity Monitor and did some quick searches to see if I could find something related to iTunes, Boxee, and Sound. Anyway, there is a process called coreaudiod – the core audio daemon. Force-quit that (requires admin privileges) and boom! iTunes works again.

Restore Previous Display Window Positions AppleScript

This AppleScript is sort of a hack to restore window positions after removing/adding an external display, similar my other script to move all windows to the main screen. You should run it before you disconnect the display, then again when you reconnect it. It’s customized for my environment right now, so you’ll need to look through the code a bit to customize it. I have this saved as an application in my Applications folder for quick launching with Spotlight.

property numFFWindows : 0
property FFPos : {}
property FFSize : {}
property iTunesPos : {}
property iTunesSize : {}
property iCalPos : 0
property iCalSize : 0
property AdiumContactsPos : 0
property AdiumContactsSize : 0
property AdiumIMSize : 0
property AdiumIMPos : 0
property OFPos : 0
property OFSize : 0

display dialog "Set Window Position or Save Window Position?" buttons {"Restore", "Save"} default button "Restore"
set theResult to result

tell application "System Events"
    if (button returned of theResult is "Restore") then
        -- Restore Settings
        if (numFFWindows > 0) then
            tell process "Firefox"
                repeat with i from 1 to numFFWindows
                    set position of window i to (item i of FFPos)
                    set size of window i to (item i of FFSize)
                end repeat
            end tell
        end if
        if (iTunesPos is not {0, 0}) then
            tell process "iTunes"
                set position of window 1 to iTunesPos
                set size of window 1 to iTunesSize
            end tell
        end if
        if (iCalPos is not {0, 0}) then
            tell process "iCal"
                set position of window 1 to iCalPos
                set size of window 1 to iCalSize
            end tell
        end if
        if (OFPos is not {0, 0}) then
            tell process "OmniFocus"
                set position of window 1 to OFPos
                set size of window 1 to OFSize
            end tell
        end if
        if (AdiumContactsPos is not {0, 0}) then
            tell process "Adium"
                set position of window "Contacts" to AdiumContactsPos
                set size of window "Contacts" to AdiumContactsSize
                repeat with i from 1 to (count windows)
                    if ((window i) is not (window "Contacts")) then
                        set position of window i to AdiumIMPos
                        set size of window i to AdiumIMSize
                    end if
                end repeat

            end tell
        end if

        -- Save Settings
        tell process "Firefox"
            set numFFWindows to count windows
            set FFPos to {}
            set FFSize to {}
            repeat with i from 1 to numFFWindows
                set end of FFPos to (position of window i)
                set end of FFSize to (size of window i)
            end repeat
        end tell
        tell process "iTunes"
            set iTunesPos to position of window 1
            set iTunesSize to size of window 1
        end tell
        tell process "iCal"
            set iCalPos to position of window 1
            set iCalSize to size of window 1
        end tell
        tell process "OmniFocus"
            set OFPos to position of window 1
            set OFSize to size of window 1
        end tell
        tell process "Adium"
            set AdiumContactsPos to position of window "Contacts"
            set AdiumContactsSize to size of window "Contacts"
            set AdiumIMPos to {}
            set AdiumIMSize to {}
            repeat with i from 1 to (count windows)
                if ((window i) is not (window "Contacts")) then
                    set AdiumIMPos to (position of window i)
                    set AdiumIMSize to (size of window i)
                end if
            end repeat
        end tell
    end if
end tell

College Ramblings…

My Bachelors Degree in Computer Science

My Bachelors Degree in Computer Science

(I have a bunch of posts I have started but not finished. So I’m going to start posting them. Some of them may not best, but I’d like to get them cleared out. Here’s my oldest post – draft dated 10/16/2007, finishing it up today.)
Please Note: This is a rambling.

So I have my Bachelors degree in Computer Science. This is great, but my thoughts about it really boil down to this: big deal. I have learned a decent amount throughout college in regard to my major, no doubt about it. But I believe I have missed many more opportunities in the process such as:

  • (Indie) Software development
  • Other Business – this is sort of a big list

I really have not progressed in my knowledge of OS X specific development, even though I finished my BS 1.5 years ago. I can blame many, many things for this, and a post about this is coming up soon. The biggest loss here I think is lost experience-time on the platform. If I am not able to make it on my own with OS X software development, I’d at least like to work for a Mac software company. I have done some development on Windows, but at school and at EMC I work exclusively on Linux. In terms of business development, I’ve made only moderate gains where I believe larger gains should be possible, as well as let a few entire business ideas not see the light of day because “I don’t have time”.

My biggest gains from going to college:

  • Friends/Contacts
  • Ideas
  • Some maturation(I’ve been told this is disputable though)
  • It was fun… Lots of fun
  • I learned a few things too
  • I don’t plan to expand on this too much. I am happy I went to college, and to have earned my degree. That being said, I just sometimes wish I had been able to spend my time on other things. I believe many of the required courses outside of my major were a HUGE waste of my time. You can give me the “it makes you a well rounded person” BS all you want, but I believe a dedicated course on “Software Engineering” or “Debugging and Performance Optimization”, beats out “Philosophy in Film” in terms of usefulness by a nearly infinite amount. Or how about a course I would have loved: “Mac OS X Software Development” – I tried to do this as a directed study for a project sequence in late 2007, alas the proposal fell on deaf ears and I instead went with “Internet and Web Systems” (read: HTML, CSS, and JavaScript, you know things I had been doing since I was 13).

    Yada, Yada, Yada

    The experiences and friends gained throughout my college years are priceless to me (Should I count the student loans?) – and having the degree looks good on the resume if I need it. I hope I don’t though, I don’t believe that I am meant to be a 40+hr/week worker. I love running my own business(es) and hope to continue to do so. I look forward to sharing my escapades in starting a few new ones with everyone this year. Here’s to 2009.

OS X Memory Issues

With Activity Monitor and the Finder open, and, a few background apps (Remote Buddy, Proxi, and PTHPasteboard). I had just closed all other apps: Mail, FireFox, iTunes, PandoraBoy, Adium, iCal, probably a few others.

With 3GB Physical RAM in this system, I was left with 750MB free:

This, is no good.

Update (12/29/09): I finally googled this, no idea why I waited so long. Anyway, Mac OS X: Reading system memory usage in Activity Monitor.

Make Everyday The Middle Of The Week in iCal

I prefer using iCal in “Weekly” view mode. My problem with this mode though is that once you get towards the end of the week, you will not see what is coming up the next day(s) without explicitly switching to the next week – surely we can fix this?

What I wanted was to be able to see today, maybe the day before, and the next 5 days. After all, the past 6 days is seldom useful, but it’s nice to know what is happening the next 3-5 days.

This script will do this for you. It does so by changing the “Start Week On” preference in iCal everyday at midnight.

To reiterate, my preferred setting is to have the SECOND day of the week be TODAY. If you’d prefer another day, change the number 5 in the script below(4 = 1st day, 5 = 2nd day, etc).

The Applescript to perform this is:

-- Quit iCal if it is open
tell application "System Events" to set isiCalOpen to count ¬
	(every process whose creator type is "wrbt")
if (isiCalOpen is 1) then tell application "iCal" to quit

-- Make the change
do shell script ¬
	"defaults write com.apple.ical \"first day of week\" -int " & ((((weekday of (current date)) as integer) + 5) mod 7)
delay 2
-- Open iCal
tell application "iCal" to activate

Open in Script Editor

If you’d like to have this script run everyday, you may want to check out the excellent Launchd editor, Lingon. My LaunchAgent file can be downloaded here: iCal LaunchAgent.

‘batch’ broken in Mac OS 10.5 (Leopard) – SOLVED

Give it a try and let me know if you agree… Quick test:
$ batch now
> ls
job 1 at Wed May 14 14:02:27 2008

$ atq
778240 Fri Jan 18 09:03:00 2002


$ batch 17:00
> ls
job 5 at Wed May 14 17:00:00 2008
$ atq
778240 Sat Jul 17 12:39:44 1993

Update: 10.5.3
This doesn’t seem to happen anymore in 10.5.3, but it doesn’t quite seem to work either:

$ at 3:00
> touch /TEST.TEST
job 10 at Sun Jun 1 03:00:00 2008

This was ran at 2:59:30(or so) and as of 3:45:
$ atq
10 Sun Jun 1 03:00:00 2008

Yet, the command did not execute.

Update 9/21/09:

I don’t know how I missed this before, but in the man page for at on OS X, there is the following comment:

Note that at is implemented through the launchd(8) daemon periodically
invoking atrun(8), which is disabled by default.  See atrun(8)
for information about enabling atrun.

Going over to the atrun page shows that you can enable a launch daemon to periodically run queued at and batch jobs. The executiable that does this should be run with root permissions and is located at /usr/libexec/atrun