Jump to content


  • Posts

  • Joined

  • Last visited

kbrock's Achievements

Helping Hand

Helping Hand (3/5)



  1. Hello @jrmarks11 Would you post the text of your workflow script here? Or possibly post it on github? For some help generating a url, bluejeans did post a tool -- http://output.jsbin.com/yeweno/ Maybe that will help I'm writing up a workflow, in ruby, and came here to see what others have done.
  2. Ok, so I've moved search engine discovery into a workflow. But I can not find how to "add" a search engine to Alfred itself. //constants var queryString = "{"+"query"+"}"; var jsGetUrl = "searches = document.querySelectorAll(\"link[rel='search']\")[0]; searches && searches.href"; function log(msg) { if(console) console.log(msg); } function uw(x) { return ObjC.unwrap(x); } function detect(nodes, attr, ref) { var nl = nodes.length; for(var i = 0; i < nl ; i++) { var n = nodes[i]; if(n[attr]() == true) { return ref ? n[ref]() : n; } } } function detectFrontApp() { if(false) { // hardcode for testing return "Google Chrome"; } else if(false) { // hardcode for testing return "Safari"; } else { var Events = Application("System Events") return detect(Events.processes, "frontmost", "name"); } } // convert search to alfred friendly search string function searchFromUrl(str) { str = str.replace("%7Bquery%7D", queryString); if(str.indexOf(queryString) > 0) return str; } // download open search document and return the query string function urlFromDoc(openSearchUrl) { log("curl -s -o "+ openSearchUrl) var app2 = Application.currentApplication() app2.includeStandardAdditions = true var strXML = app2.doShellScript("curl -s "+ openSearchUrl); var doc = $.NSXMLDocument.alloc.initWithXMLStringOptionsError(strXML, 0, null) var root = doc.rootElement // <OpenSearchDescription> var title = uw(uw(root.elementsForName('ShortName'))[0].stringValue); var icon = uw(uw(root.elementsForName('Image'))[0].stringValue); var searchUrl = uw(uw(root.elementsForName('Url'))[0].attributeForName('template').stringValue).replace("{searchTerms}", queryString); return { title: title, icon: icon, searchUrl: searchUrl }; } var frontApp = detectFrontApp(); var app = Application(frontApp); var openSearchUrl, searchUrl; switch(frontApp) { case "Safari": case "Webkit": log("==> " + frontApp); searchUrl = searchFromUrl(app.documents[0].url()); if(!searchUrl) { openSearchUrl = app.doJavaScript(jsGetUrl, { in: app.windows[0].currentTab }) } case "Google Chrome": case "Google Chrome Canary": case "Chromium": log("==> " + frontApp); var tab = app.windows[0].activeTab(); searchUrl = searchFromUrl(tab.url()); if(!searchUrl) { openSearchUrl = tab.execute({javascript: jsGetUrl}); } default: } if(searchUrl) { log("searchUrl=" + searchUrl + " <<< YAY"); } else if(openSearchUrl) { log("openSearchUrl=" + openSearchUrl); searchUrl = urlFromDoc(openSearchUrl)['searchUrl']; log("searchUrl=" + searchUrl + " <<< YAY"); } else { searchUrl = "unable to contact " + frontApp + " and get search term"; log("nuttin via" + frontApp); } searchUrl; // want to add THIS to Alfred's search engine
  3. I find the packaging a little tricky. Storing the script in a separate file is easier for version control, github browsing, and packaging up the final product. But storing the script in the workflow itself makes the experience from the workflow view much better. Could there be a way to modify the way a script is referenced in the UI so this distinction is lessened. Then adding a feature like a line numbers wouldn't feel like a rabbit hole
  4. There is a standard for defining search engines. It started in 1997 as a sherlock plugin but has gone by many names: mycroft plugins, search engines, search plugins, and more recently opensearch. All browsers can read this format and let the user choose it to search the web. Since Alfred is all about searching the web, it would be nice if it could use this capability. A web page has an html header that tells the browser where the search engines are defined: <link rel="search" type="application/opensearchdescription+xml" title="Stack Overflow" href="/opensearch.xml"> And the actual document is relatively straight forward: <?xml version="1.0" encoding="UTF-8" ?> <OpenSearchDescription xmlns="http://a9.com/-/spec/opensearch/1.1/" xmlns:moz="http://www.mozilla.org/2006/browser/search/"> <ShortName>Stack Overflow</ShortName> <Description>Search Stack Overflow: Q&A for professional and enthusiast programmers</Description> <InputEncoding>UTF-8</InputEncoding> <Image width="16" height="16" type="image/x-icon">//sstatic.net/stackoverflow/img/favicon.ico</Image> <Url type="text/html" method="get" template="http://stackoverflow.com/search?q={searchTerms}"></Url> </OpenSearchDescription> They can even support auto complete templates: <Url type="application/x-suggestions+json" template="http://example.com/suggest?q={searchTerms}"/> Usecase comes in 2 forms: 1. add a web search (and type in a website's url e.g.: google.com) 2. click "add a web search from the current chrome window" Then, Alfred reads the icon, url, and name from the header and creates the search definition. Also, alfred uses the auto complete suggestions extension to give super awesome feedback. Thanks
  5. You can copy paste the local script, and change it to en1. This will show all 3 possible ip addresses. (wifi, wired and external)
  6. Automator does a good job with this. They have multiple variables go through the system. If we assume that query is the only variable, then I wish action worked like script filter. I was going through the UI to type up a suggestion in this thread, but noticed that open url has an output. Is this still an issue? --EDIT-- Found it: I want the output of a script to be fed into open url. The script would massage the input to form into a url Sure want actions to feed into other actions. Yes, in the mean time, I'm using "scriptfilter" instead of "trigger -> script" to do my work ASIDE: thanks again for the awesome workflows
  7. I want to have multiple keywords that drive into a common script. So yes, I was hoping for the same feature. My current workaround is to use script filter with the "default" value being in the autocomplete
  8. 1. Please do not install a programming language for us. There are so many ways to install software on the mac. And developers can be picky as to how they want to do it. Let alone what packages to install. 2) The bash script suggestion looks great. 3) Allowing someone to add an interpreter that has already been installed would be great. That way I can use this feature to point to my own ruby installed via rbenv / rvm / chruby. And not the system installed ruby that doesn't have the packages I've installed.
  9. When play all songs by an artist in iTunes mini-player, Alfred changes the iTunes active playlist Why this is a problem: After a playlist plays, clicking play key (f8 on my keyboard) will play the active playlist. Which, of course, is the Alfred Playlist. Right? But if that playlist changes, I need to start using the mouse and track down the confusion. Alfred 2.0.8 (212) Version 10.8.6 iTunes 11.1 Easy to reproduce: open iTunes choose Music, Playlists, Alfred Playlist open mini-iTunes (command shift space for me) choose an artist choose the last song in an album (only necessary for use case 2) enter What I see: Problem #1 - music starts playing - "Alfred Playist" is updated - yay - active playist is the playlist below "Alfred Playlist" - boo Also note, after the playlist completes, clicking play keyboard button (or mini-player play/pause will start playing a different playlist)
  • Create New...