]>
Dogcows Code - chaz/openbox/blob - tools/themeupdate/themeupdate.py
14 inp
= sys
.stdin
.readline(1).strip()
15 if inp
== 'y' or inp
== '': return True
16 if inp
== 'n': return False
19 key
= line
[:line
.find(':')].strip()
20 value
= line
[line
.find(':') + 1:].strip()
21 if not (key
and value
):
25 def find_key(data
, keysubstr
, exact
= False):
30 key
, value
= getkeyval(l
)
32 if (exact
and key
== keysubstr
) or \
33 (not exact
and key
.find(keysubstr
) != -1):
38 def simple_replace(data
):
40 pairs
['.picColor'] = '.imageColor'
41 pairs
['menu.frame'] = 'menu.items'
42 pairs
['menu.hilite'] = 'menu.selected'
43 pairs
['borderColor'] = 'border.color'
44 pairs
['imageColor'] = 'image.color'
45 pairs
['textColor'] = 'text.color'
46 pairs
['interlaceColor'] = 'interlace.color'
48 for k
in pairs
.keys():
50 i
, key
, nul
= find_key(data
, k
);
52 newl
= data
[i
].replace(k
, pairs
[k
])
53 out('Updating "' + key
+
54 '" to "' + key
.replace(k
, pairs
[k
]) + '"\n')
60 pairs
['window.focus.font'] = 'window.active.label.text.font'
61 pairs
['window.unfocus.font'] = 'window.inactive.label.text.font'
62 pairs
['window.justify'] = 'window.label.justify'
63 pairs
['menu.frame.disableColor'] = 'menu.disabled.textColor'
64 pairs
['window.label.focus.font'] = 'window.active.label.text.font'
65 pairs
['window.label.unfocus.font'] = 'window.inactive.label.text.font'
66 pairs
['window.label.justify'] = 'window.label.text.justify'
67 pairs
['menu.title.font'] = 'menu.title.text.font'
68 pairs
['menu.title.justify'] = 'menu.title.text.justify'
69 pairs
['menuOverlap'] = 'menu.overlap'
70 pairs
['handleWidth'] = 'window.handle.width'
71 pairs
['borderWidth'] = 'border.width'
72 pairs
['bevelWidth'] = 'padding.width'
73 pairs
['frameWidth'] = 'window.client.padding.width'
74 pairs
['window.frame.focusColor'] = 'window.active.client.color'
75 pairs
['window.frame.unfocusColor'] = 'window.inactive.client.color'
76 pairs
['window.title.focus'] = 'window.active.title.bg'
77 pairs
['window.title.unfocus'] = 'window.inactive.title.bg'
78 pairs
['window.label.focus'] = 'window.active.label.bg'
79 pairs
['window.label.unfocus'] = 'window.inactive.label.bg'
80 pairs
['window.handle.focus'] = 'window.active.handle.bg'
81 pairs
['window.handle.unfocus'] = 'window.inactive.handle.bg'
82 pairs
['window.grip.focus'] = 'window.active.grip.bg'
83 pairs
['window.grip.unfocus'] = 'window.inactive.grip.bg'
84 pairs
['menu.items'] = 'menu.items.bg'
85 pairs
['menu.title'] = 'menu.title.bg'
86 pairs
['menu.selected'] = 'menu.items.active.bg'
87 pairs
['window.title.focus'] = 'window.active.title.bg'
88 pairs
['window.label.focus'] = 'window.active.label.bg'
89 pairs
['window.title.unfocus'] = 'window.inactive.title.bg'
90 pairs
['window.label.unfocus'] = 'window.inactive.label.bg'
91 pairs
['window.button.disabled.focus'] = 'window.active.button.disabled.bg'
92 pairs
['window.button.disabled.unfocus'] = \
93 'window.inactive.button.disabled.bg'
94 pairs
['window.button.pressed.focus'] = 'window.active.button.pressed.bg'
95 pairs
['window.button.pressed.unfocus'] = \
96 'window.inactive.button.pressed.bg'
97 pairs
['window.button.toggled.focus'] = 'window.active.button.toggled.bg'
98 pairs
['window.button.toggled.unfocus'] = \
99 'window.inactive.button.toggled.bg'
100 pairs
['window.button.focus'] = 'window.active.button.unpressed.bg'
101 pairs
['window.button.unfocus'] = 'window.inactive.button.unpressed.bg'
102 pairs
['window.button.hover.focus'] = 'window.active.button.hover.bg'
103 pairs
['window.button.hover.unfocus'] = 'window.inactive.button.hover.bg'
105 for k
in pairs
.keys():
107 i
, key
, nul
= find_key(data
, k
, True);
109 newl
= data
[i
].replace(k
, pairs
[k
])
110 out('Updating "' + key
+
111 '" to "' + key
.replace(k
, pairs
[k
]) + '"\n')
117 pairs
['window.title.focus'] = 'window.active.title'
118 pairs
['window.title.unfocus'] = 'window.inactive.title'
119 pairs
['window.label.focus'] = 'window.active.label'
120 pairs
['window.label.unfocus'] = 'window.inactive.label'
121 pairs
['window.handle.focus'] = 'window.active.handle'
122 pairs
['window.handle.unfocus'] = 'window.inactive.handle'
123 pairs
['window.grip.focus'] = 'window.active.grip'
124 pairs
['window.grip.unfocus'] = 'window.inactive.grip'
125 pairs
['menu.selected'] = 'menu.items.active'
126 pairs
['window.title.focus'] = 'window.active.title'
127 pairs
['window.label.focus'] = 'window.active.label'
128 pairs
['window.title.unfocus'] = 'window.inactive.title'
129 pairs
['window.label.unfocus'] = 'window.inactive.label'
130 pairs
['window.button.disabled.focus'] = 'window.active.button.disabled'
131 pairs
['window.button.disabled.unfocus'] = \
132 'window.inactive.button.disabled'
133 pairs
['window.button.pressed.focus'] = 'window.active.button.pressed'
134 pairs
['window.button.pressed.unfocus'] = \
135 'window.inactive.button.pressed'
136 pairs
['window.button.toggled.focus'] = 'window.active.button.toggled'
137 pairs
['window.button.toggled.unfocus'] = \
138 'window.inactive.button.toggled'
139 pairs
['window.button.focus'] = 'window.active.button'
140 pairs
['window.button.unfocus'] = 'window.inactive.button'
141 pairs
['window.button.hover.focus'] = 'window.active.button.hover'
142 pairs
['window.button.hover.unfocus'] = 'window.inactive.button.hover'
143 pairs
['window.label.unfocus'] = 'window.inactive.label'
144 pairs
['window.label.focus'] = 'window.active.label'
145 pairs
['window.button.focus'] = 'window.active.button.unpressed'
146 pairs
['menu.disabled'] = 'menu.items.disabled'
147 pairs
['menu.selected'] = 'menu.items.active'
148 pairs
['window.button.unfocus'] = 'window.inactive.button.unpressed'
149 pairs
['window.button.pressed.focus'] = 'window.active.button.pressed'
150 pairs
['window.button.pressed.unfocus'] = 'window.inactive.button.pressed'
151 pairs
['window.button.disabled.focus'] = 'window.active.button.disabled'
152 pairs
['window.button.disabled.unfocus'] = 'window.inactive.button.disabled'
153 pairs
['window.button.hover.focus'] = 'window.active.button.hover'
154 pairs
['window.button.hover.unfocus'] = 'window.inactive.button.hover'
155 pairs
['window.button.toggled.focus'] = 'window.active.button.toggled'
156 pairs
['window.button.toggled.unfocus'] = 'window.inactive.button.toggled'
158 for k
in pairs
.keys():
160 i
, key
, nul
= find_key(data
, k
);
162 newl
= data
[i
].replace(k
, pairs
[k
])
163 out('Updating "' + key
+
164 '" to "' + key
.replace(k
, pairs
[k
]) + '"\n')
169 def replace_colors(data
):
174 key
, value
= getkeyval(l
)
176 if key
.find('.color') != -1:
177 if key
.find('client.color') == -1 \
178 and key
.find('image.color') == -1 \
179 and key
.find('bg.color') == -1 \
180 and key
.find('border.color') == -1 \
181 and key
.find('interlace.color') == -1 \
182 and key
.find('text.color') == -1:
183 newl
= data
[i
].replace('.color', '.bg.color')
184 out('Updating "' + key
+
185 '" to "' + key
.replace('.color', '.bg.color') + '"\n')
187 if key
.find('.border.color') != -1 \
188 and key
.find('bg.border.color') == -1:
189 newl
= data
[i
].replace('.border.color', '.bg.border.color')
190 out('Updating "' + key
+
191 '" to "' + key
.replace('.border.color',
192 '.bg.border.color') + '"\n')
194 if key
.find('.interlace.color') != -1 \
195 and key
.find('bg.interlace.color') == -1:
196 newl
= data
[i
].replace('.interlace.color',
197 '.bg.interlace.color')
198 out('Updating "' + key
+
199 '" to "' + key
.replace('.interlace.color',
200 '.bg.interlace.color') + '"\n')
206 invalid
.append('toolbar')
209 i
, key
, nul
= find_key(data
, inv
)
211 out(key
+ ' is no longer supported.\nRemove (Y/n)? ')
213 out('Removing "' + key
+ '"\n')
217 invalid
.append('rootCommand')
218 invalid
.append('menu.bullet')
219 invalid
.append('menu.bullet.image.color')
220 invalid
.append('menu.bullet.selected.image.color')
221 invalid
.append('menu.frame.justify')
224 i
, key
, nul
= find_key(data
, inv
, True)
226 out(key
+ ' is no longer supported.\nRemove (Y/n)? ')
228 out('Removing "' + key
+ '"\n')
234 i
, nul
, nul
= find_key(data
, 'window.button.pressed', True)
236 out('The window.button.pressed option has been replaced by ' +
237 'window.button.pressed.focus and ' +
238 'window.button.pressed.unfocus.\nUpdate (Y/n)? ')
241 out('Removing "window.button.pressed"\n')
243 out('Adding "window.button.pressed.unfocus"\n')
244 data
.insert(i
, l
.replace('window.button.pressed',
245 'window.button.pressed.unfocus'))
246 out('Adding "window.button.pressed.focus"\n')
247 data
.insert(i
, l
.replace('window.button.pressed',
248 'window.button.pressed.focus'))
251 i
, nul
, nul
= find_key(data
, 'window.font')
253 out('You appear to specify fonts using the old X fonts ' +
254 'syntax.\nShall I remove all fonts from the theme (Y/n)? ')
259 i
, key
= key_find(data
, '.font')
262 out('Removing "' + key
+ '"\n')
266 i
, nul
, nul
= find_key(data
, '.xft.')
268 out('You appear to specify fonts using the old Xft fonts ' +
269 'syntax.\nShall I update these to the new syntax (Y/n)? ')
274 fonts
['window'] = 'window.label.focus.font'
275 fonts
['menu.items'] = 'menu.items.font'
276 fonts
['menu.title'] = 'menu.title.font'
277 for f
in fonts
.keys():
278 li
, nul
, flags
= find_key(data
, f
+ '.xft.flags')
280 li
, nul
, flags
= find_key(data
, '*.xft.flags')
282 out('Removing ' + f
+ '.xft.flags\n')
284 oi
, nul
, offset
= find_key(data
, f
+ '.xft.shadow.offset')
286 oi
, nul
, offset
= find_key(data
, '*.xft.shadow.offset')
288 out('Removing ' + f
+ '.xft.shadow.offset\n')
290 ti
, nul
, tint
= find_key(data
, f
+ '.xft.shadow.tint')
292 ti
, nul
, tint
= find_key(data
, '*.xft.shadow.tint')
294 out('Removing ' + f
+ '.xft.shadow.tint\n')
296 fi
, nul
, face
= find_key(data
, f
+ '.xft.font')
298 fi
, nul
, face
= find_key(data
, '*.xft.font')
299 if fi
>= 0: fi
= len(data
) - 1
301 out('Removing ' + f
+ '.xft.font\n')
307 if flags
.find('bold'):
309 if flags
.find('shadow'):
312 s
= s
+ ':shadowoffset=' + offset
314 s
= s
+ ':shadowtint=' + tint
315 out('Adding ' + fonts
[f
] + '\n')
316 data
.insert(fi
, fonts
[f
] + ': ' + s
)
318 for stars
in ('*.xft.flags', '*.xft.shadow.offset' ,
319 '*.xft.shadow.tint', '*.xft.font'):
320 i
, key
, nul
= find_key(data
, stars
)
322 out('Removing ' + key
+ '\n')
326 fonts
= ('window.label.focus.font',
330 i
, key
, value
= find_key(data
, f
, True)
332 if value
.find('pixelsize') == -1:
333 out('*** ERROR *** The ' + key
+ ' font size is not being '
334 'specified by pixelsize. It is recommended that you use '
335 'pixelsize instead of pointsize for specifying theme '
336 'fonts. e.g. "sans:pixelsize=12"\n')
340 def warn_missing(data
):
341 need
= ('window.active.button.hover', 'window.inactive.button.hover',
344 i
, nul
, nul
= find_key(data
, n
)
346 out('The ' + n
+ ' value was not found in the theme, but it '
347 'can optionally be set.\n')
349 def err_missing(data
):
350 need
= ('window.active.button.disabled',
351 'window.inactive.button.disabled',
352 'window.active.client.color',
353 'window.inactive.client.color')
355 i
, nul
, nul
= find_key(data
, n
)
357 out('*** ERROR *** The ' + n
+ ' value was not found in the '
358 'theme, but it is required to be set.\n')
364 out('Usage: themupdate.py /path/to/themerc > newthemerc\n\n')
368 file = open(sys
.argv
[1])
372 out('Unable to open file "' + sys
.argv
[1] + '"\n\n')
375 data
= file.readlines()
376 for i
in range(len(data
)):
377 data
[i
] = data
[i
].strip()
This page took 0.051088 seconds and 4 git commands to generate.