Skip to content

Instantly share code, notes, and snippets.

@ludalex
Forked from NoobsArePeople2/gist:5121597
Last active December 27, 2015 19:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ludalex/7377523 to your computer and use it in GitHub Desktop.
Save ludalex/7377523 to your computer and use it in GitHub Desktop.

Requirements

  1. USB Overdrive
  2. A non-Apple keyboard with media keys (or keys you want to make "media" keys). For reference, I'm using a Microsoft Sidewinder X4

Set Up

  1. Plug in your keyboard and install USB Overdrive.
  2. Open USB Overdrive. Click into the Settings tab.
  3. Click the dropdown and select "Any Keyboard, Any Application"
  4. Click the "Scan Next Track" item in the left-hand list. You can also select this key by focusing the USB Overdrive window and pressing the actual key on the keyboard.
  5. In the right-hand column click the dropdown and select "Execute AppleScript".
  6. Paste the following AppleScript:
on is_running(appName)
	tell application "System Events" to (name of processes) contains appName
end is_running

if is_running("iTunes") then
	tell application "iTunes"
		next track
	end tell
else
	tell application "Spotify"
		next track
	end tell
end if
  1. Repeat steps 4 and 5 but select "Scan Previous Track". Paste the following AppleScript:
on is_running(appName)
	tell application "System Events" to (name of processes) contains appName
end is_running

if is_running("iTunes") then
	tell application "iTunes"
		previous track
	end tell
else
	tell application "Spotify"
		previous track
	end tell
end if
  1. Repeat steps 4 and 5 but select "Play/Pause". Paste the following AppleScript:
on is_running(appName)
	tell application "System Events" to (name of processes) contains appName
end is_running

if is_running("iTunes") then
	tell application "iTunes"
		playpause
	end tell
else
	tell application "Spotify"
		playpause
	end tell
end if
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment