-
Notifications
You must be signed in to change notification settings - Fork 1
/
walbert.py
executable file
·44 lines (32 loc) · 1.57 KB
/
walbert.py
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
#!/usr/bin/env python
# Uses PyWal colors and adds them to a predefined Albert launcher theme
__author__ = "ErkHal"
import os
import json
import cssutils
#Edit these to change the color variables assigned to the QSS rules
SELECTION_COLOR = 'color6'
pywalFilepath = os.path.join(os.environ['HOME'], '.cache/wal/colors.json')
styleSheet = cssutils.parseFile('/usr/share/albert/org.albert.frontend.widgetboxmodel/themes/Walbert.qss')
#Load pywal JSON properties
with open(pywalFilepath) as f:
colorArray = json.load(f)
for rule in styleSheet.cssRules:
try:
if rule.selectorText == '*':
rule.style.color = colorArray['special']['foreground']
rule.style.backgroundColor = colorArray['special']['background']
if rule.selectorText == '#settingsButton':
rule.style.color = colorArray['colors'][SELECTION_COLOR]
if rule.selectorText == '#frame' or rule.selectorText == '#inputLine':
rule.style.backgroundColor = colorArray['special']['background']
if rule.selectorText == 'QListView':
rule.style['selection-color'] = colorArray['colors'][SELECTION_COLOR]
except AttributeError as e:
pass #Ignore error if attribute doesn't exist
# Overwrite the stylesheet file with the new rules
with open('/usr/share/albert/org.albert.frontend.widgetboxmodel/themes/Walbert.qss', 'wb') as f:
f.write(styleSheet.cssText)
f.close()
print('-----------------------------------------')
print('Stylesheet changed, restart Albert or change themes in Albert\'s settings to apply changes')