zeitlings / alfred-workflows

Collected Alfred Workflows & Proof of Concept

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool


Collected Workflows

This is a collection of smaller workflows, experiments, and demonstrations of interesting concepts for writing automations with the Alfred App.

Some workflows live in their own repository:

Buy Me a Coffee at ko-fi.com


Table of Contents


1. Workflows

1.1. Duden Workflow

Search, navigate and view information from duden.de German spelling dictionary.
  • shift ⇧ or cmd ⌘+Y: Get QuickLook previews for the landing page, grammar, and synonyms
  • cmd ⌘+L to view the full entry contents.
  • Action synonymes to list all synonyms. Action any synonym to view the entry for it.
  • Action examples or idioms to list all that are available.

Credits: SwiftSoup


1.2. What Unicode character is this?

The What Unicode character is this? workflow tells you which unicode character it is. Given a character or string, you will get the unicode code points, the scalar names and general categories.

Example

  • KATAKANA LETTER TU
  • U+30C4
  • Other Letter

Modifiers

  • ⌘ cmd yields \u{30C4} (swift, ES6 formatted)
  • ⌥ opt yields \u30C4 (python, go formatted)
  • ⌃ ctrl yields ツ (HTML entity)
  • ⇧ shift yields 0x30C4 (hex literal)

Inverse

Given a hex value either raw or in any of the above formattings will return its corresponding unicode character.

  • whatisit? \u{1F914} yields info for 🤔


1.3. Roman Numeral Converter

Convert Roman numerals to decimal and vice versa. Accepts Arabic numbers in the range 1 to 3999.


1.4. DEVONthink ←→ PDF Expert

Get either the DEVONthink 3 reference URL from PDF Expert, that is the x-devonthink-item page link for the active document opened in PDF Expert, the selection link if you have text selected, or the annotation link if your selection intersects an annotation and checking for annotations is enabled.

The PDF, of course, has to live in one of your open DEVONthink databases.

  • cmd ⌘ to open the PDF on the same page in DEVONthink
  • .xdev to enable or disable opening the document in DEVONthink when using the hotkey

Expected result A
x-devonthink-item://1D7FA99A-AAFF-4883-9853-F0666A650400?page=6
Expected result B
x-devonthink-item://1D7FA99A-AAFF-4883-9853-F0666A650400?page=6&start=66&length=9&search=selection
Expected result C
x-devonthink-item://1D7FA99A-AAFF-4883-9853-F0666A650400?page=6&annotation=Squiggly&x=212&y=406

Known issues

  • Fails with documents opened in PDF Expert split view
xdev2.0.0.mp4

1.5. Define Word - A Better Dictionary

Customizable Dictionary with Quicklook Preview - and Dark Mode.

ctrl to see the dictionary associated with the entry
cmd + ⏎ to paste a word to the frontmost application (spell checker)
shift or cmd+Y to preview the dictionary entry
cmd+C to copy the dictionary entry's plain text to the clipboard
cmd+L to view the plain text as large type

You can define dictionaries for lookups, set the font size of the previews, or manually select a dictionary to use. The previews reflect the global appearance, i.e. they have a dark mode. The workflow also includes a preset for looking up synonyms of a word and a convenient keyboard shortcut for quick lookups. To use the workflow as a multilingual spell checker, you can use the cmd modifier when actioning the entry to paste the word to the frontmost application.

1.6. AlfredOCR

No external dependencies are required to perform the OCR.

1.6.1 Alfred OCR Light

The workflow allows you to copy text from images using optical character recognition. Take a snapshot with your mouse or trackpad and the recognized text is automatically copied to the clipboard.
You can also extract text from images sent to the workflow's File Action.

1.6.2 Alfred OCR+

The workflow allows you to copy text from images, or to convert PDF files into searchable PDF documents using optical character recognition, and to apply compression to PDF documents.

1 / Snapshot
Take a snapshot with your mouse or trackpad and the recognized text is automatically copied to the clipboard.

  • Default shortcut: 6
  • Default keyword: ocr

2 / PDF Document

  • To convert a PDF into a searchable PDF document, pass it to the workflow's Universal Action.

    • To compress the resulting PDF, pass the source document on while pressing the ⌘+⇧ keys.
    • To open the resulting PDF, pass the source document on while pressing the ⌥+⇧ keys.
    • To force the replacement of a source document, pass it on while pressing the ⌥+⌘ keys.
  • To compress a PDF without performing OCR, pass it to the Compress PDF Document File Action.

  • To view the progress tracker, re-enable the workflow with the Keyword (default: ocr).

1.7. Favorites

Add files and folders to your list of favorites by using the workflow's Universal Action. Quickly find them again by activating the workflow with the Keyword (default: fav) or by setting a hotkey of your choice.

  • Hit enter or cmd+O to open a file or folder.
  • Add items with the workflow’s Universal Action.
  • Modifiers:
    • ctrl: Show full Path
    • cmd: Reveal in Finder
    • opt: Browse in Alfred
    • cmd+shift: Move up
    • opt+shift: Move down
    • fn: Remove from Favorites
    • shift or cmd+Y: Quicklook Preview

