Jump to content

deanishe

Member
  • Posts

    8,759
  • Joined

  • Last visited

  • Days Won

    522

Everything posted by deanishe

  1. @dfay: Sorry, I overlooked you huge post from earlier. I think I might need some form of Airplay-compatible hardware. I have a few of those bluetooth -> RCA receivers, but you always have to hit a button on the top of the thing to re-/disconnect a device
  2. Sounds like a good start, but I'm not plugging my phone in to play audio. It's 2015, dude!
  3. Use this AppleScript in a Run Script action (Language /usr/bin/osascript): set theQuery to "{query}" tell application "Finder" set thePath to (home as Unicode text) & "Fonts" set theDirectory to thePath as alias open theDirectory activate -- Change the delay to something long enough so that -- the Finder window is activated and receives the -- keystroke events delay 0.3 tell application "System Events" tell process "Finder" set value of text field 1 of group 5 of toolbar 1 of front window to theQuery keystroke "f" using {command down} end tell end tell end tell You might have to alter the ...text field 1 of group 5 of toolbar 1... line if you've customised Finder's toolbar.
  4. Right, so you don't want the results in Alfred but somewhere else? You need to use AppleScript to open the Spotlight window or a Finder window and do the search. To run a search in Finder, add a Run Script action using language `/usr/bin/osascript` and the following content: set theQuery to "{query}" tell application "Finder" open (POSIX file "/") as alias activate -- Change the delay to something long enough so that -- the Finder window is activated and receives the -- keystroke events delay 0.3 tell application "System Events" tell process "Finder" set value of text field 1 of group 5 of toolbar 1 of front window to theQuery keystroke "f" using {command down} end tell end tell end tell Because the script is using GUI scripting, it's dependent on the way your Finder is set up. If CMD+F isn't your shortcut to do a search in Finder, change the corresponding line in the script. text field 1 of group 5... should be the right "address" for the search box in a non-customised Finder window, but you may have to adjust those values if you've added anything to Finder's toolbar (I need group 6 on my machine, for example). If you want to search with Spotlight, not Finder, you can also do that using GUI scripting.
  5. I did try out Airserver, but it wouldn't work for me for some reason. It would have been a decent stop-gap. Thing is, I turn my computer off a lot, as it's an old Mac Pro and consumes a ridiculous amount of power, so routing the sound via the computer isn't a great option.
  6. Yeah, I spent some time staring at the weird output and wasn't going to bother trying to figure it out. Thankfully, a Stack Overflow thread turned up the above nugget.
  7. The important bit is setting the client URL parameter to something other than t. That way you get valid, comprehensible JSON instead of some weird crap.
  8. Does anyone know if there's any way to get all the hostnames/subdomains/domains that map to a single IP address? Or can you only get the rDNS hostname?
  9. Don't worry, just ignore me. Because you said "both ways" and I'm used to calling whois with a hostname, I got it into my head that the ip keyword was a reverse DNS lookup that wanted an IP address as input, not a hostname.
  10. Thanks! You clearly know way more about audio equipment than me, so I'd like to run what I'm after by you and would appreciate your input. I currently have an old set of Logitech 5.1 speakers (basically a 10-year-old version of the Z906 system) connected via a digital optical cable. Turns out I don't like 5.1 (I live alone, so it keeps scaring the crap out of me when I hear noises behind me) and I don't like digital optical (it disables the system volume control). I've been considering replacing the lot with a low-end, non-AV, non-digital Onkyo and a set of bookshelf speakers, but I haven't got a clue if I'm going to be any better off with that because I know nothing about audio equipment. Like, will I still need to use the receiver's remote to change the volume? To avoid the X-Y problem trap, what I ideally want to achieve is the ability to easily connect both my iPhone and computer to the same speakers and have them both play at the same time (i.e. I can listen to a podcast from my phone, but still hear sound effects from the computer). Would I need a mixer to do that? What's the best way to connect your iPhone to your audio equipment, anyway? I currently have one of those Bluetooth receivers plugged into the Logitech box, but it's a PITA. I'd also like to avoid having to use a separate remote and use my computer/phone as much as possible instead (hence my interest in this thread). It needn't be better in audio terms than the Logitech speakers I'm using. I have no detectable appreciation of audio quality beyond what I have. Anything better in audio terms is lost on me.
  11. What does the IP lookup do? I've tried it with a couple of my IP addresses and it just gives me the same IP address back…
  12. Out of interest, is this something "normal" Onkyo receivers can do or is it only the high-falutin' digital AV jobbies?
  13. What actually happens is that Google returns each sentence as a separate result, but the workflow throws away all but the first. To get multi-sentence results, open the workflow in Finder and edit the translate script in it to read as follows. This will show all the sentences in a translation. Because Alfred can't show much text in its results, I've added copy text and large type. Hit CMD+C on a result to copy the translation to the clipboard and CMD+L to show the full translation in Alfred's large type window. # Set locale and normalize unicode composition for international support. export LC_CTYPE="UTF-8" query="$(echo "${@:3}" | iconv -s -f UTF-8-Mac -t UTF-8)" # Retrieve and parse Google Translate answer. response="$(curl -G --data-urlencode "text=$query" --data 'client=p' --data 'sl=auto' --data "tl=$1" --silent --user-agent 'Mozilla/5.0' 'http://translate.google.com/translate_a/t' | python -c 'import sys, json; print("".join([d.get("trans", "<UNTRANSLATED>") for d in json.loads(sys.stdin.read())["sentences"]]).encode("utf-8"))')" [[ -z "$response" ]] && translation="No translation found" || translation="$response" # Write feedback. echo '<?xml version="1.0" encoding="UTF-8"?><items> <item uid="translation"> <title><![CDATA['"$translation"']]></title> <arg><![CDATA['"$translation"']]></arg> <text type="copy"><![CDATA['"$translation"']]></text> <text type="largetype"><![CDATA['"$translation"']]></text> <icon>icon.png</icon> <subtitle>”'"$query"'” in '$2'.</subtitle> </item> </items>'
  14. You have added the drive to Alfred's Search Scope in the preferences, haven't you? (Alfred Preferences > Features > Default Results)
  15. That's the way Alfred's designed to work (mixing workflow results and its own results together). You can select "with space" in your Script Filter's options to keep its results out of Alfred's (it won't be run till the query is "kc "). If you want to ensure Alfred's default results aren't mixed in with your workflow's, you need to use a more unique keyword. ".kc" would probably give you no default results in Alfred.
  16. That's not really true. It's perfectly possible to run a background process from within an Alfred script. You just have to be sure that any subprocesses you want to background also disconnect from the parent STDOUT and STDERR, as Alfred won't consider a subprocess finished while one of them is still open.
  17. The problem is your command is the wrong way round. Use cmd 2>&1 >> $log & not cmd & 2>&1 >> $log (with the "backgrounding" ampersand at the end after the redirection). If the ampersand isn't at the end, bash won't background the process, which is why your script isn't exiting immediately.
  18. Thanks, Andreas That only works with URLs (i.e. webservers), not arbitrary hostnames. However, the relevant Python code from that workflow is: import socket def dns_info(hostname): """Return DNS info for hostname""" try: host, aliases, ipaddrs = socket.gethostbyname_ex(hostname) except Exception as err: print('Error fetching DNS for {} : {}'.format(hostname, err)) raise return { 'hostname': host, 'aliases': aliases, 'ipaddrs': ipaddrs } Example output: >>> dns_info('www.google.com') {u'ipaddrs': ['74.125.136.106', '74.125.136.105', '74.125.136.103', '74.125.136.147', '74.125.136.99', '74.125.136.104'], u'hostname': 'www.google.com', u'aliases': []} >>> dns_info('www.yahoo.com') {u'ipaddrs': ['46.228.47.114', '46.228.47.115'], u'hostname': 'fd-fp3.wg1.b.yahoo.com', u'aliases': ['www.yahoo.com']}
  19. I think the only way you could use Alfred's built-in components would be if you used tags or Spotlight comments to add the project name to each 'wp-content' folder. You could try this workflow, which filters across directory levels, so you'd set up a Fuzzy Folder for ~/Sites and then "sites xch wp" (assuming "sites" is the keyword you assigned to ~/Sites) will match ~/Sites/xchange/wp-content/. The best way would probably be to write a Script Filter, however. This is a very rudimentary prototype, but if you use this as a Script Filter (Language = zsh, Escaping = Double Quotes, Backquotes, Dollars, Backslashes), it will do more or less what you want (filter on the project name, open the wp-content folder): #!/usr/bin/env zsh export LC_CTYPE=UTF-8 query="{query}" function projname() { echo "$( echo "$1" | awk -F/ '{print $(NF-1)}' )" } function contains() { local string="${1:l}" local substring="${2:l}" if test "${string#*$substring}" != "$string" then return 0 # $substring is in $string else return 1 # $substring is not in $string fi } wpdirs=(${(f)"$(mdfind -onlyin ~/Sites '(kMDItemContentType == public.folder) && (kMDItemFSName == wp-content)')"}) if [[ -z "$query" ]]; then projects=($wpdirs) else projects=() for p in $wpdirs; do pname="$( projname "$p" )" if contains "$pname" "$query"; then projects+="$p" fi done fi echo '<?xml version="1.0" encoding="utf-8"?>' echo '<items>' for proj in $projects; do pname="$( projname "${proj}" )" cat <<EOF <item valid="yes" type="file"> <title>${pname}</title> <subtitle>${proj}</subtitle> <arg>${proj}</arg> <uid>${proj}</uid> <icon type="fileicon">${proj}</icon> </item> EOF done echo '</items>'
  20. That won't work because /Users/drlulz/Documents/anki isn't part of your $PATH… Either use the full path to runanki or cd to ~/Documents/anki first and do env -i ./runanki. You are actually using the full path to the runanki executable in your workflow script, aren't you?
  21. It could be lots of things. Try running the program with env -i runanki to simulate the empty environment.
  22. That works, of course, but you kind of have to Alfred before you can Alfred if you know what I mean.
  23. It doesn't work for me because it can't find requests. When you distribute your workflow, you should consider including any libraries it needs with it. You can install them in your workflow using, e.g., pip install --target=/path/to/my/workflow requests.
  24. The reason you can't figure it out is because it's almost impossible to do in the way you're thinking. There's absolutely no way for Alfred to look directly into browser tab. Pretty much the only thing a browser will tell an external program is the URL and titles of its tabs. If you need to work with the contents of browser windows, what you need is a userscript or browser extension. Probably this one.
  25. Perhaps consider using iTerm 2 instead of Terminal? It's better and has a visor mode built in (you need the nightly build, though).
×
×
  • Create New...