At work, I quite often listen to music on Spotify or iTunes (because of reasons). However, when you have to leave the laptop for just a bit, I need to both stop the music and lock the computer, and it's a bit inconvenient. So I needed a way to make the computer go quiet and lock itself up nicely.
So I wrote this piece of AppleScript, and bound it to Cmd-L using Quicksilver (yes, I know Alfred folks can do this too, but I'm a QS user). Drop it in ~/Library/Scripts/ and bind a trigger key to it in QuickSilve (or whichever tool you prefer). You will need to also set up Keychain Access so that it has a menu item for locking the screen. This works with OSX 10.10 (Yosemite) at least.
# # Tell our noisy programs to shut up # tell application "Spotify" pause end tell tell application "iTunes" pause end tell # # Lock up the screen without going to sleep. Needs that Keychain Access # is set up properly. # tell application "System Events" to tell process "SystemUIServer" to click (first menu item of menu 1 of ((click (first menu bar item whose description is "Keychain menu extra")) of menu bar 1) whose title is "Lock Screen")
Private comments? Drop me an email. Or complain in a nearby pub - that'll help.
|"Main" last changed on 10-Aug-2015 21:44:03 EEST by JanneJalkanen.|