Skip to content

Instantly share code, notes, and snippets.

@jong
Forked from victorquinn/VolumeAdjust.applescript
Created February 5, 2013 02:30
Show Gist options
  • Save jong/4711642 to your computer and use it in GitHub Desktop.
Save jong/4711642 to your computer and use it in GitHub Desktop.
on alfred_script(q)
set tmp to splitString(q, " ")
set q to item 1 of tmp
if length of tmp is 2 then
set change to item 2 of tmp
else
set change to 10
end if
set current to output volume of (get volume settings)
if q is equal to "mute" or q is equal to "off" then
set current to 0
else if q is equal to "max" or q is equal to "full" then
set current to 100
else if q is equal to "quiet" or q is equal to "soft" or q is equal to "low" then
set current to 15
else if q is equal to "medium" or q is equal to "half" or q is equal to "mid" then
set current to 50
else if q is equal to "loud" or q is equal to "high" then
set current to 85
else if q is equal to "up" or q is equal to "more" or q is equal to "+" then
set current to current + change
if (current > 100) then
set current to 100
end if
else if q is equal to "down" or q is equal to "less" or q is equal to "-" then
set current to current - change
if (current < 0) then
set current to 0
end if
else
if (q as integer > 100) then
set current to 100
else if (q as integer < 0) then
set current to 0
else
set current to q
end if
end if
tell application "Growl" to notify with name "Extension Output" title "Adjust Volume" application name "Alfred" identifier "Volume: " & current description "The volume is now " & current & "/100" image from location "~/Library/Application Support/Alfred/extensions/applescripts/Adjust Volume/icon.png"
set volume output volume current
end alfred_script
to splitString(aString, delimiter)
set retVal to {}
set prevDelimiter to AppleScript's text item delimiters
log delimiter
set AppleScript's text item delimiters to {delimiter}
set retVal to every text item of aString
set AppleScript's text item delimiters to prevDelimiter
return retVal
end splitString
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment