?

Log in

No account? Create an account
Remapping a function key in OS X. - I know it's wonky and I don't care [entries|archive|friends|userinfo]
Kake

[ website | My Website ]
[ userinfo | livejournal userinfo ]
[ archive | journal archive ]

Links
[Links:| Randomness Guide to London | Open Guide to Cambridge | Snake Soup | KakeFlickr ]

Remapping a function key in OS X. [Jan. 5th, 2007|02:08 pm]
Kake
[Tags|]

Can someone tell me how to remap, say, F11 so that whenever I press it, it tells VLC to pause the thing it's playing, regardless of whether VLC is the app currently on top?

(I'm sure I could work out how to do this myself, but it would probably take several hours and involve cursing. So even if you can't answer the question off the top of your head, any suggestions that would set me on the right track would be most welcome.)

Update: 2shortplanks and caramel_betty and frobisher figured it out! Yay!
LinkReply

Comments:
[User Picture]From: rjw1
2007-01-05 02:14 pm (UTC)
applescript?
(Reply) (Thread)
[User Picture]From: sammoore
2007-01-05 03:00 pm (UTC)
I was going to suggest mapping F11 to an applescript which then gives VLC the focus and pauses the track. Presumably if you just wanted it quiet you could map a key to "Mute" which wouldn't of course pause the playing.

Sam
(Reply) (Parent) (Thread)
[User Picture]From: nou
2007-01-05 03:16 pm (UTC)
Yes, that's right — I want to pause the playing, not just mute the sound. The main reason I want this is for use in situations where I really do need to stop and concentrate on something else at very short notice, and if I just press the mute button (or take the headphones off) then I forget I've done it and only notice later that I've lost my place. This is particularly an issue with audiobooks.

How do I map F11 to some applescript? And could you point me to a decent applescript reference? (I'd got as far as “I'll be wanting to use applescript for this, then”, but it's figuring out how that was the part I expected to involve time and cursing.)
(Reply) (Parent) (Thread)
[User Picture]From: sammoore
2007-01-05 04:07 pm (UTC)
You should be able to do something under

System Preferences -> Keyboard and Mouse -> Keyboard Short Cuts

As for Applescript, I have had a small play but I only know what is theoretically possible, not how to do it.

Resources can be found at:


http://www.apple.com/applescript/


and in the documentation installed with OSX.

Hope that helps.
(Reply) (Parent) (Thread)
[User Picture]From: pozorvlak
2007-01-05 04:12 pm (UTC)
Are you aware of Mac::Glue?
(Reply) (Parent) (Thread)
[User Picture]From: nou
2007-01-07 05:04 pm (UTC)
I was vaguely aware of it. I've sort of never trusted Perl on OS X for some reason, most likely because I've never really tried it. I probably should.

I've sorted the applescript now though, just need to work out how to make it execute when I hit F11.
(Reply) (Parent) (Thread)
[User Picture]From: caramel_betty
2007-01-05 07:07 pm (UTC)
http://nslog.com/2005/06/26/no_applescript_mute/ looks like an interesting bit of AppleScript for muting play.

http://dicot.biol.mcgill.ca/~bvalin/salling/salling.html seems to be recommended as a way of pausing/playing in VLC. Though it seems to care about phone-calls, you could probably extract the bit of code that actually does the toggling. (Apparently, VLC has no way of telling you if it's playing or not, so it's a toggle, not a pause, IYSWIM.) Not having the ability to read .scpt files, I can't actually understand it, however. :-)
(Reply) (Parent) (Thread)
[User Picture]From: nou
2007-01-07 04:59 pm (UTC)
Apparently, VLC has no way of telling you if it's playing or not, so it's a toggle, not a pause, IYSWIM.

Ooh, that was very useful, thank you! I now know that if VLC is playing, then osascript -e 'tell application "VLC" to play' will pause it.

Now to work out how to make that get executed when I hit F11...
(Reply) (Parent) (Thread)
[User Picture]From: frobisher
2007-01-05 06:39 pm (UTC)
You could maybe specify a keyboard shortcut in the system prefs or perhaps someone's written a plugin for quicksilver (which does this sort of thing for me with itunes)
(Reply) (Thread)
[User Picture]From: nou
2007-01-07 05:12 pm (UTC)
Quicksilver looks interesting. I do feel there must be some way of attaching applescript to a keyboard shortcut without installing anything third-party, though I haven't worked out what it is yet.
(Reply) (Parent) (Thread)
[User Picture]From: 2shortplanks
2007-01-08 10:22 pm (UTC)
Step by step instructions (mainly because I think this is a good idea so I've done it myself now)


  • Open Up Script Editor

  • Type "tell application "VLC" to play" into the window

  • Select "File" -> "Save As" from the menu

  • Select "application" from the "file format" drop down

  • Save as "ToggleVLC" in "/Applicaitons"



You should now have a double clickable application in /Applications that will pause/play VLC

Now, to get it to work in quicksilver:


  • Trigger Quicksilver (that's Command-Space on my system, but it depends on how you've got it set up on your system

  • Type Command-; to bring up preferences

  • Ensure that the catalog has been rescanned. To do this either wait ten minutes, or...

    • Click on "Catalog" on the toolbar.

    • Click on "Applications" on the left:

    • Click on the rescan button at the botom that looks like an anti-clockwise arrow


  • Click on "Triggers"

  • Click on the plus icon and select "hotkey"

  • Type enough of "ToggleVLC" to select ToggleVLC, and hit return

  • Double click on "None" next to "Open ToggleVLC".

  • Click on "Edit" to the right of "Hot Key".

  • Type F11



You might need to unbind F11 from Exposé before you can set the trigger correctly. This can be done from the "Dashboard and Exposé" in "System Preferences".
(Reply) (Parent) (Thread)
[User Picture]From: nou
2007-01-09 12:35 am (UTC)
You are a genius. Thank you!

F11 F11 F11 F11 bounce bounce F11 F11
(Reply) (Parent) (Thread)