public
Last active

Alfred Adjust Volume Applescript

  • Download Gist
VolumeAdjust.applescript
AppleScript
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69
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

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.

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.