apfelartig Posted January 17, 2013 Share Posted January 17, 2013 Hello, I am really new to scripts but I used some in Alfred v1. Scripts like Bluetooth-Toggle or Wi-Fi-toggle and AppleScripts like Starfish or Caffeine Manager. Now with version 2 beta I wanted to import some manually by copying the text. For Example: Bluetooth-Toggle I said Keyword (Input) and combined it with run script (Actions) Script: ./bluetooth.py Another Caffeine Manager: I said Keyword (Input) and combined it with run applescript (Actions) Script: (* This is an unofficial manager for Caffeine (http://lightheadsw.com/caffeine/) created by Sebastian of Zibity. It is an easy way to toggle Caffeine on and off. Usage: "caff" If you have any questions or suggestions, please send me a message via my website: http://www.zibity.com If you want more cool Alfred extensions like these, take a look at http://www.zibity.com/alfred.html for all of my other extensions. If you like this extension, please consider donating to support the continued development of things like this: http://donate.zibity.com *) --- SCRIPT BEGINS HERE --- try tell application "Caffeine" if active is false then turn on tell application "Growl" to notify with name "Extension Output" title "Caffeine has been activated." description "Caffeine Manager has activated Caffeine." application name "Alfred" identifier "caff" icon of application "Caffeine" else turn off tell application "Growl" to notify with name "Extension Output" title "Caffeine has been deactivated." description "Caffeine Manager has deactivated Caffeine." application name "Alfred" identifier "caff" icon of application "Caffeine" end if end tell end try Non of this ways really worked for me. Do you have any suggestions for me what I did wrong? Link to comment
Weaselboy Posted January 17, 2013 Share Posted January 17, 2013 You need to have the script enclosed in "on alfred_script(q)-end alfred_script" like in my example below. on alfred_script(q) tell application "Mail" check for new mail end tell end alfred_script Link to comment
apfelartig Posted January 17, 2013 Author Share Posted January 17, 2013 Thanks! Now It works with AppleScripts but not with the following ones: Bluetooth-toggle ./bluetooth.py WiFi-toggle #Function to search keychain for the network password get_pw () { if [ "$1" ] then security 2>&1 >/dev/null find-generic-password -ga AirPort -l "$1" | cut -d '"' -f 2 | grep -v security: fi } #Find the device name DEVICE=$(networksetup -listallhardwareports | grep -A 2 -E "AirPort|Wi-Fi" | grep -m 1 -o -e en[0-9]); #Toggle or change network? case "{query}" in "") #Toggle the power of the Wi-Fi/Airport if [ $(networksetup -getairportpower $DEVICE | grep -c On) == 0 ] then networksetup -setairportpower $DEVICE On echo "Wi-Fi enabled."; else networksetup -setairportpower $DEVICE Off echo "Wi-Fi disabled."; fi ;; "?") echo $(networksetup -getairportnetwork $DEVICE) echo networksetup -getinfo Wi-Fi ;; *) #Change network - Make sure that the Airport is on if [ $(networksetup -getairportpower $DEVICE | grep -c On) == 0 ] then networksetup -setairportpower $DEVICE On fi #Fuzzy match to known networks NETWORK=$(networksetup -listpreferredwirelessnetworks en1 | egrep -im 1 "[[:alnum:]]*{query}[[:alnum:]]*$"); #If a match is found - try to connect to Network if [ -z "$NETWORK" ] then echo "Unable to match \"{query}\" to a know network."; else ERROR=$(networksetup -setairportnetwork en1 "$(echo $NETWORK)" $(get_pw "$(echo $NETWORK)") ); if [ -z "$ERROR" ] then echo "Successfully connected to network $NETWORK."; else echo $ERROR; fi fi ;; esac Are these Python-Scripts and follow other rules? Link to comment
apfelartig Posted January 17, 2013 Author Share Posted January 17, 2013 Actually only the Bluetooth-Toggle doesn't work. are there any other scripts to turn it on/off? Link to comment
Weaselboy Posted January 17, 2013 Share Posted January 17, 2013 Actually only the Bluetooth-Toggle doesn't work. are there any other scripts to turn it on/off? I found one https://discussions.apple.com/thread/3179367?start=0&tstart=0 here that looks like it would do the trick. Link to comment
apfelartig Posted January 17, 2013 Author Share Posted January 17, 2013 Yes I have tested it before. The problem is that it starts System Preferences which isn't usually in my Dock. Link to comment
aiyo Posted January 18, 2013 Share Posted January 18, 2013 WiFi-toggle This is a Bash script. I have made a new version for Alfred 2, you can finde it here: https://github.com/aiyodk/Alfred-Extensions/raw/master/AlfredApp_2.x/Wi-Fi-Toggle/Wi-Fi%20Toggle.alfredworkflow This new workflow also shows the current network name and IP-address when connected to a network. You can see all my Alfred 2 workflows here: http://www.aiyo.dk/alfredapp/v2/ Cheers Link to comment
apfelartig Posted January 18, 2013 Author Share Posted January 18, 2013 Thanks, thats really great. Maybe you consider a small notification for 10.8? 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