Skip to content

Commit

Permalink
prep for release 2.5.0
Browse files Browse the repository at this point in the history
  • Loading branch information
luckman212 committed Apr 26, 2024
1 parent 51f5ee4 commit bfcb758
Show file tree
Hide file tree
Showing 5 changed files with 762 additions and 96 deletions.
Binary file added 15A2426A-6614-4325-9014-873CE2FCAEEE.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added 9D05394A-A5F5-4A2B-8AA7-3C06528411D3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
14 changes: 11 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,21 @@
# ClipSaver

This workflow is triggered with the `cs` keyword by default.

As of version 2.4.x, the workflow also supports Alfred 5.5's new "Grid View" layout for previewing and actioning images.
This workflow is triggered with the `cs` keyword by default. You can change the keyword if desired via the configuration window.

It presents images from Alfred's clipboard history via a Script Filter, and allows selecting an image to be extracted, converted to a format of your choice (default is PNG) and placed in a folder of your choosing (default is on the Desktop, in a folder called `saved_clips`). You can optionally set the `save_to_current` environment variable to have the workflow save to the currently active Finder window.

Upon success, the original clipboard entry as well as the .tiff from Alfred's database will be removed if you have `delete_after_convert` set to true (File List objects in the clipboard history will remain untouched).

Some features require [CleanShot](https://cleanshot.com/) to be installed. If you don't have CleanShot, you can still use the other features of the workflow.
- Holding ⇧shift while actioning from the Grid View will Pin (float) the selected images to the screen
- Holding ⌥option will open the images in the Annotation (edit) tool.

## Grid View (Alfred 5.5 only)

As of version 2.4, the workflow also supports Alfred 5.5's new "Grid View" layout for previewing and actioning images. You can drag and drop images out of the grid with the mouse. While in Grid mode, press ⌘0 to toggle a larger view. You can use the File Buffer to select multiple images and action them.

> _If the File Buffer contains contents, they will be used instead of the "last selection"._
## Workflow Configuration

All configuration is optional. The workflow should work "out of the box" without configuring any of these items. They are here for advanced users only.
Expand Down
46 changes: 46 additions & 0 deletions cleanshot.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
#!/bin/zsh --no-rcs

# workaround for CleanShot bug
# open-annotate verb does not work for TIFFs
# bugreport has been filed!
_convert_to_png() {
temp_dir=${temp_dir:-/private/tmp/converted_images}
if [[ ! -d ${temp_dir} ]]; then
mkdir -p "${temp_dir}"
else
find "${temp_dir}" -type f -ctime +10m -delete 2>/dev/null
fi
for img_pathname in "$@"; do
[[ -r ${img_pathname} ]] || continue
img_basename=${img_pathname##*/}
img_noext="${img_basename%.*}"
out_fname="$temp_dir/${img_noext}.png"
if /usr/bin/sips 2>&1 \
--setProperty format png \
--out "${out_fname}" \
"${img_pathname}"; then
EXCLUDE+=( "$img_pathname" )
FILEARRAY+=( "$out_fname" )
fi
done
}

action=${action:-edit}
#echo 1>&2 "action: $action"
IFS=$'\t' read -A FILEARRAY <<<"$1"
EXCLUDE=()

case "$action" in
float|pin)
VERB='pin'
;;
edit|annotate)
VERB='open-annotate'
_convert_to_png "${FILEARRAY[@]}"
;;
esac

for f in ${FILEARRAY:|EXCLUDE}; do
echo 1>&2 "processing: $f"
open "cleanshot://${VERB}?filepath=$f"
done
Loading

0 comments on commit bfcb758

Please sign in to comment.