Jump to content

deanishe

Member
  • Posts

    8,759
  • Joined

  • Last visited

  • Days Won

    522

Everything posted by deanishe

  1. I don't think you can attach folder actions directly to Trash. It's a "magic" folder that doesn't actually exist. You could try attaching the script to the underlying ~/.Trash and .Trashes/<UID> directories at the root of each volume. Note that srm securely deletes files by overwriting them. If you just want them gone, rm is much faster.
  2. Don't think so. Bonjour doesn't work on VPN connections, and AFAIK Bonjour is the only way to connect Alfred Remote. There may be a way to manually specify an IP address (I'm not sure: I don't own Alfred Remote). If you can specify an address manually, it might work depending on your exact network configuration.
  3. AFAIK, there are 2 ways to do that. 1. Use AppleScript to simulate a click in an application's Services menu. 2. Use the Objective-C API (possibly from another language via a bridge) to run a service. In both cases, you'd have to specify the service's exact name (there's no way—that I'm aware of—to easily get a list of available services). Yes, that would be easier. You can run a workflow by path using open -a "Automator Runner" /path/to/workflow.workflow You could probably adapt my AppScripts workflow pretty easily to work with Automator workflows instead of (or as well as AppleScripts). The problem is that some Automator workflows won't work when not run as services if they get their input via the "Service receives selected XXX in YYY" option in Automator. For any services that require the selected files or text etc., you'd have to replace the input via the services API with a corresponding normal Automator action to retrieve the input, e.g., Get Selected Finder Items.
  4. So, you want to assign them all keyboard shortcuts in System Preferences and list them in (and run them from) Alfred?
  5. I'm not sure Alfred is much of a replacement for Hazel. They're designed to work in fundamentally different ways, and Alfred really isn't suited for running/managing background jobs. If you want to schedule a job, you should write a command-line script to perform whatever action and then create a Launch Agent for it or a cron job to run it at whatever interval. Personally, I use LaunchControl to create and manage Launch Agents because I prefer launchd to cron. If you can encapsulate whatever it is you want to do in a script, you can then run that from Alfred, Hazel or launchd/cron. With regard to your Trash question, I don't think there are any APIs, metadata or utilities that can help you there. Hazel appears to keep track itself of how long each file has been in the trash. So to replace it, you'll probably have to write a utility that can do the same…
  6. I'm pretty sure you can use AppleScript to simulate a mouseclick on an item in the Services menu, but I don't think there's an API for enumerating installed/active services. Not in AppleScript, at least.
  7. It might be that you haven't yet "taught" Finder how you like your new windows. You have to open a new Finder window, make it look just the way you want (size, view, sorting etc.) and then close it again without using the window at all (opening files/folders, navigating between folders etc.). After that, all new windows should look that way regardless of how they're opened.
  8. Short answer: no. Long answer: yes, but not like that. To perform different actions on different items, you connect them all to a single script that can perform the required actions and alter arg to specify the command as well as the argument. So you change arg="$IP" to arg="copy $IP" or arg="open $IP" as appropriate. Connect that to a Run Script action and turn of Escaping. Then you can treat {query} as two arguments: function perform_action() { local action="$1" local ip="$2" if [[ "$action" -eq "copy" ]]; then echo "$ip" | pbcopy else open "http://$ip" fi } perform_action {query}
  9. Alfred's fallback searches are symptomatic of a failed workflow. Open the workflow in Alfred, open the debugger, and then run the workflow.
  10. FWIW, I was looking into the security of Lastpass (and others) last night. It seems that the password used to log into the online service is derived from your master password in such a stupid way as to make your master password hundreds of times easier to crack than an offline-only copy of your database would be. They also do some rather questionable things, like storing known, encrypted text in the database, which also makes cracking your master password much simpler than it would otherwise be. And ironically, the known text in question is "lastpass rocks"…
  11. Writing workflows is an excellent introduction to programming. The results are generally more satisfying than, say, successfully implementing quicksort in Java. IMO, you should probably try and do this yourself. There'll be plenty of help available here if you have any specific questions.
  12. That's a weird way of comparing strings. You should definitely be using elif url.startswith('login'): and the other check should probably read if url == 'logout':
  13. It's not a solid solution. Its security is terrible, terrible, terrible. The fact that the homepage is very light on encryption implementation details is a red flag (as is the fact that the whole thing is written in JavaScript). So I looked into it, and it turns out Lastpass security is rubbish and RoboForm security is practically non-existent. In particular, RoboForm uploads (or it did in 2013) all your passwords (including your master password) in plain text. This is utterly, absolutely unacceptable. The connection may be encrypted with SSL, but the fact remains that RoboForm (and its employees) have access to your plaintext passwords. Lastpass doesn't do that, but the website password is derived from your master password in a way that makes it extremely easy to crack, again making you vulnerable to Lastpass, its employees and any other entity that can access its data. 1Password at least tries to do security properly. The fact that it is a local application, not a browser-based one, gives it a significant advantage over other solutions. If your password manager is browser based, then it suffers from all the same security problems browsers do (XSS, CSRF etc.) and is potentially running in the same process as malicious code (hijacked or malicious websites). A browser is possibly the worst choice of platform for a password manager.
  14. Doesn't work for me. It can't find xkpasswd. For some reason, the workflow looks in /usr/local/xkpasswd. It's installed in /Library/Perl/5.18/Crypt/HSXKPasswd. Are you using HSXKPasswd's built-in sample files to generate the passwords?
  15. You have to use Actions > Run Script, not Outputs > Run Script.
  16. You still have to connect the actions together in Alfred. How would Alfred know where to send the output otherwise? I'm not sure if a hostname alone will be enough. You'll probably need to put an http:// in there, too.
  17. From a Run Script action, any output to STDOUT is sent to the next action as {query}. That means, as demonstrated above, what you print or echo in your script becomes {query} for the next action. In the case of Script Filters, the arg parameter of their results becomes the {query} of the following action.
  18. You put url = "{query}" at the top of your script, and print the altered URL. This script takes the URL the user entered and expands any shortened URLs. from urlparse import urlsplit, urlunsplit from urllib2 import urlopen url = "{query}" # Expand short URL/resolve redirects print(urlopen(url).geturl())
  19. Like I said, try Epichrome. It lets you build standalone apps for webpages (using Chrome).
  20. The workflow communicates with Reminders via AppleScript, so Reminders has to be running. It would be possible to detect if Reminders is not running when the workflow starts, and then quit it again afterwards.
  21. FWIW, 1Password also provides a very simple way for third-party apps to integrate its bookmarks. Roboform does not provide any means of third-party integration. As a result, it would be very difficult (likely impossible) for Alfred to include its passwords or for someone to write a workflow for it. There are a couple of Lastpass workflows because Lastpass also provides a way for other applications to interact with it.
  22. Like Andrew says, you're going to have problems with Chrome Apps because they're still Chrome windows. Try something like Epichrome to make proper site-specific browsers with Chrome. They exist in their own applications, so they behave like proper applications, not Chrome windows.
  23. Alfred only works with one input, so you're probably going to have to do some scripting to get around that. In the simplest case, you could say "the input format is |country 1|city 1|country 2|city 2" and then split the single input on | If you follow my tutorial for a Pinboard workflow (creating the workflow, installing the library etc.) and use this Python script instead of pinboard.py, it should do, basically, what you want. #!/usr/bin/python # encoding: utf-8 """ Script Filter for Alfred 2 and Alfred-Workflow library. Compare cost of living in two cities. Save as `numbeo.py` in your workflow directory and create a Script Filter with Argument = required Language = /bin/bash Script = /usr/bin/python numbeo.py "{query}" """ import sys from workflow import Workflow, web log = None API_URL = u'http://www.numbeo.com/common/CitySearchJson' WEB_URL = u'http://www.numbeo.com/common/dispatcher.jsp?city_id1={}&city_id2={}&where=http://www.numbeo.com/cost-of-living/compare_cities.jsp' DELIMITER = u'⬌' def search_city(query): """Search for cities.""" r = web.get(API_URL, {'term': query}) r.raise_for_status() return r.json() def comparison_url(first_id, second_id): """Return URL for webpage comparing the two cities.""" return WEB_URL.format(first_id, second_id) def main(wf): """Run workflow.""" first_id = None query = wf.args[0] if DELIMITER in query: first_id, query = [s.strip() for s in query.split(DELIMITER)] for city in search_city(query): if city['value'] == first_id: continue if first_id: url = comparison_url(first_id, city['value']) wf.add_item(u'Compared to {}'.format(city['label']), url, valid=True, arg=url) else: wf.add_item(city['label'], autocomplete=u'{} {} '.format(city['value'], DELIMITER)) wf.send_feedback() if __name__ == '__main__': wf = Workflow() log = wf.logger sys.exit(wf.run(main)) Connect that Script Filter to an Open URL Output.
  24. If you remove the directories where your unwanted applications are from Alfred's Default Scope, you won't see them during normal search. Be sure to run reload after fiddling with the Scope. The only way to find every file is locate. If it isn't turned on, it'll tell you how to turn it on when you run it.
  25. I don't think you can do that with a Terminal Command. The fundamental problem is that Alfred pastes the command in whichever directory Terminal opens at. Your script has no filepath, so it has no idea where to find the other script. The only way around it is to call Terminal yourself from a script that exists on disk (so it knows where to look for the other script). This AppleScript will call a shell script in its own directory, either by full path or by changing directory. -- Change working directory to parent dir of this script -- before running the shell script property cwd : true on run (argv) set theScript to first item of argv set parentDir to POSIX path of ((path to me as text) & "::") if cwd is true then tell application "Terminal" to do script "pushd " & quoted form of parentDir & " && " & quoted form of theScript & "; popd" else set thePath to parentDir & theScript tell application "Terminal" to do script quoted form of thePath log "thePath : " & thePath end if end run If you save it as, say, run-script-in-terminal.scpt in your workflow, then you can use it in a /bin/bash Run Script Action to call other scripts: osascript run-script-in-terminal.scpt ./myscript.sh If you set cwd at the top of the AppleScript to true, it will tell Terminal to change to the AppleScript's own directory before calling the next script. Set it to false and it will call the script by its full path from whichever directory Terminal opens at.
×
×
  • Create New...