Fasand Posted January 23, 2013 Share Posted January 23, 2013 (edited) Here's a little workflow for toggling bluetooth and wifi.Basic usage:bt - toggle bluetooth, see status bluetooth - toggle bluetoothwifi - toggle wifiDownload: https://www.dropbox.com/s/xcka1l6pxt8ibsn/BT%20%26%20Wifi%20Toggle.alfredworkflow (as of 08/03/2014) Important update: The latest version of this workflow uses a new (unofficial) version of blueutil which is a copy of the original source code, only rewritten and compiled (by me) for the latest OS X, that is for the OS X 10.10 beta, too. I am a little worried that by having it compiled for the beta, it won't work for 10.9 and lower but I hope there won't be a problem. If there is, please tell me and I will release a version with the original blueutil.Using: custom version of blueutil (http://www.frederikseiffert.de/blueutil/) Edited August 3, 2014 by Fasand gabamnml, the_salmon_mousse and Domenic 3 Link to comment
apfelartig Posted January 23, 2013 Share Posted January 23, 2013 For me the bluetooth toggle doesn't work. It just opens System Preferences/Bluetooth. Link to comment
Fasand Posted January 23, 2013 Author Share Posted January 23, 2013 For me the bluetooth toggle doesn't work. It just opens System Preferences/Bluetooth. That's weird. For me, it works ok (doesn't open System Preferences). It should actually close them if they're open. It even connects my magic mouse after the second toggle. What OS do you have? (Lion/Mountain Lion) Possibly, if you wait a while, it could work, but if it opens System Prefs there is probably a different problem. ( Btw thanks for reply ) Link to comment
Fasand Posted January 24, 2013 Author Share Posted January 24, 2013 I'm on 10.8.2 I did have a little problem with the disconnection of devices, i.e. when I have my magic mouse connected, the system preferences toggle triggered by applescript doesn't do exactly what I want it to do, so it's actually ran twice just so that it works. This however does not explain why it opens up your system prefs. I am sorry, but I really don't know what the problem is, as I even have the same OS version and it looks like it's acting completely different for you. If I figure it out, I will post it here. Link to comment
rossbennett Posted January 30, 2013 Share Posted January 30, 2013 Good start here, but we need a couple of tweaks. I'm on 10.8.2, with updates, etc. I'm on this last August's MBP 13". The Airport is en1 on it (en0 is the hardline). I hard-coded it in mine for the time-being. I'm really new to Applescript, so I haven't worked out a good scheme to look it up reliably or I'd offer it here.The bluetooth toggle was doing fine at turning it on—but the thing about turning it off, the second "if" evaluation would always find the power off and turn it on. So if off, it was turning it on. If on, it was turning it off, then on. I replaced the two if blocks with "click A" and it's working well now. Link to comment
Fasand Posted January 30, 2013 Author Share Posted January 30, 2013 When I was testing it, I found that if there wasn't the second click, my mouse wouldn't connect again and it caused problems. With the other if, it works with my mouse, however more like a bluetooth "turn off and on" than a real toggle. As for the en1 problem, I understand as I thought I had en1, too at first, but then I found otherwise. I have 10.8.2 on a 2012 MBA, so I have no idea why it's different, but I guess it's not that big of a problem (mostly because there are much better extensions that include wifi toggle). Essentially, I created this mostly so that I don't have to go to the menu bar and connect my mouse, so using this, I just write a short command twice. That is why it doesn't work that well for others and why the wifi toggle is set for en0. I am lazy. Please take this more as a workflow to work with and make it yours, not a good, publicly distributable workflow. I posted it only because I haven't found any similar and because I hoped that someone would get the idea to make something similar, but better and working . To end this pointless self-letter, good luck with this semi-working workflow . Link to comment
chrstn.rchl Posted January 31, 2013 Share Posted January 31, 2013 Hey Dude, I fixed your script. Check this out: http://d.pr/f/L4OONote: I've changed "bttoggle" to "bt". That's shorter for me Link to comment
virus2500 Posted January 31, 2013 Share Posted January 31, 2013 Hi, i changed the wifi apple script to on alfred_script(q) set wifi to (do shell script "networksetup -listallhardwareports | grep -A 1 Wi-Fi | tail -n 1 | cut -b 9-12") if (offset of "On" in (do shell script "networksetup -getairportpower " & wifi & " ")) > 0 then do shell script "networksetup -setairportpower " & wifi & " off" else do shell script "networksetup -setairportpower " & wifi & " on" end if end alfred_script I defined the variable wifi which will grep the wifi interface from networksetup so it shouldn't matter wether your wifi card is en0,en1...en20 I could only test it on my machine so i am not 100% sure it'll work for everyone. Mike Link to comment
Fasand Posted February 1, 2013 Author Share Posted February 1, 2013 A great thanks to all of you for helping out in this little extension. I put your fixes into one and the fixed/updated version is currently up on AlfPT ("BT & Wifi Toggle"). I tried it and all works as it should for me, so good luck with it! Download: http://d.pr/f/ybMT (or AlfPT) Link to comment
wbranson Posted February 15, 2013 Share Posted February 15, 2013 This one isn't working for me. Not sure what the problem is. The wifi toggle works but the bluetooth does not. Gives me a "Failed to toggle bluetooth" error with my bluetooth connections pane displayed. Running brand new MBP with Mountain Lion. Link to comment
getthething Posted February 15, 2013 Share Posted February 15, 2013 Not working for me either. I just get this message: "You cannot control your computer if you turn Bluetooth off at this time as you would lose your input devices." Link to comment
Fasand Posted February 15, 2013 Author Share Posted February 15, 2013 Not working for me either. I just get this message: "You cannot control your computer if you turn Bluetooth off at this time as you would lose your input devices." I haven't encountered this at all, but from what I read I suspect you have the Magic Trackpad. If yes, than this is a system issue, completely unknown to me and I'm sorry, but if Apple hasn't resolved this in quite a long time, I have no chance/idea... If you are not using the Magic Trackpad, than there is a different problem that I am trying to solve right now. If I find something out, I will let you and everybody know. Link to comment
Fasand Posted February 15, 2013 Author Share Posted February 15, 2013 This one isn't working for me. Not sure what the problem is. The wifi toggle works but the bluetooth does not. Gives me a "Failed to toggle bluetooth" error with my bluetooth connections pane displayed. Running brand new MBP with Mountain Lion. Some people before you probably encountered the same problem, yet I still don't really know what the problem is... The worst thing about this is that it works for most people, but for some people with same hardware doesn't ... I added a line that should write out the error when it occurs, so please update the workflow from the link below and when the error occurs, reply here what it says, which could possibly lead to a solution. Download: http://d.pr/f/5pM0 Link to comment
Fasand Posted February 15, 2013 Author Share Posted February 15, 2013 This one isn't working for me. Not sure what the problem is. The wifi toggle works but the bluetooth does not. Gives me a "Failed to toggle bluetooth" error with my bluetooth connections pane displayed. Running brand new MBP with Mountain Lion. Not working for me either. I just get this message: "You cannot control your computer if you turn Bluetooth off at this time as you would lose your input devices." For me the bluetooth toggle doesn't work. It just opens System Preferences/Bluetooth. I did not find a solution on how to alter the AppleScript for it to work, but I found a nice little (old) utility for toggling bluetooth which has thankfully nothing to do with AppleScript and I added it into my workflow. If you are still interested, here is the link to download: http://d.pr/f/9YZR If this doesn't work (it should!), I really don't know. wbranson 1 Link to comment
getthething Posted February 15, 2013 Share Posted February 15, 2013 I did not find a solution on how to alter the AppleScript for it to work, but I found a nice little (old) utility for toggling bluetooth which has thankfully nothing to do with AppleScript and I added it into my workflow. If you are still interested, here is the link to download: http://d.pr/f/9YZR If this doesn't work (it should!), I really don't know. I am using a Magic trackpad. This one works for me though. Thanks! Link to comment
wbranson Posted February 18, 2013 Share Posted February 18, 2013 I did not find a solution on how to alter the AppleScript for it to work, but I found a nice little (old) utility for toggling bluetooth which has thankfully nothing to do with AppleScript and I added it into my workflow. If you are still interested, here is the link to download: http://d.pr/f/9YZR If this doesn't work (it should!), I really don't know. Thanks very much for the update. I use a magic mouse not a magic trackpad, but this one seems to work flawlessly. Appreciate the work. Link to comment
dcadizm Posted April 17, 2013 Share Posted April 17, 2013 Thanks !!! It works perfectly Link to comment
tschoof Posted April 25, 2013 Share Posted April 25, 2013 Works perfectly, but an indicator message would be cool, if you're willing to work on it ;-) Have one for BT that does that, but one Workflow for BT and WiFi would be nice. Link to comment
spuder Posted April 27, 2013 Share Posted April 27, 2013 This will save me 4 mouse clicks per day! Love it. Link to comment
MetalRufflez Posted May 1, 2013 Share Posted May 1, 2013 (edited) Thank you for the workflow, but it always left the SysPref window open after I used it and since I don't know/want to learn AppleScript, I reused your icons and made it in bash script. Only problem is that for the Bluetooth toggle, there is no easy way to do this with vanilla osx. You have to install a small utility called blueutil, that you can get here: http://www.frederikseiffert.de/blueutil/ The extension is here: http://cl.ly/2Q3v191C0G37 Edited May 1, 2013 by MetalRufflez Link to comment
Fasand Posted May 2, 2013 Author Share Posted May 2, 2013 Thank you for the workflow, but it always left the SysPref window open after I used it and since I don't know/want to learn AppleScript, I reused your icons and made it in bash script. Only problem is that for the Bluetooth toggle, there is no easy way to do this with vanilla osx. You have to install a small utility called blueutil, that you can get here: http://www.frederikseiffert.de/blueutil/ The extension is here: http://cl.ly/2Q3v191C0G37 Update the workflow using the link in the first post and look inside the workflow's folder . I already stopped using the AppleScript way as it sucked and caused problems. Now it's using blueutil and works perfectly. Link to comment
caputo Posted October 30, 2013 Share Posted October 30, 2013 Is anyone having trouble with this script after upgrading to Mavericks? Since I upgraded last week, I can no longer use this workflow without receiving an error message "Failed to Toggle Bluetooth". In accessibility, Alfred 2 has the permissions to control my computer and I attempted to install the linked bt utility but received an error message /Volumes/blueutil/Install.command ; exit; 0:109: execution error: cp: directory /usr/local/bin does not exist (1) logout Thoughts? Link to comment
Fasand Posted November 2, 2013 Author Share Posted November 2, 2013 Is anyone having trouble with this script after upgrading to Mavericks? Since I upgraded last week, I can no longer use this workflow without receiving an error message "Failed to Toggle Bluetooth". In accessibility, Alfred 2 has the permissions to control my computer and I attempted to install the linked bt utility but received an error message /Volumes/blueutil/Install.command ; exit; 0:109: execution error: cp: directory /usr/local/bin does not exist (1) logout Thoughts? That's weird. I upgraded to Mavericks and everything works fine, maybe try to download the workflow again (http://d.pr/f/ybMT). As for installing the utility, the error simply says that your /usr/local/bin doesn't exist, so try creating it: mkdir /usr/local/bin and installing it again, not sure however if that might help. If anything works (or doesn't) be sure to tell me . Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now