Forked from victorquinn/VolumeAdjust.applescript
Last active
December 16, 2015 12:48
-
-
Save vanrijn/5436724 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | |
set volume output volume current | |
tell application "System Events" | |
set isRunning to (count of (every process whose bundle identifier is "com.Growl.GrowlHelperApp")) > 0 | |
end tell | |
if isRunning then | |
tell application id "com.Growl.GrowlHelperApp" | |
-- Make a list of all the notification types | |
-- that this script will ever send: | |
set the allNotificationsList to ¬ | |
{"Extension Output"} | |
-- Make a list of the notifications | |
-- that will be enabled by default. | |
-- Those not enabled by default can be enabled later | |
-- in the 'Applications' tab of the growl prefpane. | |
set the enabledNotificationsList to ¬ | |
{"Extension Output"} | |
-- Register our script with growl. | |
-- You can optionally (as here) set a default icon | |
-- for this script's notifications. | |
register as application ¬ | |
"Alfred" all notifications allNotificationsList ¬ | |
default notifications enabledNotificationsList ¬ | |
icon of application "Script Editor" | |
end tell | |
tell application id "com.Growl.GrowlHelperApp" 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" | |
end if | |
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
This adds Growl registration and notification fixes for the Alfred v1 Applescript.