├── LICENSE
├── README.md
└── Workflow
├── icon.png
├── images
└── about
│ └── updateat.png
└── info.plist
/LICENSE:
--------------------------------------------------------------------------------
1 | BSD 3-Clause License
2 |
3 | Copyright (c) 2021, Running with Crayons Ltd
4 | All rights reserved.
5 |
6 | Redistribution and use in source and binary forms, with or without
7 | modification, are permitted provided that the following conditions are met:
8 |
9 | 1. Redistributions of source code must retain the above copyright notice, this
10 | list of conditions and the following disclaimer.
11 |
12 | 2. Redistributions in binary form must reproduce the above copyright notice,
13 | this list of conditions and the following disclaimer in the documentation
14 | and/or other materials provided with the distribution.
15 |
16 | 3. Neither the name of the copyright holder nor the names of its
17 | contributors may be used to endorse or promote products derived from
18 | this software without specific prior written permission.
19 |
20 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
23 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
24 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
26 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
27 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
28 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | #
Update Automation Tasks Alfred Workflow
2 |
3 | Update Automation Tasks During Alfred 5 Early Access
4 |
5 | ⤓ Download Workflow
6 |
7 | ## About
8 |
9 | Automation Tasks are one of the many new features of Alfred 5, [which is currently in Early Access](https://www.alfredapp.com/help/getting-started/early-access/). For the time being you need this Workflow to install and update them. By Alfred 5’s General Release, the process will be automatic.
10 |
11 | Run `updateat` to bring your local copy of Automation Tasks up-to-date.
12 |
13 | 
14 |
15 | To learn more about Automation Tasks, [see their help page](https://www.alfredapp.com/help/workflows/automations/).
16 |
17 | ⤓ Download Workflow
18 |
--------------------------------------------------------------------------------
/Workflow/icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/alfredapp/update-automation-tasks-workflow/a525b5dab62f1110d3351f5f2f973d198e3d5a75/Workflow/icon.png
--------------------------------------------------------------------------------
/Workflow/images/about/updateat.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/alfredapp/update-automation-tasks-workflow/a525b5dab62f1110d3351f5f2f973d198e3d5a75/Workflow/images/about/updateat.png
--------------------------------------------------------------------------------
/Workflow/info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | bundleid
6 | com.alfredapp.updateautomationtasks
7 | connections
8 |
9 | 36CF8038-7C50-4A13-9975-E868191C743B
10 |
11 |
12 | destinationuid
13 | F1EFE58B-AFB7-435C-8183-9D556910E684
14 | modifiers
15 | 0
16 | modifiersubtext
17 |
18 | vitoclose
19 |
20 |
21 |
22 | F1EFE58B-AFB7-435C-8183-9D556910E684
23 |
24 |
25 | destinationuid
26 | 5AF09E6E-0727-488A-A05F-25A57E355A87
27 | modifiers
28 | 0
29 | modifiersubtext
30 |
31 | vitoclose
32 |
33 |
34 |
35 | destinationuid
36 | 9AFB6097-23B5-4179-935D-9086BDCA6767
37 | modifiers
38 | 0
39 | modifiersubtext
40 |
41 | vitoclose
42 |
43 |
44 |
45 |
46 | createdby
47 | Vítor Galvão
48 | description
49 | Update Automation Tasks During Alfred 5 Early Access
50 | disabled
51 |
52 | name
53 | Update Automation Tasks
54 | objects
55 |
56 |
57 | config
58 |
59 | argumenttype
60 | 2
61 | keyword
62 | updateat
63 | subtext
64 |
65 | text
66 | Update Automation Tasks
67 | withspace
68 |
69 |
70 | type
71 | alfred.workflow.input.keyword
72 | uid
73 | 36CF8038-7C50-4A13-9975-E868191C743B
74 | version
75 | 1
76 |
77 |
78 | config
79 |
80 | concurrently
81 |
82 | escaping
83 | 102
84 | script
85 | readonly repo_name='automation-tasks'
86 | readonly zip_url="https://github.com/alfredapp/${repo_name}/archive/refs/heads/main.zip"
87 | readonly automation_dir="${HOME}/Library/Application Support/Alfred/Automation"
88 | readonly tmp_dir="$(mktemp -d)"
89 |
90 | # Trash old directory
91 | /usr/bin/osascript -l JavaScript -e "
92 | const tasksURL = $.NSURL.alloc.initFileURLWithPath('${automation_dir}' + '/Tasks')
93 | $.NSFileManager.defaultManager.trashItemAtURLResultingItemURLError(tasksURL, undefined, undefined)
94 | "
95 |
96 | # Download and unpack new zip
97 | mkdir -p "${automation_dir}"
98 | curl --location --no-buffer "${zip_url}" | ditto -xk - "${tmp_dir}"
99 | mv "${tmp_dir}/${repo_name}-main/Tasks" "${automation_dir}"
100 |
101 | # Cleanup
102 | rm -rf "${tmp_dir}"
103 | scriptargtype
104 | 1
105 | scriptfile
106 |
107 | type
108 | 5
109 |
110 | type
111 | alfred.workflow.action.script
112 | uid
113 | F1EFE58B-AFB7-435C-8183-9D556910E684
114 | version
115 | 2
116 |
117 |
118 | config
119 |
120 | concurrently
121 |
122 | escaping
123 | 0
124 | script
125 | # Special values for OneUpdater reuse
126 | readonly workflow_webaddress="$(/usr/libexec/PlistBuddy -c 'print webaddress' './info.plist')"
127 | readonly workflow_repo="$(basename "$(dirname "${workflow_webaddress}")")/$(basename "${workflow_webaddress}")"
128 |
129 | # THESE VARIABLES MUST BE SET. SEE THE ONEUPDATER README FOR AN EXPLANATION OF EACH.
130 | readonly remote_info_plist="${workflow_webaddress}/raw/main/Workflow/info.plist"
131 | readonly workflow_url="${workflow_repo}"
132 | readonly download_type='github_release'
133 | readonly frequency_check='1'
134 |
135 | # FROM HERE ON, CODE SHOULD BE LEFT UNTOUCHED!
136 | function abort {
137 | echo "${1}" >&2
138 | exit 1
139 | }
140 |
141 | function url_exists {
142 | curl --silent --location --output /dev/null --fail --range 0-0 "${1}"
143 | }
144 |
145 | function notification {
146 | local -r notificator="$(find . -type d -name 'Notificator.app')"
147 | if [[ -n "${notificator}" ]]; then
148 | "${notificator}/Contents/Resources/Scripts/notificator" --message "${1}" --title "${alfred_workflow_name}" --subtitle 'A new version is available'
149 | return
150 | fi
151 |
152 | local -r terminal_notifier="$(find . -type f -name 'terminal-notifier')"
153 | if [[ -n "${terminal_notifier}" ]]; then
154 | "${terminal_notifier}" -title "${alfred_workflow_name}" -subtitle 'A new version is available' -message "${1}"
155 | return
156 | fi
157 |
158 | osascript -e "display notification \"${1}\" with title \"${alfred_workflow_name}\" subtitle \"A new version is available\""
159 | }
160 |
161 | # Local sanity checks
162 | readonly local_info_plist='info.plist'
163 | readonly local_version="$(/usr/libexec/PlistBuddy -c 'print version' "${local_info_plist}")"
164 |
165 | [[ -n "${local_version}" ]] || abort 'You need to set a workflow version in the configuration sheet.'
166 | [[ "${download_type}" =~ ^(direct|page|github_release)$ ]] || abort "'download_type' (${download_type}) needs to be one of 'direct', 'page', or 'github_release'."
167 | [[ "${frequency_check}" =~ ^[0-9]+$ ]] || abort "'frequency_check' (${frequency_check}) needs to be a number."
168 |
169 | # Check for updates
170 | if [[ $(find "${local_info_plist}" -mtime +"${frequency_check}"d) ]]; then
171 | if ! url_exists "${remote_info_plist}"; then abort "'remote_info_plist' (${remote_info_plist}) appears to not be reachable."; fi # Remote sanity check
172 |
173 | readonly tmp_file="$(mktemp)"
174 | curl --silent --location --output "${tmp_file}" "${remote_info_plist}"
175 | readonly remote_version="$(/usr/libexec/PlistBuddy -c 'print version' "${tmp_file}")"
176 |
177 | if [[ "${local_version}" == "${remote_version}" ]]; then
178 | touch "${local_info_plist}" # Reset timer by touching local file
179 | exit 0
180 | fi
181 |
182 | if [[ "${download_type}" == 'page' ]]; then
183 | notification 'Opening download page…'
184 | open "${workflow_url}"
185 | exit 0
186 | fi
187 |
188 | download_url="$([[ "${download_type}" == 'github_release' ]] && 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}")"
189 |
190 | if url_exists "${download_url}"; then
191 | notification 'Downloading and installing…'
192 | curl --silent --location --output "${HOME}/Downloads/${alfred_workflow_name}.alfredworkflow" "${download_url}"
193 | open "${HOME}/Downloads/${alfred_workflow_name}.alfredworkflow"
194 | else
195 | abort "'workflow_url' (${download_url}) appears to not be reachable."
196 | fi
197 | fi
198 | scriptargtype
199 | 1
200 | scriptfile
201 |
202 | type
203 | 0
204 |
205 | type
206 | alfred.workflow.action.script
207 | uid
208 | 5AF09E6E-0727-488A-A05F-25A57E355A87
209 | version
210 | 2
211 |
212 |
213 | config
214 |
215 | lastpathcomponent
216 |
217 | onlyshowifquerypopulated
218 |
219 | removeextension
220 |
221 | text
222 | Auomation Tasks have been updated
223 | title
224 | Update Complete
225 |
226 | type
227 | alfred.workflow.output.notification
228 | uid
229 | 9AFB6097-23B5-4179-935D-9086BDCA6767
230 | version
231 | 1
232 |
233 |
234 | readme
235 | Automation Tasks are one of the many new features of Alfred 5, [which is currently in Early Access](https://www.alfredapp.com/help/getting-started/early-access/). For the time being you need this Workflow to install and update them. By Alfred 5’s General Release, the process will be automatic.
236 |
237 | Run `updateat` to bring your local copy of Automation Tasks up-to-date.
238 |
239 | 
240 |
241 | To learn more about Automation Tasks, [see their help page](https://www.alfredapp.com/help/workflows/automations/).
242 | uidata
243 |
244 | 36CF8038-7C50-4A13-9975-E868191C743B
245 |
246 | xpos
247 | 65
248 | ypos
249 | 45
250 |
251 | 5AF09E6E-0727-488A-A05F-25A57E355A87
252 |
253 | colorindex
254 | 12
255 | note
256 | OneUpdater
257 | xpos
258 | 500
259 | ypos
260 | 45
261 |
262 | 9AFB6097-23B5-4179-935D-9086BDCA6767
263 |
264 | xpos
265 | 500
266 | ypos
267 | 200
268 |
269 | F1EFE58B-AFB7-435C-8183-9D556910E684
270 |
271 | xpos
272 | 280
273 | ypos
274 | 45
275 |
276 |
277 | userconfigurationconfig
278 |
279 | version
280 | 2022.1
281 | webaddress
282 | https://github.com/alfredapp/update-automation-tasks-workflow/
283 |
284 |
285 |
--------------------------------------------------------------------------------