To get the Growl notifications working, I had to add lines to register the 
script with Growl as indicated on the support page for AppleScript on Growl's 
website: 

property blueutilPath : "/usr/local/bin/blueutil"

-- Check the current bluetooth status and turn it on if necessary.
if execBlueutil("") is "0" then
        execBlueutil("1")
        tell application "Growl"
                set the allNotificationsList to ¬
                        {"Bluetooth Setting"}
                set the enabledNotificationsList to ¬
                        {"Bluetooth Setting"}
                register as application ¬
                        "AppleScript - Bluetooth" all notifications 
allNotificationsList ¬
                        default notifications enabledNotificationsList
                notify with name ¬
                        "Bluetooth Setting" title ¬
                        "Bluetooth On" description ¬
                        "Bluetooth has been enabled." application name 
"AppleScript - Bluetooth" icon of file (path to me)
        end tell
else
        -- Set the bluetooth status to what it was before.
        execBlueutil("0")
        tell application "Growl"
                set the allNotificationsList to ¬
                        {"Bluetooth Setting"}
                set the enabledNotificationsList to ¬
                        {"Bluetooth Setting"}
                notify with name ¬
                        "Bluetooth Setting" title ¬
                        "Bluetooth Off" description ¬
                        "Bluetooth has been disabled." application name 
"AppleScript - Bluetooth" icon of file (path to me)
        end tell
end if


on execBlueutil(command)
        set res to do shell script blueutilPath & " power " & command
        if res contains "Error" then
                display dialog res
                quit
        end if
        return res
end execBlueutil

--
Afshin Haghgoo
[email protected]

On July 7, 2013, at 7:48 18, Afshin Haghgoo <[email protected]> wrote:

