Skip to content

Commit 7a5fed1

Browse files
author
Jean-Claude Jung
committed
Alfred Gallery compliant
1 parent 0321c9e commit 7a5fed1

File tree

3 files changed

+1
-113
lines changed

3 files changed

+1
-113
lines changed

.DS_Store

6 KB
Binary file not shown.

Image Shrinker.alfredworkflow

-1.25 KB
Binary file not shown.

src/info.plist

Lines changed: 1 addition & 113 deletions
Original file line numberDiff line numberDiff line change
@@ -108,16 +108,6 @@
108108
<key>vitoclose</key>
109109
<false/>
110110
</dict>
111-
<dict>
112-
<key>destinationuid</key>
113-
<string>7AEEE496-6258-4811-A26B-16F2133EA5C7</string>
114-
<key>modifiers</key>
115-
<integer>0</integer>
116-
<key>modifiersubtext</key>
117-
<string></string>
118-
<key>vitoclose</key>
119-
<false/>
120-
</dict>
121111
</array>
122112
<key>B8C7AC3E-494B-4E67-87EE-F949A3A7D88A</key>
123113
<array>
@@ -450,97 +440,6 @@
450440
<key>version</key>
451441
<integer>1</integer>
452442
</dict>
453-
<dict>
454-
<key>config</key>
455-
<dict>
456-
<key>concurrently</key>
457-
<false/>
458-
<key>escaping</key>
459-
<integer>0</integer>
460-
<key>script</key>
461-
<string># THESE VARIABLES MUST BE SET. SEE THE ONEUPDATER README FOR AN EXPLANATION OF EACH.
462-
readonly remote_info_plist="https://raw.githubusercontent.com/Acidham/alfred-image-shrinker/main/src/info.plist"
463-
readonly workflow_url="Acidham/alfred-image-shrinker"
464-
readonly download_type='github_release'
465-
readonly frequency_check='4'
466-
467-
# FROM HERE ON, CODE SHOULD BE LEFT UNTOUCHED!
468-
function abort {
469-
echo "${1}" &gt;&amp;2
470-
exit 1
471-
}
472-
473-
function url_exists {
474-
curl --silent --location --output /dev/null --fail --range 0-0 "${1}"
475-
}
476-
477-
function notification {
478-
readonly local notificator="$(find . -type d -name 'Notificator.app')"
479-
if [[ -n "${notificator}" ]]; then
480-
"${notificator}/Contents/Resources/Scripts/notificator" --message "${1}" --title "${alfred_workflow_name}" --subtitle 'A new version is available'
481-
return
482-
fi
483-
484-
readonly local terminal_notifier="$(find . -type f -name 'terminal-notifier')"
485-
if [[ -n "${terminal_notifier}" ]]; then
486-
"${terminal_notifier}" -title "${alfred_workflow_name}" -subtitle 'A new version is available' -message "${1}"
487-
return
488-
fi
489-
490-
osascript -e "display notification \"${1}\" with title \"${alfred_workflow_name}\" subtitle \"A new version is available\""
491-
}
492-
493-
# Local sanity checks
494-
readonly local_info_plist='info.plist'
495-
readonly local_version="$(/usr/libexec/PlistBuddy -c 'print version' "${local_info_plist}")"
496-
497-
[[ -n "${local_version}" ]] || abort 'You need to set a workflow version in the configuration sheet.'
498-
[[ "${download_type}" =~ ^(direct|page|github_release)$ ]] || abort "'download_type' (${download_type}) needs to be one of 'direct', 'page', or 'github_release'."
499-
[[ "${frequency_check}" =~ ^[0-9]+$ ]] || abort "'frequency_check' (${frequency_check}) needs to be a number."
500-
501-
# Check for updates
502-
if [[ $(find "${local_info_plist}" -mtime +"${frequency_check}"d) ]]; then
503-
if ! url_exists "${remote_info_plist}"; then abort "'remote_info_plist' (${remote_info_plist}) appears to not be reachable."; fi # Remote sanity check
504-
505-
readonly tmp_file="$(mktemp)"
506-
curl --silent --location --output "${tmp_file}" "${remote_info_plist}"
507-
readonly remote_version="$(/usr/libexec/PlistBuddy -c 'print version' "${tmp_file}")"
508-
509-
if [[ "${local_version}" == "${remote_version}" ]]; then
510-
touch "${local_info_plist}" # Reset timer by touching local file
511-
exit 0
512-
fi
513-
514-
if [[ "${download_type}" == 'page' ]]; then
515-
notification 'Opening download page…'
516-
open "${workflow_url}"
517-
exit 0
518-
fi
519-
520-
download_url="$([[ "${download_type}" == 'github_release' ]] &amp;&amp; curl --silent "https://api.github.com/repos/${workflow_url}/releases/latest" | grep 'browser_download_url' | head -1 | sed -E 's/.*browser_download_url": "(.*)"/\1/' || echo "${workflow_url}")"
521-
522-
if url_exists "${download_url}"; then
523-
notification 'Downloading and installing…'
524-
curl --silent --location --output "${HOME}/Downloads/${alfred_workflow_name}.alfredworkflow" "${download_url}"
525-
open "${HOME}/Downloads/${alfred_workflow_name}.alfredworkflow"
526-
else
527-
abort "'workflow_url' (${download_url}) appears to not be reachable."
528-
fi
529-
fi</string>
530-
<key>scriptargtype</key>
531-
<integer>1</integer>
532-
<key>scriptfile</key>
533-
<string></string>
534-
<key>type</key>
535-
<integer>0</integer>
536-
</dict>
537-
<key>type</key>
538-
<string>alfred.workflow.action.script</string>
539-
<key>uid</key>
540-
<string>7AEEE496-6258-4811-A26B-16F2133EA5C7</string>
541-
<key>version</key>
542-
<integer>2</integer>
543-
</dict>
544443
</array>
545444
<key>readme</key>
546445
<string># Image Shrinker
@@ -604,17 +503,6 @@ The workflow accepts one image file
604503
<key>ypos</key>
605504
<real>195</real>
606505
</dict>
607-
<key>7AEEE496-6258-4811-A26B-16F2133EA5C7</key>
608-
<dict>
609-
<key>colorindex</key>
610-
<integer>12</integer>
611-
<key>note</key>
612-
<string>OneUpdater</string>
613-
<key>xpos</key>
614-
<real>1455</real>
615-
<key>ypos</key>
616-
<real>455</real>
617-
</dict>
618506
<key>8E04C74A-AFA3-45A5-AB78-FBD21C7699C8</key>
619507
<dict>
620508
<key>xpos</key>
@@ -685,7 +573,7 @@ The workflow accepts one image file
685573
<key>variablesdontexport</key>
686574
<array/>
687575
<key>version</key>
688-
<string>1.0</string>
576+
<string>1.1</string>
689577
<key>webaddress</key>
690578
<string>https://github.com/Acidham/alfred-image-shrinker</string>
691579
</dict>

0 commit comments

Comments
 (0)