Skip to content

Instantly share code, notes, and snippets.

@victorquinn
Last active February 10, 2018 07:26
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
  • Save victorquinn/1794961 to your computer and use it in GitHub Desktop.
Save victorquinn/1794961 to your computer and use it in GitHub Desktop.
Alfred Adjust Volume Applescript
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)
set old to current
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 is equal to "current" or q is equal to "now" or q is equal to "status" or q is equal to "level"
set current to current
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
if (current as integer > old as integer)
set message to "The volume has been increased to " & current & "/100"
else if current is equal to old
set message to "The current volume is " & current & "/100"
else
set message to "The volume has been decreased to " & current & "/100"
end if
return message
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
@bradical
Copy link

This is cool. Thanks! Do you know if the Growl option still works for Alfred 2 style Workflow? Seems to always do Notification Center for me regardless of what I click.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment