-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathinfo.plist
327 lines (306 loc) · 9.97 KB
/
info.plist
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>bundleid</key>
<string>com.darsh12.firefoxswitcher</string>
<key>category</key>
<string>Internet</string>
<key>connections</key>
<dict>
<key>35EA4ECC-C7A8-4D58-AF6F-CB1AB3A2D72C</key>
<array/>
<key>54EAE446-DC21-4B16-A958-DC2E88F231EB</key>
<array/>
<key>81D9623A-1FBD-4B0E-9079-FB2052073F98</key>
<array>
<dict>
<key>destinationuid</key>
<string>54EAE446-DC21-4B16-A958-DC2E88F231EB</string>
<key>modifiers</key>
<integer>0</integer>
<key>modifiersubtext</key>
<string></string>
<key>vitoclose</key>
<false/>
</dict>
<dict>
<key>destinationuid</key>
<string>069646A0-5A8C-4995-AE96-615511398549</string>
<key>modifiers</key>
<integer>0</integer>
<key>modifiersubtext</key>
<string></string>
<key>vitoclose</key>
<false/>
</dict>
<dict>
<key>destinationuid</key>
<string>35EA4ECC-C7A8-4D58-AF6F-CB1AB3A2D72C</string>
<key>modifiers</key>
<integer>524288</integer>
<key>modifiersubtext</key>
<string>Launching Firefox Developer Edition</string>
<key>vitoclose</key>
<false/>
</dict>
</array>
</dict>
<key>createdby</key>
<string>darsh12</string>
<key>description</key>
<string>Switch firefox profiles</string>
<key>disabled</key>
<false/>
<key>name</key>
<string>Firefox Switcher</string>
<key>objects</key>
<array>
<dict>
<key>config</key>
<dict>
<key>alfredfiltersresults</key>
<true/>
<key>alfredfiltersresultsmatchmode</key>
<integer>0</integer>
<key>argumenttreatemptyqueryasnil</key>
<true/>
<key>argumenttrimmode</key>
<integer>0</integer>
<key>argumenttype</key>
<integer>1</integer>
<key>escaping</key>
<integer>102</integer>
<key>keyword</key>
<string>foxy</string>
<key>queuedelaycustom</key>
<integer>3</integer>
<key>queuedelayimmediatelyinitially</key>
<true/>
<key>queuedelaymode</key>
<integer>0</integer>
<key>queuemode</key>
<integer>1</integer>
<key>runningsubtext</key>
<string></string>
<key>script</key>
<string>import os, ConfigParser
import json
config = ConfigParser.ConfigParser()
config.read(os.path.expanduser('~/Library/Application Support/Firefox/profiles.ini'))
profiles = []
# Loop over all the sections in the config file
for name in config.sections():
try:
# Get the Name from each firefox profile
profile_names = config.get(name, "Name")
# Append the profile name to the appropriate json keys
config_dict = {"uid": profile_names, "type": "default", "title": profile_names,
"subtitle": name + " : " + profile_names,
"autocomplete": profile_names, "arg": profile_names}
# Append each config_dict the the profiles list
profiles.append(config_dict)
# In the event there is a profile with no Name, skip over it
except ConfigParser.NoOptionError:
continue
# Convert the profiles list to a json object
json_convert = json.dumps(profiles, sort_keys=True, indent=2)
# Append the items to the json object then print it
print "{\"items\": %s }" % json_convert
</string>
<key>scriptargtype</key>
<integer>1</integer>
<key>scriptfile</key>
<string>source/script.py</string>
<key>subtext</key>
<string>Choose profile...</string>
<key>title</key>
<string>Firefox profile changer</string>
<key>type</key>
<integer>8</integer>
<key>withspace</key>
<true/>
</dict>
<key>type</key>
<string>alfred.workflow.input.scriptfilter</string>
<key>uid</key>
<string>81D9623A-1FBD-4B0E-9079-FB2052073F98</string>
<key>version</key>
<integer>3</integer>
</dict>
<dict>
<key>config</key>
<dict>
<key>concurrently</key>
<true/>
<key>escaping</key>
<integer>102</integer>
<key>script</key>
<string>query=$1 # This is the the arg variable from the script filter
# Launch the firefox
/Applications/Firefox.app/Contents/MacOS/firefox -P --no-remote $query &</string>
<key>scriptargtype</key>
<integer>1</integer>
<key>scriptfile</key>
<string></string>
<key>type</key>
<integer>0</integer>
</dict>
<key>type</key>
<string>alfred.workflow.action.script</string>
<key>uid</key>
<string>54EAE446-DC21-4B16-A958-DC2E88F231EB</string>
<key>version</key>
<integer>2</integer>
</dict>
<dict>
<key>config</key>
<dict>
<key>concurrently</key>
<false/>
<key>escaping</key>
<integer>0</integer>
<key>script</key>
<string># THESE VARIABLES MUST BE SET. SEE THE ONEUPDATER README FOR AN EXPLANATION OF EACH.
readonly remote_info_plist='https://raw.githubusercontent.com/darsh12/alfred-firefox-switcher/master/info.plist'
readonly workflow_url='darsh12/alfred-firefox-switcher'
readonly download_type='github_release'
readonly frequency_check='0'
# FROM HERE ON, CODE SHOULD BE LEFT UNTOUCHED!
function abort {
echo "${1}" >&2
exit 1
}
function url_exists {
curl --silent --location --output /dev/null --fail --range 0-0 "${1}"
}
function notification {
readonly local notificator="$(find . -type d -name 'Notificator.app')"
if [[ -n "${notificator}" ]]; then
"${notificator}/Contents/Resources/Scripts/notificator" --message "${1}" --title "${alfred_workflow_name}" --subtitle 'A new version is available'
return
fi
readonly local terminal_notifier="$(find . -type f -name 'terminal-notifier')"
if [[ -n "${terminal_notifier}" ]]; then
"${terminal_notifier}" -title "${alfred_workflow_name}" -subtitle 'A new version is available' -message "${1}"
return
fi
osascript -e "display notification \"${1}\" with title \"${alfred_workflow_name}\" subtitle \"A new version is available\""
}
# Local sanity checks
readonly local_info_plist='info.plist'
readonly local_version="$(/usr/libexec/PlistBuddy -c 'print version' "${local_info_plist}")"
[[ -n "${local_version}" ]] || abort 'You need to set a workflow version in the configuration sheet.'
[[ "${download_type}" =~ ^(direct|page|github_release)$ ]] || abort "'download_type' (${download_type}) needs to be one of 'direct', 'page', or 'github_release'."
[[ "${frequency_check}" =~ ^[0-9]+$ ]] || abort "'frequency_check' (${frequency_check}) needs to be a number."
# Check for updates
if [[ $(find "${local_info_plist}" -mtime +"${frequency_check}"d) ]]; then
if ! url_exists "${remote_info_plist}"; then abort "'remote_info_plist' (${remote_info_plist}) appears to not be reachable."; fi # Remote sanity check
readonly tmp_file="$(mktemp)"
curl --silent --location --output "${tmp_file}" "${remote_info_plist}"
readonly remote_version="$(/usr/libexec/PlistBuddy -c 'print version' "${tmp_file}")"
if [[ "${local_version}" == "${remote_version}" ]]; then
touch "${local_info_plist}" # Reset timer by touching local file
exit 0
fi
if [[ "${download_type}" == 'page' ]]; then
notification 'Opening download page…'
open "${workflow_url}"
exit 0
fi
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}")"
if url_exists "${download_url}"; then
notification 'Downloading and installing…'
curl --silent --location --output "${HOME}/Downloads/${alfred_workflow_name}.alfredworkflow" "${download_url}"
open "${HOME}/Downloads/${alfred_workflow_name}.alfredworkflow"
else
abort "'workflow_url' (${download_url}) appears to not be reachable."
fi
fi</string>
<key>scriptargtype</key>
<integer>1</integer>
<key>scriptfile</key>
<string></string>
<key>type</key>
<integer>0</integer>
</dict>
<key>type</key>
<string>alfred.workflow.action.script</string>
<key>uid</key>
<string>069646A0-5A8C-4995-AE96-615511398549</string>
<key>version</key>
<integer>2</integer>
</dict>
<dict>
<key>config</key>
<dict>
<key>concurrently</key>
<true/>
<key>escaping</key>
<integer>102</integer>
<key>script</key>
<string>query=$1 # This is the the arg variable from the script filter
# Launch the firefox
/Applications/FirefoxDeveloperEdition.app/Contents/MacOS/firefox -P --no-remote $query &</string>
<key>scriptargtype</key>
<integer>1</integer>
<key>scriptfile</key>
<string></string>
<key>type</key>
<integer>0</integer>
</dict>
<key>type</key>
<string>alfred.workflow.action.script</string>
<key>uid</key>
<string>35EA4ECC-C7A8-4D58-AF6F-CB1AB3A2D72C</string>
<key>version</key>
<integer>2</integer>
</dict>
</array>
<key>readme</key>
<string>Inspired by: https://github.com/m4dz/alfred-firefox-profile-launcher
This workflow uses python in order to launch different firefox profiles. This workflow can also launch Firefox Developer Edition while pressing the alt key.
Self-updating feature to grab the latest release</string>
<key>uidata</key>
<dict>
<key>069646A0-5A8C-4995-AE96-615511398549</key>
<dict>
<key>colorindex</key>
<integer>12</integer>
<key>note</key>
<string>OneUpdater</string>
<key>xpos</key>
<integer>580</integer>
<key>ypos</key>
<integer>290</integer>
</dict>
<key>35EA4ECC-C7A8-4D58-AF6F-CB1AB3A2D72C</key>
<dict>
<key>xpos</key>
<integer>315</integer>
<key>ypos</key>
<integer>360</integer>
</dict>
<key>54EAE446-DC21-4B16-A958-DC2E88F231EB</key>
<dict>
<key>xpos</key>
<integer>160</integer>
<key>ypos</key>
<integer>140</integer>
</dict>
<key>81D9623A-1FBD-4B0E-9079-FB2052073F98</key>
<dict>
<key>xpos</key>
<integer>395</integer>
<key>ypos</key>
<integer>10</integer>
</dict>
</dict>
<key>variablesdontexport</key>
<array/>
<key>version</key>
<string>1.2.2</string>
<key>webaddress</key>
<string>https://github.com/darsh12/alfred-firefox-switcher</string>
</dict>
</plist>