Edit Evernote ENML Applescript

This Applescript just sends the currently selected note to the Evernote ENML Editor. Assign it to a hotkey using your favorite hotkey app and it’s a nice little time saver.


tell application "System Events"
set app_name to name of the first process whose frontmost is true
end tell

if (app_name is "Evernote") then
tell application "Evernote"
set noteList to selection
if (count of noteList) = 1 then
set noteGUID to my get_evernote_note_id((item 1 of noteList)'s note link)
set editURL to "http://enml-editor.ping13.net/note?n=" & noteGUID
end if
end tell
open location editURL

else
tell application "Evernote" to activate
end if

on get_evernote_note_id(this_text)
set AppleScript's text item delimiters to "/"
set the item_list to every text item of this_text
set AppleScript's text item delimiters to ""
return item 8 of item_list
end get_evernote_note_id

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()
else
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()
try
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
pause
end if
end tell
end if
end try
end pause_itunes

on play_itunes()
try
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
play
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.

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

    else
        -- 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

MacBook Pro Riser

For about $8 I made the equivalent to the Griffin iCurve/Elevator with PVC pipe.

Original idea was from Instructables. I adjusted for size of the MacBook Pro, and used 1/2″ instead of 3/4″ PVC. 3/4″ seemed far too heavy duty for this.

If you want to make one for your 15″ MacBook Pro I recommend using 1/2″ PVC.

You’ll need the following pieces:

  • 2x 11″
  • 4x 5 1/2″
  • 2x 3″
  • 4x Elbow Joints
  • 4x T-Joints

Assembly is pretty simple. I actually did it right in Home Depot in about 10 minutes.

IMG_1030.jpg

IMG_1031.jpg