Jump to content

deanishe

Member
  • Posts

    8,759
  • Joined

  • Last visited

  • Days Won

    522

Everything posted by deanishe

  1. You need to change line 225 of the pandoctor.py file in the workflow. Change the URL to http://pandoc.org/README.html.
  2. You could also create a service that executes Alfred's File Action menu. Open Automator and create a new Service. It should accept "files or folders" in Finder. Add a Run AppleScript action, and put this in the box (it simulates the keyboard shortcut to open Alfred's File Action menu): on run {input, parameters} tell application "System Events" to key code 44 using {command down, option down} return input end run NOTE: This script runs ⌘⌥/ (command-option slash) which is what I have set for my shortcut. I believe the default is ⌘⌥\ (command-option backslash). In that case, you need to change key code 44 to key code 42. Save the Service as, say, "Open Selection in Alfred…", and it will appear in your context menu in Finder.
  3. Out of interest, does mdimport /my/file/path have the same effect?
  4. Confirmed. Had me a little confused as it works instantly (without reload) on files/folders. It probably bears pointing out that adding alfred:ignore is often not much help with folders, as it only applies to the folder itself and not its contents.
  5. I've written a fairly basic example workflow using the python-phonenumbers library. It should do what you want it to if I've discerned your intentions correctly. You can download it here. I'd encourage you to study the code in the tel.py file (what the Script Filter runs), which is fairly heavily commented to explain what's going on, and the Alfred-Workflow tutorial (and other docs) to follow what's going on "behind the scenes". Perhaps you can think of a way to improve the workflow to make it useful to other people (e.g. displaying several different formats and/or understanding phone numbers that aren't from the US). Feel free to ask if you have any more questions about it, or to click on the "Buy me a beer" link below
  6. Command-C works okay. Some of the time. You still need to have the app running (or very recently closed) in any case.
  7. iOS doesn't really do "background". You're going to need the app running on iOS unless there's some convoluted implementation that uses push notifications to "wake" the app.
  8. You can add "alfred:ignore" as either a tag or a Spotlight comment to files and folders Alfred should ignore. I don't think it works with applications, however.
  9. What do you mean "shortcut"? Are you just typing in "cal" and Calendar.app is the top result? Fantastical probably isn't going to show up in that case, as it's name doesn't start with "cal". Do a Get Info on Fantastical.app and add "cal" to the Comments box. If will now show up for the query "cal". It might take Alfred a few runs to learn that you now want "cal" to match Fantastical over Calendar.
  10. I got that trick from one of the threads you linked to. I just knew it was related to Alfred not specifying a UTF-8 environment.
  11. You could probably do this via a script assigned to a keyboard shortcut. If I were trying to do this, I'd do it in four steps: Use AppleScript to send the key presses ⌘⇧← then ⌘X to select the current line and cut the text to the pasteboard. Use a custom script to replace the characters in the cut text with the characters on the same keys when the target keyboard layout is selected, e.g. going from an English layout to a German one, that would mean replacing "y" with "z" and ";" with "ö". Paste the altered text (also using AppleScript). Use this script to switch to the desired input source. For use outside Alfred, I guess you'd want to skip the ⌘⇧← bit and select the text yourself.
  12. What do you mean "arguments"? Like, what are you talking about? Command-line programs, Script Filter XML, Post Notification Outputs? Your question can't really be answered without some context.
  13. Have you tried explicitly specifying an encoding? Either add this to the top of your bash script: export LC_CTYPE=en_US.UTF-8 Or call ruby with -Ku (use UTF-8). Can't say more without the actual code and input that's causing the error.
  14. Python, you say? Now we're talking Anything you put in a Run Script action should be run silently in the background. Sometimes weird things happen on OS X if you try to run, say, git, but it isn't installed (instead of your script silently failing, you'll get a pop-up asking you to install Xcode). There is a small delay when you start running extra processes, but running a bash process takes a few hundredths of a second. That can really add up if you're writing a complex script in bash (which is largely based on running other processes), but when you're combining it with AppleScript calls to applications (which are insanely slow), bash will never be the problem. Getting data from an application via AppleScript is often many thousands of times slower than accessing the datastore directly (if that's possible). Don't break your head over AppleScript. It's a truly demented language. It's simple to the point of broken, but the first-class option for interacting with very complicated application object models. It's two kinds of bad rolled in to one…
  15. Alfred Star Ratings View and set star ratings for your files. Star ratings (like in iTunes) are a great way to categorise and organise your files. Unfortunately, you can access them directly in Finder, but Smart Folders (aka Saved Searches) do support them. Combine 'em to get quick access to your favourite porn Oscar-winning movies. Goes great with my Smart Folders workflow. Download & installation Download the workflow from GitHub releases or Packal. Double-click the downloaded .alfredworkflow file to install it. Usage This workflow works primarily via Alfred's File Actions. It uses Alfred's main window to display the ratings of the files you have selected in Finder, but they are altered via File Actions. In particular, if you just want to rate some files (rather than see their ratings), you should select them in Finder and directly call Alfred's File Actions mode with ⌥⌘+\ (default Alfred hotkey). From Alfred's main window .r — Grab the files currently selected in Finder and display them with their ratings. This is attached to a Hotkey, which you can assign (Alfred strips Hotkeys from workflows when you install them). Feel free to change this keyword, but you probably want to choose something unique (i.e. it doesn't match any of Alfred's default results), so the File Buffer is easy to use. → (default Alfred hotkey) — Show File Actions for selected result. ⌥+↑ (default Alfred hotkey) — Add result to File Buffer. ⌥+↓ (default Alfred hotkey) — Add result to File Buffer and move selection to next result. ⌥+→ (default Alfred hotkey) — Open File Actions for all files in the File Buffer. From Alfred's File Actions window Entering the number of stars you wish to assign (e.g. 0, 1, 2 etc.) should show the corresponding action. The action to clear the rating is called "Clear Star Rating", so typing clear should show that action. Licensing, thanks This workflow is released under the MIT licence. It relies on the following open-source resources: The icon is from Font Awesome by Dave Gandy (SIL licence). biplist by Andrew Wooster for parsing/generating binary plists (licence). Alfred-Workflow by me, a library for writing Alfred 2 workflows (MIT licence).
  16. AppleScript sucks, tbh. Really sucks. The way Alfred runs NSAppleScripts is that it calls the alfred_script(q) function, passing in its query as q. So if you're running it from within Alfred, change the line within alfred_script(q) from: set tabIndex to q as integer to: set tabIndex to 1 Similarly, if you're running it from the command line, change the corresponding line in run(argv) (which is the normal entry point when you run a script) from: set tabIndex to item 1 of argv as integer to: set tabIndex to 1 Or in either cases, just use: my toggleActiveTab(1) That said, I deliberately wrote it so it takes an argument because you said you were planning to do the same for tabs 2 and 3. It's rather bad form to create multiple copies of a script if you can avoid it: if you find a bug or want to change/improve something, you have to edit multiple, effectively identical scripts. A better idea would be to open your workflow in Finder and save this script in there as, say, safari_tabs.scpt. Then in Alfred, instead of a Run NSAppleScript Action, create a Run Script Action with Language = /bin/bash. Then you can use a super simple script, which can't really go wrong: osascript safari_tabs.scpt 1 Then just make a copy of that and change the number to activate tab 2 or 3. You can connect Hotkey triggers to each of these.
  17. I think what you were missing is index of current tab. That's how you get a number, not a tab object. If I've understood you correctly, this should do what you want. I've rewritten the script extensively because the behaviour you want is a little complicated, and it's easier to reason about if you separate the "business logic" from the actual actions. This way, my toggleActiveTab() function, which is the bit that implements the behaviour you want, is fairly simple. (* This function is called when you run the script from the command line, e.g.: osascript "Safari Tabs.scpt" 2 will activate tab 2 of the frontmost Safari window. *) on run (argv) set tabIndex to item 1 of argv as integer my toggleActiveTab(tabIndex) end run (* This function is called when the script is run from within an Alfred Run NSAppleScript Action. q is the query you entered in Alred's query box. It is a string. Convert it to a number and run the script. *) on alfred_script(q) set tabIndex to q as integer my toggleActiveTab(tabIndex) end alfred_script (* If Safari is the active application and the specified tab is the current one, hide Safari. Otherwise, activate Safari and make the specified tab the current one. *) on toggleActiveTab(tabIndex) set activeAppName to my getActiveApp() log activeAppName & " is the active application" -- First we want to hide Safari if it is currently active and current tab is tabIndex if activeAppName = "Safari" then set activeTab to my getActiveSafariTab() if activeTab = tabIndex then my hideApplication("Safari") -- Our job is done; exit script return end if end if -- Safari isn't active and/or tabIndex isn't the current tab, so -- activate Safari (if necessary) and set current tab to tabIndex activate application "Safari" my setActiveSafariTab(tabIndex) end toggleActiveTab -- Return the name of the active application on getActiveApp() tell application "System Events" to set activeApp to first process where it is frontmost return name of activeApp end getActiveApp -- Return the index of the current tab in Safari's frontmost window on getActiveSafariTab() tell application "Safari" to return index of current tab of front window end getActiveSafariTab -- Set the active tab of Safari's frontmost window on setActiveSafariTab(tabIndex) tell front window of application "Safari" to set current tab to tab tabIndex end setActiveSafariTab -- Hide the specified application on hideApplication(appName) tell application "Finder" to set visible of process appName to false end hideApplication
  18. Error number 60 is a socket timeout error (it couldn't connect to your server). Either there was a temporary network problem between you and your mail server or your mail server was briefly offline.
  19. Which "deanishe's guide" are you following? AFAIK, the only one I wrote assumes the use of the Alfred-Workflow library (which helps you send the results to Alfred). Also, you almost certainly don't want the two sets of quotes in x = "'{query}'". x = "{query}" is enough.
  20. Right. It does sound like a messed up install. Assuming you've already tried rebooting, you might have to reinstall the system from the Recovery Partition. This should fix a broken OS installation. If you don't want to do that right now, you could edit the workflow to use "open", as described above, instead of osascript.
  21. No. You cannot run a workflow as a fallback search. You could add a custom search for DuckDuckGo.
  22. Hard to say, as I can't actually run the code. I fed the XML you posted above into the Run Script and it didn't hang. (It threw an error because I don't have an account to connect it to). From what I can tell, you won't see anything in the debugger: all STDERR output is redirected to the log file. Your use of {query} is a bit odd. Why aren't you using the defaults (i.e. "{query}" without Spaces, Brackets and Semicolons escaped)? You could try adding echo "{query}" > /dev/stderr to the top of the Script box. That will show up in Alfred's debugger. If you see it, the problem is with your script. Also, the install instructions in the README are incorrect. You can't run this in terminal: echo "$isy_config = {:hostname => 'https://isy.domain.com', :username => 'my_username', :password => 'my_password' }" > /path/to/folder/workflow/isy_config.rb Because you used double quotes, bash will expand $isy_config to an empty string. And, as best I can tell, your Gemfile is incomplete. The workflow also wants something called "color".
  23. There are a few things wrong with that. I'm assuming the doubled osascript -e is a typo. More correctly, it should read osascript -e 'open location "https://google.com"' (No need to put two sets of quotes around "google.com"; You need the https:// to make it a valid URL; It's better to wrap commands in single quotes.) But it's entirely unnecessary to use AppleScript. Just run open "https://google.com"
×
×
  • Create New...