Toggle Twitter

January 22nd, 2011

I use Twitter. A lot, and almost entirely on my Mac desktop. Over the years, I have switched between many popular client applications, often returning to old favorites when the specific advantages of one outweighs the advantages of another for my current priorities.

The way I use Twitter is to leave one of these client applications running in the background, with all the notification settings set to off. I still check it quite often, but it’s on my terms. If I get deep into concentration working on some bug, chatting with a friend, or or watching a video, I don’t want Twitter interrupting me.

Twitterrific was the first desktop client I used, and I can’t remember whether it was the default choice or if I picked it, but I got in the habit of using the global keyboard shortcut Cmd-Ctrl-T to toggle the window’s visibility. When I tried other Twitter apps, I made a point of setting the preference in that app to match the same shortcut.

Eventually I tried an app that didn’t support a setting for a global keyboard shortcut, so I had to write a script to do it for me. It occurred to me at some point that I could write a single AppleScript to handle the toggling of visibility regardless of which app I was using.

Download “Toggle Twitter”

The script logic is pretty simple: given a list of common Twitter app-names, is one of them running? If so, toggle it. If not, launch it. If you’re using something else, just add it to the list, and it should work perfectly.

I used FastScripts to hook this up to the global shortcut Cmd-Ctrl-T because it matches my historic muscle memory, and well, T is for Twitter.

9 Responses to “Toggle Twitter”

  1. Ron L Says:

    Daniel

    Out of curiosity, what folder do you put the script in? There are several options, and I go back and forth on which one should be used for system-wide scripts via FastScripts.

    Ron

  2. Daniel Jalkut Says:

    Hi Ron – I put all my custom scripts in ~/Library/Scripts, and sort of arbitrarily organize them into folders by theme. For example I have a folder called “Application Shortuts” which is for all the scripts I have that simply open a specific app (Cmd-Opt-Shift-W for Safari, for example). I put this Twitter toggler in that folder.

  3. Eric Dobson Says:

    Just another reason I really need to get into AppleScript. I’ll definitely be adapting this to work with other application groups. Thanks for another helpful post!

    -Eric

  4. Ron L Says:

    Thanks Daniel, that works perfectly.

  5. Chucky Says:

    “Just another reason I really need to get into AppleScript.”

    Very mild learning curve. The beauty of the “human language” metaphor AS uses is that it makes it quite easy to take other folks’ code samples, and pretty much understand what they’re doing right off the bat.

    Then you can modify them for yourself, and before you know it, you are semi-proficient in AS.

    The killer app of AS is that it’s readable.

    Coders hate the language, but non-coding power users find much to use there.

  6. David Levine Says:

    Thanks for the post. I never thought about setting the global shortcut to hide and show the app. I use Twitter for Mac and I just set the shortcut to Cmd-Ctrl-T. It makes sense.

  7. Jason Says:

    I don’t understand this. There’s a built in “Hide window” shortcut in OSX, which is (by default) Command-h. Then all you have to do is Command-Tab to it to get it back.

    The one thing this script saves you is not having to command-tab however many times you have running applications for. But what else is more compelling about this that I’m not understanding?

  8. Daniel Jalkut Says:

    Hi Jason – I find it much easier on my brain to think of things like this as toggles. Having to use different keystrokes, possibly getting lost in an unexpected app, these are not things I like to deal with.

    I guess you either see the value or you don’t. I don’t think you’re missing anything, though. If the Cmd-H and Cmd-Tab method works as effortlessly for you, then there’s certainly no benefit for you in using the script. (Aside from the fact that the script will also automatically launch the first Twitter app in the list if it’s not already running).

  9. Eric Dobson Says:

    Jason: I agree with Daniel, it definitely isn’t a big deal for everyone, and you’re not missing anything. For me, I often have so many apps open that the Cmd + Tab method could take a half-dozen keystrokes. I could use LaunchBar and type 3 keystrokes, or I can use this script and only type 1. With muscle memory it will happen instantly without thought or distraction. Not a huge deal, but when I find dozens of such shortcuts and they add up to a couple hundred small tasks each day, it makes a difference.

Comments are Closed.

Follow the Conversation

Stay up-to-date by subscribing to the Comments RSS Feed for this entry.