Jump to content

zeitlings

Member
  • Posts

    263
  • Joined

  • Last visited

  • Days Won

    16

Everything posted by zeitlings

  1. Default Browser An Alfred workflow to set the default web browser. ▸ Visit on Github ◂ | ▸ Alfred Gallery ◂ Usage Note Set the default web browser using the keyword (default: sdb). The macOS browser change confirmation dialog is automatically accepted. Utility: Use the workflow’s File Action (name: Bundle Identifier Information) to retrieve an application’s bundle identifier.
  2. Coincidentally, I updated the code and workflow today. After peeking in here and seeing your script, @snoop182, I integrated it as well. Works like a charm! With a few tweaks that is. Here's a version of the script that confirms the default browser switch automatically and can handle most bundle names, regardless of locale: on run set theBrowser to "{query}" set browserComponents to theBrowser's words tell application "System Events" tell application process "CoreServicesUIAgent" tell window 1 set buttonNames to (name of every button) repeat with buttonName in buttonNames repeat with theComponent in browserComponents if (buttonName contains theComponent) then tell (first button whose name contains theComponent) perform action "AXPress" end tell return end if end repeat end repeat end tell end tell end tell end run And thanks @Grug, @Mr Kenz . Perhaps now it deserves its own topic. Link: Set Default Browser v1.1.0
  3. Nope, I "updated" it on import what seems to replace whatever was there before – at least with regard to the files. I imported the same workflow again and the Crypto stuff got wiped. Now most of the functionality is restored.
  4. I was about to check back in to tell you that I tested v4.02 after reading pankajsz' comment and that it worked fine. Testing v4.2 now. Cropping does work. Or better, did work. I now tried to decrypt your encb.pdf and was prompted to pip install PyCryptodome, which I did. Now I get the previous incompatible architecture panic whatever I'm trying to do (progress, split, deskew,...). Btw., before I tried the decrypt I tested the deskew for a minute and the performance was irritatingly sub par. Is this a rosetta thing (Activity Monitor indicates the corresponding process to be of kind "Intel") or is it also kind of slow on x86_64? Anyways, at least it's pretty safe to assume that pycrptodome is the culprit. [21:34:19.337] ERROR: Alfred PDF Tools[Script Filter] Code 1: Traceback (most recent call last): ... File "/Users/zeitlings/Library/Application Support/Alfred/Alfred.alfredpreferences/workflows/user.workflow.809C4DC3-843E-403D-8955-9DEF46A73157/Crypto/Util/_raw_api.py", line 309, in load_pycryptodome_raw_lib raise OSError("Cannot load native module '%s': %s" % (name, ", ".join(attempts))) OSError: Cannot load native module 'Crypto.Cipher._raw_ecb': Not found '_raw_ecb.cpython-39-darwin.so', Not found '_raw_ecb.abi3.so', Cannot load '_raw_ecb.so': dlopen(/Users/zeitlings/Library/Application Support/Alfred/Alfred.alfredpreferences/workflows/user.workflow.809C4DC3-843E-403D-8955-9DEF46A73157/Crypto/Util/../Cipher/_raw_ecb.so, 0x0006): tried: '/Users/zeitlings/Library/Application Support/Alfred/Alfred.alfredpreferences/workflows/user.workflow.809C4DC3-843E-403D-8955-9DEF46A73157/Crypto/Util/../Cipher/_raw_ecb.so' (mach-o file, but is an incompatible architecture (have 'x86_64', need 'arm64e')), '/Users/zeitlings/Library/Application Support/Alfred/Alfred.alfredpreferences/workflows/user.workflow.809C4DC3-843E-403D-8955-9DEF46A73157/Crypto/Cipher/_raw_ecb.so' (mach-o file, but is an incompatible architecture (have 'x86_64', need 'arm64e'))
  5. Hey, same errors here on M1 Pro / with arm64. I'm sure you have already noticed the incompatible dependency: ❯ file $(which python3) /opt/homebrew/bin/python3: Mach-O 64-bit executable arm64 /usr/bin/env python3 links fine: Python 3.9.13 (main, May 24 2022, 21:13:51) [Clang 13.1.6 (clang-1316.0.21.2)] on darwin ### Workflow version 4.2 ### Alfred version 5.0.1 ### Python version 3.9.13 ### PyCryptodome version 3.15.0 ### macOS version 12.4 ### Architecture arm64
  6. Aah, neat. Merci Aha! I see. What I am interested in are different options to replace the input and thus allow for different ways to act on some piece of base information. For that purpose I agree, 'autocompleting' by hitting ⇥ would be awkward. However, when I set the validity of some item to false, actioning it or hitting ⏎ will also trigger the autocomplete. Allowing that for mods, I think, would not be awkward at all. You've mentioned alfred-cal above. As it happens, my experiments continued with a calendar++ version of it. I'll use it as an example for how I'd like to leverage modifier-specific autocomplete; have a look at this: Here I'm integrating calendar events, where the digits of those days with events have an underscore. By actioning a week-of-the-month row that has events, the events of that week are listed (and actioning here will bring you to the event or the day). The original alfred-cal calendar attempts to show the correlating week in the calendar when the row is hit. While this example is somewhat trivial, if the autocomplete could only be triggered while ⌘-modifying the row, the original behaviour could be preserved. Now it's just the other way around. But that's the idea: Allowing for different intents to be realized depending on the modifier currently used, say, ⌘⏎ -> show events, ⌥⏎ -> show tasks, ⌃⏎ -> show only birthdays, specific calendars, etc. Ignoring ⇥ as a potential trigger for modifier-autocompletes but allowing ⏎ would be quite useful.
  7. Hey vitor, thanks for the clarification! I will look into inbound configurations and external triggers. I am still stuck at this. According to the documentation I can set arg, subtitle, icon, variables and valid for modifiers. If I just add autocomplete as a parameter, Alfred doesn't complain but actioning the item or hitting tab with the mod active does nothing. Is there a trick to it? About the window bounds question, I found a way to extract them with Swift and some core SDKs. Here's a functioning snippet in case someone stumbles over this and has use for it: import CoreGraphics import Foundation.NSArray func getAlfredWindowWidth() -> Float? { let options: CGWindowListOption = .init([.excludeDesktopElements, .optionOnScreenOnly]) if let windowInfo: [[String : AnyObject]] = CGWindowListCopyWindowInfo(options, CGWindowID(0)) as NSArray? as? [[String: AnyObject]], let alfredWindow: [String: AnyObject] = windowInfo.first(where: { info in (info["kCGWindowOwnerName"] as? String) == "Alfred" ? true : false }), let bounds: AnyObject = alfredWindow["kCGWindowBounds"], let frame: CGRect = .init(dictionaryRepresentation: bounds as! CFDictionary) { return Float(frame.width) } return nil } getAlfredWindowWidth() // yields the window width + padding p.s. what's the formatting syntax for `inline code` call outs like this: 'autocomplete and mods'? Now I just copy-pasted.
  8. Hey, I noticed that with Alfred 5 we can write scripts directly in Swift - no need for compiling an executable! This got me excited and I ended up trying and implementing several things. At some point, I decided it was about time I got at grips with the ins and outs of Script Filters. I took inspiration from @deanishe in two respects. I really like the behavior of his Unicode workflow and wanted to create something that performed similarly, and since his Duden workflow is broken, reviving it seems like a good place to start. I was able to recreate most of what I had in mind. However, there is something that eludes me still. With the Unicode workflow, once a selection is made and the hex representation gets expanded (.u cat -> .u 0x1F408 / ), the previous state immediately gets restored if I hit backspace. Something appears to immediately trigger an autocomplete as soon as the structure of ".u 0x1F408 / " is compromised: How do I instantly trigger some autocomplete without user confirmation (hitting enter on some returned item)? I have attached two previews of the Duden workflow I am experimenting on. At (1), when I hit backspace into (Geige /syn -> Geige /sy⌫) , I would like the previous state to be restored (Geige / ). While I am at it, a few more questions: Is there a way to override or set an autocomplete with a modifier? Say, with cmd "A" becomes the autocomplete, with alt "B". Is there a way to influence the appearance of specific items, say, set the background color, font, text size? Is there a way to get the NSRect for the items (or perhaps just the window width)? This could be interesting for playing with vertical alignment (center, trailing). That's all for now. Merci! 1 2
  9. I've been looking into this a little bit. Without writing the workflow right away myself, I' d still like to give some insights. tl:dr: use a combination of sips and ffmpeg. There are three macOS native utilities that at first sight promise a solution: avconvert, afconvert and sips. avconvert seems to work quite well actually. The problem is the limited presets and the absence of decent compression, as far as I can tell. For creating 100MB large, 2min long mp4s, this is nice. What's perhaps interesting about this is that it lets you use apples proprietary HEVC (h.265) and ProRes codecs. For everyday use cases this is irrelevant. afconvert appears to be extremely limited as in, it can read mp3 but will not write out mp3 files. I stopped looking into it here. Looking at `afconvert --help` seems to suggest that there has been no development since 2013. There is apple's SDK AVFAudio with which you could perhaps write an executable to perform conversions... if you happen to really really want to do that. Without having tested it thoroughly (or at all) sips looks great out of the box! Cf. `sips --formats` for writable image formats. I also briefly tested VLC's CLI video transcoding and it works pretty well. However, the effort required to fine-tune the parameters could make it difficult to fit into an Alfred workflow. This leaves us with ffmpeg, which has to be installed: `$brew install ffmpeg`. Looks great. I' would start with sips for images and ffmpeg for the rest.
  10. It didn't work for me with Brave Browser, so I threw together a replacement. This should handle any browser you configure the workflow to consider: https://github.com/zeitlings/alfred-set-default-browser. Note however, that it is not thoroughly tested. More information in the README.
  11. LaTeX ⟷ Markdown Alfred Workflow Quickly convert Markdown to LaTeX or vice versa from your clipboard with Pandoc. Description A simple routine to convert snippets of markdown to LateX from your clipboard or vice versa. The workflow creates either a *.md or *.tex file relative to your input and at the location you choose. The file is converted with Pandoc by calling it from the terminal. The converted file subsequently gets output at the same place. Existing files will be overwritten. Pandoc is key and has to be installed: $ brew install pandoc GitHub: github.com/zeitlings/alfred-latex-md/raw/master/LaTeX-MD.alfredworkflow (direct download) github.com/zeitlings/alfred-latex-md Alternative Method: Clipboard only An altered version that removes all created files and copies the converted output back to your clipboard: Convert markdown to LateX from your clipboard or vice versa. The workflow creates either a *.md or *.tex file at your ~/Documents folder. The file will be converted with pandoc by calling it from the Terminal. The contents of the converted file will be copied to your clipboard. Both files will be moved to your trash bin. GitHub: github.com/zeitlings/alfred-latex-md-direct/raw/master/LaTeX-MD-direct.alfredworkflow (direct download) github.com/zeitlings/alfred-latex-md-direct _____________ The workflow is piggybagging off these two: https://www.alfredforum.com/topic/459-workflow-create-a-new-text-file-with-clipboard-content/ https://www.alfredforum.com/topic/394-fixed-create-a-new-file-in-the-finder/ https://pandoc.org/
×
×
  • Create New...