Jump to content

TheDonk

Member
  • Posts

    35
  • Joined

  • Last visited

Everything posted by TheDonk

  1. After playing around with this for a while, I think I wrongly assumed this to be an Alfred problem. The same bug is present from the command line directly, sometimes it just won't scan. Not sure why, could be just on my machine. The same persists when using the "airport" command as well. So this one is closed I guess, sorry for the time wasting. It just didn't cross my mind that might be the error (since I didn't write it) Anyways, thanks for the help!
  2. Wow thanks! Lot of things to learn I´ll try this version throughout the day and see if the problem is solved.
  3. Yup it is, when i copied all the files into a new WF that wasn´t export worked fine. Thanks for any help
  4. Right, good point sorry. It was the only difference though, and I have produced the problem either way. https://www.dropbox.com/s/z8dovkdbpy6m8hp/WiFi_tool.alfredworkflow?dl=0 I had to copy-paste it into another workflow since I kept getting a "working directory doesn´t exist" error when I tried to export it. It still shows the same behaviour though, working most of the time - occasionally not
  5. Starting debug for 'Network Tool' [2016-10-03 01:31:56][STDERR: input.scriptfilter] 01:31:56 workflow.py:2152 DEBUG Workflow version : 1.0.0 01:31:56 workflow.py:1830 DEBUG Cached data saved at : /Users/donk/Library/Caches/com.runningwithcrayons.Alfred-3/Workflow Data/com.alfredapp.donk.networktool/networks.cpickle 01:31:56 workflow.py:1564 DEBUG Reading settings from `/Users/donk/Library/Application Support/Alfred 3/Workflow Data/com.alfredapp.donk.networktool/settings.json` ... 01:31:56 workflow.py:2346 DEBUG Set last run version : 1.0.0 01:31:56 workflow.py:2190 DEBUG Workflow finished in 0.036 seconds. [2016-10-03 01:31:56][input.scriptfilter] <?xml version="1.0" encoding="utf-8"?> <items><item valid="no"><title>no WiFi connections found</title><subtitle /><icon>bummer_fax.jpeg</icon></item></items> This is the debugger from Alfred. It doesn´t run long enough - which means that the bash-script is not called for some reason. I got an export error as well trying to export it, which makes me think I made a mistake putting files where they shouldn´t be. However, that would be a more likely cause if it never ran. I can upload the entire thing in a sec, after I sort out this export error
  6. I have a bug in my workflow, and I don´t understand the cause - so I thought maybe some of you have experienced the same problem. My workflow is a script filter getting a wifi-scan terminal output and populates the workflow with available networks to connect. Most of the time, it is working fine. However, sometimes Alfred shows no items. It seems to me that this happens when the workflow hasn´t been used for a while, but I haven´t tested that hypothesis extensively. I use the Python Library in my script filter. Anyone experienced something similar? It takes a few seconds to scan and import to the script, can that be the issue? PS: Is there a spoiler-function here? # -*- coding: utf-8 -*- """This populates the workflow with networks available for connection using the tool "m-cli" or "Swiss Army Knife" command line tools. """ import sys import subprocess from workflow import Workflow def getNetwork(): """This fetches a network scan using m-cli""" subprocess.call("./get_network.sh", shell=True) networkScan = [] with open('networkScan.txt') as inputfile: for line in inputfile: networkScan.append(line.strip().split(',')) scanNames = [] scanRS = [] for i in xrange(len(networkScan) - 1): results_line = networkScan[i + 1][0].split(":", 1) scanRS.append(results_line[1][15:18]) scanNames.append(results_line[0][0:-3]) return scanNames, scanRS def search_key(key): """This function is a search key for the wf filter. It means that the Title of the item is the only relevance for the search filter""" elements = [] elements.append(key['title']) return u' '.join(elements) def main(wf): """This function generates actionable items in Workflow""" if len(wf.args): query = wf.args[0] else: query = None networks = wf.cached_data('networks', getNetwork, max_age=30) items = [] for i in xrange(len(networks[0])): if int(networks[1][i]) > -55: newItem = dict(title=networks[0][i], subtitle="Signal strength " + networks[1][i], autocomplete=networks[0][i], arg=networks[0][i], icon="wifi_100.png") elif int(networks[1][i]) > -75: newItem = dict(title=networks[0][i], subtitle="Signal strength " + networks[1][i], autocomplete=networks[0][i], arg=networks[0][i], icon="wifi_66.png") else: newItem = dict(title=networks[0][i], subtitle="Signal strength" + networks[1][i], autocomplete=networks[0][i], arg=networks[0][i], icon="wifi_33.png") items.append(newItem) if query: items = wf.filter(query, items, key=search_key) # if not items: # This is when there are no items, no data # wf.add_item('no WiFi connections found', # icon=u"bummer_fax.jpeg") # wf.send_feedback() # return 0 for item in items: wf.add_item(title=item["title"], subtitle=item["subtitle"], autocomplete=item['autocomplete'], arg=item["arg"], valid=True, icon=item["icon"]) wf.send_feedback() if __name__ == u'__main__': wf = Workflow() sys.exit(wf.run(main))
  7. Cheers, that´s what I hoped If the speed gain is very small, I doubt I´ll ever need it. In any case, nice to keep in the back of the mind.
  8. I´m learning to write my own workflows. When I need an AppleScript, I like to use /bin/bash and call the relevant .scpt-file. Is there something, e.g. an efficiency issue, with using this ahead of the RunNSAppleScript "box" available within Alfred? An example*: I´m writing a workflow to change all open tabs to another browser (on battery, I like to switch to Safari). I designed it as follows: - Script Filter using the python package from here to create actionable items. - /bin/bash script calling an Applescript depending on the item picked from step 1. Would there be any benefit at all using the applescript box instead? I´m not a trained programmer, so something may elude me here. But its just much simpler to write a file instead of copy-paste into Alfred. *Just as a tutorial for myself, my question is really more in a general sense than in this particular example.
  9. Do you guys change any of the "timings" in Karabiner? I´ve found this sticky key idea to be useful, but am struggling to find the right balance between typing text and hotkeys when it comes to timing. Atm I have the "Initial Modifier Wait" at 50ms, but I was wondering what you guys use? Combined with workflows, this entire idea is brilliant though. I used to write in Alfred Prompt for almost everything, so this approach saves a lot of keystrokes.
  10. I have a question. The code for "R" as sticky key, e.g., has the hotkey "L" which launches an app. In the xml-code, it looks like this "R+L" really triggers another set of keys - namely "; + shft + alt". I assume then thats your Alfred hotkey to launch that app. But what´s the benefit of doing that way, compared to Karabiner´s built-in feature "VK_OPEN_URL_APP_appname"? I understand that one can get more keys this way in some instances, like being able to use 0+cmd+opt e.g., but don´t see the benefit of not using Karabiner´s app launcher. So I guess there´s something I haven´t thought of. In any case, a very fun discovery - thanks for that!
×
×
  • Create New...