Jalpuna

Better Keyboard Volume Control For OSX (Especially If You Own An Apogee Duet)

I don't normally post how-to instructions on my blog, but I discovered something really handy and I'm sure it'll be helpful to someone. If your Mac is connected to your stereo (especially if, like me, you own an Apogee Duet), read on to improve the functionality of your keyboard volume keys.

The Apogee Duet is an amazing audio interface for a Mac, and Snow Leopard seems to have built-in drivers for it. I plugged it in and it worked out of the box on my new Mac Mini before I installed anything. Sweet! As a side note before I begin... if you own a Duet and you're hearing a soft static from it, I posted a fix for that here.

One thing that wasn't so sweet about the Duet were the Apple keyboard sound controls and how they worked with it. Pressing a volume key on my keyboard turned the volume up or down by a LOT.

volumekeys

Maybe you're thinking "Rob, your Duet has a giant volume knob! Why would you want to adjust the volume on your keyboard instead?"

Here's why: My hands are on my keyboard as I type this. Why reach for my Duet when I can just tap a button where my hands already are? I find that a keyboard mute button is especially handy to have, but it's also nice to be able to tap a key to turn the volume up or down a little.

A Little.

That's where keyboard controls failed me.

Volume control in OSX is based on a 100 step scale between "0", meaning no sound, and "100" for maximum volume. A tap of the keyboard volume key turns the volume up + 5 or down -5. That can be a pretty big change, especially if you're used to the something like Apogee Duet's volume knob where turning the knob 1 click turns the volume up +1 or down -1.

Ah, but I found a fix.

First, go to System Preferences. Choose "Keyboard". Click the option to "Use all F1, F2, etc. keys as standard function keys."

Next, we're going to create a pair of Applescripts and assign them to the volume keys on the keyboard (F11 and F12). I'm sure there are other ways to do this, but I chose Spark because it was simple and worked perfectly for my needs.

Spark

Once you've downloaded Spark and placed it in your Applications folder on your Mac, launch it, and let's edit some Applescripts and hotkeys!

In Spark, in the File menu, under New Hotkey, select Applescript.

Shortcut: Click the box and select a key on your keyboard.

Name: Name the hotkey/shortcut function you're creating. Let's create a Volume Down hotkey first.

Make sure Source is selected in the box below and then copy and paste the following Applescript code into it:

-- volume down 1 set current_volume to output volume of (get volume settings)

if current_volume is greater than 0 then
set current_volume to current_volume - 1
end if

set volume output volume current_volume

It should look like this (click the pic for a larger view):

Lower the volume

Note that "Repeat Interval" option at the bottom of the pic above is set to "0". That's something I initially missed. By entering a number in there... say, 100, for example, you gain the option to hold down the key and continue changing the volume. Zero is the default, and it prevents the hotkey from repeating.

Moving on...

It's the same process to create a hotkey to raise the volume.

In Spark, in the File menu, under New Hotkey, select Applescript.

Shortcut: select a key on your keyboard.

Name: Name the hotkey/shortcut function you're creating. This time, we're creating a Volume Up hotkey.

Make sure Source is selected in the box below and then copy and paste the following Applescript code into it:

-- volume up 1 set current_volume to output volume of (get volume settings)

if current_volume is less than 100 then
set current_volume to current_volume + 1
end if

set volume output volume current_volume

It should look like this (again, click it for a larger view):

Raise the volume

Set a Repeat Interval (below the Applescript box) if you want to be able to hold down the hotkey to keep turning the volume up rather than having to press it multiple times. I find 100 ms to be a good setting. I missed that option initially, so it's set to "0" in the image above, meaning no hotkey repeat.

If you find that + or - 1 isn't enough of a change in volume for you, you can always edit your Spark hotkey settings and change 1 to 2. [Update: after using these settings for a while, I did decide to change it to +/- 2 instead of 1. Again, that was an easy change to make in Spark]

And, hey, as long as we're setting up hotkeys, let's set up those iTunes keyboard function keys too.

volumekeys

In the File menu, select New Hotkey and click iTunes and repeat the process for each hotkey, except this time, instead of adding Applescript code, we're choosing options Spark already has built in.

iTunes options

Note the mute key in that list. You can assign the mute key on your keyboard to iTunes this way, but I wanted my keyboard's mute key to mute everything rather than just muting iTunes, so I set that button up by going into Spark's File menu and choosing New Hotkey, then System. Then, click Actions in the popup window and you'll find this menu:

system options

OK! We're done. Enjoy your improved keyboard!

P.S. All of my Apogee Duet/Maestro posts are here.

::::: | Thursday, Jan 14 2010 at 12:58 PM
::::: |


Comments:


Justin von Oldershausen said:

Thank you so much for this tutorial! I now have volume controls on my windows keyboard.

::::: | September 1, 2010 8:18 PM


John said:

THANK YOU!

After searching for many hours to find a solution for non apple keyboards i found this tutorial and it's the only one that worked!

::::: | January 7, 2011 1:17 PM


Rob said:

You're welcome!

I'll be honest: I assume there is a better way than what I've described here, and I'd really like to find it... but until then, this works well.

Cheers!

::::: | January 7, 2011 1:21 PM


jaap said:

This is better:

-- get the current setting
set curVolume to output volume of (get volume settings)
-- work out the new setting
if curVolume set newVolume to curVolume + 10
else
-- can't go over 100
set newVolume to 100
end if
-- and apply it
set volume output volume newVolume

::::: | January 23, 2011 7:45 AM


sean said:

Did you know there is a much easier way to do this. No script, no changes to the system. Simply hold SHIFT + ALT while using the volume keys. This changes the increment to smaller tick values. About 4 or 5 ticks per volume block. Once I found that I was happy! :-)

::::: | September 29, 2011 4:10 PM


Rob said:

Sean, you're right. I should have noted that above. I really hate certain multiple key combinations. Since my left hand is on the left side of my keyboard and my mouse (a Magic Trackpad these days) is on the right, I hate key combos that involve the right hand side of the keyboard.

Command C? Sure.
Command G? OK.
But I hate reaching for a key combo to hit those F10, F11 and F12 keys. Drives me nuts!

::::: | September 29, 2011 10:33 PM


Zen5656 said:

You are the man! Thanks for this :) Maybe mention that you have to disselect the original key funktion of F11 and F12 before in the system preferences -> keyboard. Normally used for desktop and dashboard. Otherwise you cannot select it in spark. Sad that you cannot see the volume bar then and that you cannot chance overall range. I can only go up to bar 4 with my krk monitors, otherwise my ears will die ;) So it is good to have a quick access to a level between the 4 dots.

Thanks again!

::::: | February 13, 2012 3:43 PM


Rob said:

Zen, I'm not sure I understand. Desktop and Dashboard are F3 and F4 on my wireless keyboard, not F11 and F12.

::::: | February 13, 2012 3:48 PM


Omar said:

This is awesome.
You are a lifesaver!

Thank you.

::::: | June 14, 2014 12:16 PM


Gavs said:

Thanks!!!

::::: | October 21, 2014 5:04 PM




(won't be published)


Remember?

(you may use HTML tags for style)

Spam Blocker:
Please type the letter "r" in this box


::::: | All Content © 2004-2016
::::: | Jalpuna is hosted by DreamHost