├── .gitignore
├── icon.png
├── screenshots
├── preview.gif
├── oc-empty.png
└── oc-green.png
├── README.md
├── LICENSE
├── info.plist
└── open_color.py
/.gitignore:
--------------------------------------------------------------------------------
1 | *.pyc
2 | icons/
3 |
--------------------------------------------------------------------------------
/icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wookayin/alfred-open-color-workflow/HEAD/icon.png
--------------------------------------------------------------------------------
/screenshots/preview.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wookayin/alfred-open-color-workflow/HEAD/screenshots/preview.gif
--------------------------------------------------------------------------------
/screenshots/oc-empty.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wookayin/alfred-open-color-workflow/HEAD/screenshots/oc-empty.png
--------------------------------------------------------------------------------
/screenshots/oc-green.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wookayin/alfred-open-color-workflow/HEAD/screenshots/oc-green.png
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Alfred Open Color Workflow
2 |
3 | Easily paste [Open Color](https://yeun.github.io/open-color/) codes. Currently uses Open Color version 1.9.1.
4 |
5 | [Get the latest release here.](https://github.com/wookayin/alfred-open-color-workflow/releases)
6 |
7 | 
8 |
9 | ## Usage
10 |
11 | Toggle Alfred and type `oc` and optionally a color to see variations of that color.
12 |
13 | ## Authors
14 |
15 | Jongwook Choi ([@wookayin](https://github.com/wookayin))
16 |
17 | ## LICENSE
18 |
19 | [MIT](https://github.com/wookayin/alfred-open-color-workflow/blob/master/LICENSE)
20 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2016 Jongwook Choi
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | bundleid
6 | kr.wook.alfred-open-color-workflow
7 | category
8 | Productivity
9 | connections
10 |
11 | D1695850-6EFE-4350-955A-48CE7AEDD890
12 |
13 |
14 | destinationuid
15 | 7A90D4BF-75D2-4FAC-A523-5C4CC93B9D78
16 | modifiers
17 | 0
18 | modifiersubtext
19 |
20 | vitoclose
21 |
22 |
23 |
24 |
25 | createdby
26 | Jongwook Choi
27 | description
28 | Insert Open Color Hexcodes
29 | disabled
30 |
31 | name
32 | Open Color
33 | objects
34 |
35 |
36 | config
37 |
38 | alfredfiltersresults
39 |
40 | alfredfiltersresultsmatchmode
41 | 0
42 | argumenttreatemptyqueryasnil
43 |
44 | argumenttrimmode
45 | 0
46 | argumenttype
47 | 1
48 | escaping
49 | 102
50 | keyword
51 | oc
52 | queuedelaycustom
53 | 3
54 | queuedelayimmediatelyinitially
55 |
56 | queuedelaymode
57 | 0
58 | queuemode
59 | 1
60 | runningsubtext
61 |
62 | script
63 | python3 open_color.py "$1"
64 | scriptargtype
65 | 1
66 | scriptfile
67 |
68 | subtext
69 |
70 | title
71 | Open Color
72 | type
73 | 0
74 | withspace
75 |
76 |
77 | type
78 | alfred.workflow.input.scriptfilter
79 | uid
80 | D1695850-6EFE-4350-955A-48CE7AEDD890
81 | version
82 | 3
83 |
84 |
85 | config
86 |
87 | autopaste
88 |
89 | clipboardtext
90 | {query}
91 | ignoredynamicplaceholders
92 |
93 | transient
94 |
95 |
96 | type
97 | alfred.workflow.output.clipboard
98 | uid
99 | 7A90D4BF-75D2-4FAC-A523-5C4CC93B9D78
100 | version
101 | 3
102 |
103 |
104 | readme
105 | Easily paste Open Color codes.
106 |
107 | https://github.com/wookayin/alfred-open-color-workflow
108 | uidata
109 |
110 | 7A90D4BF-75D2-4FAC-A523-5C4CC93B9D78
111 |
112 | xpos
113 | 550
114 | ypos
115 | 70
116 |
117 | D1695850-6EFE-4350-955A-48CE7AEDD890
118 |
119 | xpos
120 | 290
121 | ypos
122 | 70
123 |
124 |
125 | variablesdontexport
126 |
127 | version
128 | 1.3.191
129 | webaddress
130 | https://github.com/wookayin/alfred-open-color-workflow
131 |
132 |
133 |
--------------------------------------------------------------------------------
/open_color.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/python
2 |
3 | '''
4 | open_color.py -- Prints all open color items in Alfred XML format.
5 | written by Jongwook Choi (@wookayin)
6 | '''
7 |
8 | # https://raw.githubusercontent.com/yeun/open-color/v1.4.0/open-color.json
9 | OPEN_COLORS_VERSION = '1.9.1'
10 | OPEN_COLORS = \
11 | {
12 | "white": "#ffffff",
13 | "black": "#000000",
14 | "gray": [
15 | "#f8f9fa",
16 | "#f1f3f5",
17 | "#e9ecef",
18 | "#dee2e6",
19 | "#ced4da",
20 | "#adb5bd",
21 | "#868e96",
22 | "#495057",
23 | "#343a40",
24 | "#212529"
25 | ],
26 | "red": [
27 | "#fff5f5",
28 | "#ffe3e3",
29 | "#ffc9c9",
30 | "#ffa8a8",
31 | "#ff8787",
32 | "#ff6b6b",
33 | "#fa5252",
34 | "#f03e3e",
35 | "#e03131",
36 | "#c92a2a"
37 | ],
38 | "pink": [
39 | "#fff0f6",
40 | "#ffdeeb",
41 | "#fcc2d7",
42 | "#faa2c1",
43 | "#f783ac",
44 | "#f06595",
45 | "#e64980",
46 | "#d6336c",
47 | "#c2255c",
48 | "#a61e4d"
49 | ],
50 | "grape": [
51 | "#f8f0fc",
52 | "#f3d9fa",
53 | "#eebefa",
54 | "#e599f7",
55 | "#da77f2",
56 | "#cc5de8",
57 | "#be4bdb",
58 | "#ae3ec9",
59 | "#9c36b5",
60 | "#862e9c"
61 | ],
62 | "violet": [
63 | "#f3f0ff",
64 | "#e5dbff",
65 | "#d0bfff",
66 | "#b197fc",
67 | "#9775fa",
68 | "#845ef7",
69 | "#7950f2",
70 | "#7048e8",
71 | "#6741d9",
72 | "#5f3dc4"
73 | ],
74 | "indigo": [
75 | "#edf2ff",
76 | "#dbe4ff",
77 | "#bac8ff",
78 | "#91a7ff",
79 | "#748ffc",
80 | "#5c7cfa",
81 | "#4c6ef5",
82 | "#4263eb",
83 | "#3b5bdb",
84 | "#364fc7"
85 | ],
86 | "blue": [
87 | "#e7f5ff",
88 | "#d0ebff",
89 | "#a5d8ff",
90 | "#74c0fc",
91 | "#4dabf7",
92 | "#339af0",
93 | "#228be6",
94 | "#1c7ed6",
95 | "#1971c2",
96 | "#1864ab"
97 | ],
98 | "cyan": [
99 | "#e3fafc",
100 | "#c5f6fa",
101 | "#99e9f2",
102 | "#66d9e8",
103 | "#3bc9db",
104 | "#22b8cf",
105 | "#15aabf",
106 | "#1098ad",
107 | "#0c8599",
108 | "#0b7285"
109 | ],
110 | "teal": [
111 | "#e6fcf5",
112 | "#c3fae8",
113 | "#96f2d7",
114 | "#63e6be",
115 | "#38d9a9",
116 | "#20c997",
117 | "#12b886",
118 | "#0ca678",
119 | "#099268",
120 | "#087f5b"
121 | ],
122 | "green": [
123 | "#ebfbee",
124 | "#d3f9d8",
125 | "#b2f2bb",
126 | "#8ce99a",
127 | "#69db7c",
128 | "#51cf66",
129 | "#40c057",
130 | "#37b24d",
131 | "#2f9e44",
132 | "#2b8a3e"
133 | ],
134 | "lime": [
135 | "#f4fce3",
136 | "#e9fac8",
137 | "#d8f5a2",
138 | "#c0eb75",
139 | "#a9e34b",
140 | "#94d82d",
141 | "#82c91e",
142 | "#74b816",
143 | "#66a80f",
144 | "#5c940d"
145 | ],
146 | "yellow": [
147 | "#fff9db",
148 | "#fff3bf",
149 | "#ffec99",
150 | "#ffe066",
151 | "#ffd43b",
152 | "#fcc419",
153 | "#fab005",
154 | "#f59f00",
155 | "#f08c00",
156 | "#e67700"
157 | ],
158 | "orange": [
159 | "#fff4e6",
160 | "#ffe8cc",
161 | "#ffd8a8",
162 | "#ffc078",
163 | "#ffa94d",
164 | "#ff922b",
165 | "#fd7e14",
166 | "#f76707",
167 | "#e8590c",
168 | "#d9480f"
169 | ]
170 | }
171 | ###############################################################################
172 |
173 | COLOR_CATEGORIES = (
174 | 'gray', 'red', 'pink', 'grape', 'violet', 'indigo',
175 | 'blue', 'cyan', 'teal', 'green', 'lime', 'yellow', 'orange'
176 | )
177 |
178 |
179 | from collections import OrderedDict
180 | items = OrderedDict()
181 |
182 | for color in COLOR_CATEGORIES:
183 | for number, hexcode in enumerate(OPEN_COLORS[color]):
184 | items['%s-%d' % (color, number)] = hexcode
185 |
186 | XML_HEADER = ['', '']
187 | XML_FOOTER = ['']
188 |
189 | def print_category():
190 | lines = []
191 | for i, c in enumerate(COLOR_CATEGORIES):
192 | lines.append(
193 | '''
194 | -
195 | {c}
196 | icons/{c}-6.png
197 |
198 | '''.format(i=i, c=c)
199 | )
200 | print('\n'.join(XML_HEADER + lines + XML_FOOTER))
201 |
202 |
203 | def print_items(query):
204 | lines = []
205 | for key, hexcode in items.items():
206 | if not query in key:
207 | continue
208 | lines.append(
209 | '''
210 | -
211 | {key}
212 | {hexcode}
213 | icons/{key}.png
214 |
215 | '''.format(key=key, hexcode=hexcode)
216 | )
217 |
218 | if not lines:
219 | lines.append(
220 | '''
221 | -
222 | No Results Found
223 |
224 | '''
225 | )
226 |
227 | print('\n'.join(XML_HEADER + lines + XML_FOOTER))
228 |
229 |
230 | def hex2rgb(v):
231 | v = v.lstrip('#')
232 | L = len(v)
233 | return tuple(int(v[i:i+L//3], 16) for i in range(0, L, L//3))
234 |
235 | def generate_icons():
236 | # requires Pillow package to run with '--generate-icons' options
237 | import os, os.path
238 | from PIL import Image
239 | if not os.path.exists('./icons'):
240 | os.mkdir('./icons')
241 |
242 | for key, hexcode in items.items():
243 | print ('Generating %10s : %s ...' % (key, hexcode))
244 | pixel_rgb = hex2rgb(hexcode)
245 | im = Image.new('RGB', (64, 64))
246 | im.putdata([pixel_rgb] * (64*64))
247 | im.save('./icons/%s.png' % key)
248 |
249 | def main():
250 | import sys
251 | arg = sys.argv[1] if len(sys.argv) > 1 else ''
252 |
253 | if arg == '--generate-icons':
254 | generate_icons()
255 | elif arg == '':
256 | print_category()
257 | else:
258 | print_items(arg)
259 |
260 | if __name__ == '__main__':
261 | main()
262 |
--------------------------------------------------------------------------------