> Yep the code that you put on the wiki helped.  And the error that I got from 
> running the script was solved by installing the new version and also 
> overwriting the link via "brew link --overwrite blueutil"
> 
> Now all that's needed is a way to connect to pre-linked devices that's listed 
> in the bluetooth app via QS.  But for now I'm immensely grateful for this 
> script!!  Thank   you Patrick for writing this and writing the wikipage to 
> host it!  Very gracious and very much appreciated!  
> 
> Regards,
> Afshin
> 
> --
> Afshin Haghgoo
> [email protected]
> 
> On July 3, 2013, at 8:02 33, Patrick Robertson <[email protected]> 
> wrote:
> 
>> Be sure when you copy/paste the AppleScript that there are no line breaks
>> 
>> In fact, you made me get round to adding the Bluetooth script to the wiki - 
>> the whole reason why I added file attachments yesterday to the wiki… ;-)
>> Check out http://qsapp.com/wiki/Toggle_Bluetooth_(AppleScript)
>> 
>> Seems like the blueutil I originally linked to is an 'old' one. Download the 
>> one linked to on that wiki page and you should be good to go
>> 
>> 
>> On 3 Gorff 2013, at 10:30, Afshin Haghgoo <[email protected]> wrote:
>> 
>>> Thanks Patrick!  Though I'm having trouble getting this script to run 
>>> properly.  I've installed Growl and blueutil, but each time I hit 
>>> 'compile', I get a syntax error message saying, Expected end of line, etc. 
>>> but found “"”.
>>> 
>>> If I try to run the script I get the following error message in the result 
>>> box: error "Usage: /usr/local/bin/blueutil [status|on|off]" number 1
>>> 
>>> You or anyone else know how to resolve this? 
>>> 
>>> -A
>>> 
>>> --
>>> Afshin Haghgoo
>>> [email protected]
>>> 
>>> On July 2, 2013, at 18:30 32, Patrick Robertson 
>>> <[email protected]> wrote:
>>> 
>>>> Unfortunately not at the moment, it would require a new plugin.
>>>> 
>>>> I've been meaning to add a script to the wiki which allows you to turn 
>>>> bluetooth on/off, but haven't got round to it yet. Here it is.
>>>> 
>>>> It requires you to install blueutil (and Growl), but once they're 
>>>> installed, just run the script to toggle Bluetooth on/off
>>>> 
>>>> http://www.frederikseiffert.de/blueutil/
>>>> 
>>>> Script:
>>>> 
>>>> property blueutilPath : "/usr/local/bin/blueutil"
>>>> 
>>>> 
>>>> -- Check the current bluetooth status and turn it on if necessary.
>>>> if execBlueutil("") is "0" then
>>>>    execBlueutil("1")
>>>>    tell application "Growl"
>>>>            set the allNotificationsList to {"Bluetooth Setting"}
>>>>            set the enabledNotificationsList to {"Bluetooth Setting"}
>>>>            notify with name "Bluetooth Setting" title "Bluetooth On" 
>>>> description "Bluetooth has been enabled." application name "AppleScript - 
>>>> Bluetooth" icon of file (path to me)
>>>>    end tell
>>>> else
>>>>    -- Set the bluetooth status to what it was before.
>>>>    execBlueutil("0")
>>>>    tell application "Growl"
>>>>            set the allNotificationsList to {"Bluetooth Setting"}
>>>>            set the enabledNotificationsList to {"Bluetooth Setting"}
>>>>            notify with name "Bluetooth Setting" title "Bluetooth Off" 
>>>> description "Bluetooth has been disabled." application name "AppleScript - 
>>>> Bluetooth" icon of file (path to me)
>>>>    end tell
>>>> end if
>>>> 
>>>> 
>>>> on execBlueutil(command)
>>>>    set res to do shell script blueutilPath & " power " & command
>>>>    if res contains "Error" then
>>>>            display dialog res
>>>>            quit
>>>>    end if
>>>>    return res
>>>> end execBlueutil
>>>> 
>>>> 
>>>> 
>>>> 
>>>> On 3 Gorff 2013, at 09:17, Afshin <[email protected]> wrote:
>>>> 
>>>>> Hi all, 
>>>>> 
>>>>> I'm wondering if there's a way to connect to a bluetooth device, i.e. 
>>>>> iPhone, via QS?  
>>>>> 
>>>>> Thanks! 
>>>>> -Afshin
>>>>> 
>>>>> -- 
>>>>> You received this message because you are subscribed to the Google Groups 
>>>>> "Quicksilver" group.
>>>>> To unsubscribe from this group and stop receiving emails from it, send an 
>>>>> email to [email protected].
>>>>> To post to this group, send email to 
>>>>> [email protected].
>>>>> Visit this group at http://groups.google.com/group/blacktree-quicksilver.
>>>>> For more options, visit https://groups.google.com/groups/opt_out.
>>>>>  
>>>>>  
>>>> 
>>>> 
>>>> -- 
>>>> You received this message because you are subscribed to a topic in the 
>>>> Google Groups "Quicksilver" group.
>>>> To unsubscribe from this topic, visit 
>>>> https://groups.google.com/d/topic/blacktree-quicksilver/dzPo4KBXpH4/unsubscribe.
>>>> To unsubscribe from this group and all its topics, send an email to 
>>>> [email protected].
>>>> To post to this group, send email to 
>>>> [email protected].
>>>> Visit this group at http://groups.google.com/group/blacktree-quicksilver.
>>>> For more options, visit https://groups.google.com/groups/opt_out.
>>>>  
>>>>  
>>> 
>>> 
>>> -- 
>>> You received this message because you are subscribed to the Google Groups 
>>> "Quicksilver" group.
>>> To unsubscribe from this group and stop receiving emails from it, send an 
>>> email to [email protected].
>>> To post to this group, send email to [email protected].
>>> Visit this group at http://groups.google.com/group/blacktree-quicksilver.
>>> For more options, visit https://groups.google.com/groups/opt_out.
>>>  
>>>  
>> 
>> 
>> -- 
>> You received this message because you are subscribed to a topic in the 
>> Google Groups "Quicksilver" group.
>> To unsubscribe from this topic, visit 
>> https://groups.google.com/d/topic/blacktree-quicksilver/dzPo4KBXpH4/unsubscribe.
>> To unsubscribe from this group and all its topics, send an email to 
>> [email protected].
>> To post to this group, send email to [email protected].
>> Visit this group at http://groups.google.com/group/blacktree-quicksilver.
>> For more options, visit https://groups.google.com/groups/opt_out.
>>  
>>  
> 

-- 
You received this message because you are subscribed to the Google Groups 
"Quicksilver" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/blacktree-quicksilver.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to