1.8. New File

The workflow allows you to quickly create new files in the Finder.

If the post-haste behavior is enabled, new files are created the same way as folders are when you use the shortcut (default: ⌥+⇧+N). Otherwise you will be prompted with the input mask where you can configure the file name and type.

The workflow will pick up on your location in the Finder and create the new file there. If you use the keyword, the most recently used Finder window will be selected as the destination. If no Finder window is currently open, the file will be created in the configurable fallback location.

Bonus: In addition to all plain-text type files, the workflow can also quickly create docx, doc, odt, rtf and rtfd documents for you.

Modifiers

  • Hold to view the full file path.
  • Hold ⌘+⇧ before hitting enter to enforce creating the file with clipboard contents.
  • Hold ⌥+⇧ before hitting enter to enforce creating the file without clipboard contents.

1.9. Keyboard Brightness

Adjust the keyboard backlight brightness either by using the keyword or by setting up custom shortcuts.

When using the keyword

  • type > or + to increase the brightness
  • type < or - to decrease the brightness

1.10. GIF from Video

The workflow allows you to convert video of popular formats to animated GIFs. To do this, it uses ffmpeg as a dependency.

Usage

Either send a video to the workflow's File Action or invoke the workflow using the keyword and search for the video file you want to convert. Then select the image size you want the resulting GIF to have from the list to start the conversion.

1.11. Bluetooth Device Battery

View the battery charge status of connected Bluetooth devices
(macOS 13.0+)

1.12. QResolve

Resolve and open links from QR codes

Usage

A / Take a snapshot of the QR code you want to open the link to

  • Default keyword: qrlink
  • Default shortcut: ⌘+⇧+7

B / Send an image containing the QR code to the workflow's File Action

1.13. GIF from Images

The workflow allows you to convert a series of still images into animated GIFs. For this, it uses ImageMagick as a dependency.

Usage

Send a series of still images to the workflow's File Action to create an animated GIF. The smallest image determines the dimensions of the result. All source images are assumed to be of the same file type, e.g. jpg or png.

1.14 Extract Keywords

Extract keywords and keyphrases from articles, books or other documents with YAKE!

Usage

  • Send PDF, docx, doc, rtf or txt documents to the workflow's File Actions
  • Pass the text from your selection in macOS on to the workflow's Universal Action
  • Use the keyword and paste your text (default: kw)

Dependencies

The workflow relies on Python3 to install the YAKE standalone.

YAKE!

pdftotext

1.15 Color Picker

Pick a color to get its hex, rgba, hsl representation or NSColor initializer.

Usage

Activate the Color Sampler with the keyword (default: cp) and pick the desired color.

Color History

To review previously picked colors, activate the workflow with the keyword preceded by a colon (default: :cp).


2. Proof of Concept & Demos

2.1. Extended Hotkeys

Modifier Palettes & Double Tap Hotkeys. Proof of concept and demo implementation of modifier palettes to invoke actions on consecutive keystrokes in Alfred.

Modifier Palette example behavior.

  • ⌥O, ⌥K To trigger action A.
  • ⌥I, ⌥K To trigger action B.

Double-Tap Hotkey example behavior

  • ⌃+, ⌃+ To trigger action.

Details

The core idea is to inject environment variables into the workflow configuration and to modify them with some delay.

  • To set up modifier palettes, all you have to do is define an identifier on any hotkey, ⌥O, such as "openA". This is the "text" argument that the hotkey passes on as {query}. Set the identifier to some environment variable, say "gate", and use a downstream conditional object triggered by a different hotkey, ⌥K, to check if the variable ({var:gate}) is equal to the identifier openA. Any action that you make depend on this condition will be triggered iff gate is equal to openA, i.e. if you have recently tapped the hotkey associated with the identifier.

  • To set up double-tap hotkeys, proceed in the same way, defining an identifier for the hotkey's "text" argument. For each double tap hotkey, an environment variable is injected that is either 0 or 1 for inactive or active.

Disclaimer: Alfred may crash if you get the timing of the keystrokes just right. This is due to a data race where the same variable ("gate") is accessed and modified by different threads at the same time. Also, for the double-tap hotkeys, there is some "bleed" into the other hotkeys with the way it is set up in the demo. Tapping a, then b, will also trigger b, instead of having to tap b twice.


2.2. Permission Handler

An example of how to handle permissions gracefully for your executables. (For now, take a look at the Duden Workflow that implements the permission handler).

2.3. GUI Input Experiment

Run a graphical prompt and read the input. Proof of concept for using NSWindow and SwiftUI components to get user input through a graphical prompt and then use it in the Alfred app - or on the command line.

2.4. Heads-up Display

Demo for displaying notifications on a heads-up display.
The script takes two arguments:

  • The text to display
  • The width of the prompt

About

Collected Alfred Workflows & Proof of Concept

License:MIT License


Languages

Language:Swift 100.0%