Commit f2c62482 authored by phob1an's avatar phob1an 🎧
Browse files

sync

parent c2a3b7ce
......@@ -221,7 +221,7 @@
id="layer1"
transform="translate(-11.42856,-859.091)">
<rect
style="opacity:1;fill:#f1f4f7;fill-opacity:1;stroke:none;stroke-width:8.00000095;stroke-linecap:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
style="opacity:1;fill:#f7f1f2;fill-opacity:1;stroke:none;stroke-width:8.00000095;stroke-linecap:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
id="decoration-center"
width="128"
height="128"
......@@ -236,7 +236,7 @@
height="128"
width="5"
id="b03"
style="opacity:1;fill:#f1f4f7;fill-opacity:1;stroke:none;stroke-width:8.00000095;stroke-linecap:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" />
style="opacity:1;fill:#f7f1f2;fill-opacity:1;stroke:none;stroke-width:8.00000095;stroke-linecap:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" />
<rect
style="opacity:1;fill:url(#linearGradient927);fill-opacity:1;stroke:none;stroke-width:8.00000095;stroke-linecap:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
id="rect925"
......@@ -245,7 +245,7 @@
x="194.42854"
y="943.9483" />
<rect
style="opacity:0.8;fill:#429aef;fill-opacity:1;stroke:none;stroke-width:3.5777092;stroke-linecap:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
style="opacity:0.8;fill:#d1606a;fill-opacity:1;stroke:none;stroke-width:3.5777092;stroke-linecap:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
id="XX3"
width="1"
height="128"
......@@ -253,7 +253,7 @@
y="943.9483" />
</g>
<rect
style="opacity:1;fill-opacity:1;stroke:none;stroke-width:8.00000095;stroke-linecap:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1;fill:#429aef"
style="opacity:1;fill-opacity:1;stroke:none;stroke-width:8.00000095;stroke-linecap:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1;fill:#d1606a"
id="decoration-maximized-center"
width="127.99999"
height="31.999998"
......@@ -265,12 +265,12 @@
height="31.999998"
width="127.99999"
id="decoration-maximized-inactive-center"
style="opacity:1;fill-opacity:1;stroke:none;stroke-width:8.00000095;stroke-linecap:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1;fill:#f1f4f7" />
style="opacity:1;fill-opacity:1;stroke:none;stroke-width:8.00000095;stroke-linecap:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1;fill:#f7f1f2" />
<g
id="decoration-top"
transform="translate(-5.7142928,63.928709)">
<rect
style="opacity:1;fill-opacity:1;stroke:none;stroke-width:8.00000095;stroke-linecap:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1;fill:#429aef"
style="opacity:1;fill-opacity:1;stroke:none;stroke-width:8.00000095;stroke-linecap:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1;fill:#d1606a"
id="b01"
width="127.99999"
height="31.999998"
......@@ -295,7 +295,7 @@
id="rect921"
style="opacity:1;fill:url(#radialGradient995);fill-opacity:1.0;stroke:none;stroke-width:8.00000095;stroke-linecap:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" />
<rect
style="opacity:1;fill-opacity:1;stroke:none;stroke-width:6.40003729;stroke-linecap:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1;fill:#f1f4f7"
style="opacity:1;fill-opacity:1;stroke:none;stroke-width:6.40003729;stroke-linecap:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1;fill:#f7f1f2"
id="rect923"
width="4.0000119"
height="4.0000334"
......@@ -305,10 +305,10 @@
inkscape:connector-curvature="0"
id="path925"
d="m 198.35307,1069.2681 v 4 h -4 v 1 h 5 v -5 z"
style="opacity:0.1;fill-opacity:1;stroke:none;stroke-width:8.00000095;stroke-linecap:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1;fill:#429aef" />
style="opacity:0.1;fill-opacity:1;stroke:none;stroke-width:8.00000095;stroke-linecap:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1;fill:#d1606a" />
</g>
<rect
style="opacity:1;fill:#f1f4f7;fill-opacity:1;stroke:none;stroke-width:8.00000095;stroke-linecap:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
style="opacity:1;fill:#f7f1f2;fill-opacity:1;stroke:none;stroke-width:8.00000095;stroke-linecap:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
id="decoration-inactive-center"
width="128"
height="128"
......@@ -323,9 +323,9 @@
height="128"
width="4"
id="rect931"
style="opacity:1;fill:#f1f4f7;fill-opacity:1;stroke:none;stroke-width:7.1554184;stroke-linecap:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" />
style="opacity:1;fill:#f7f1f2;fill-opacity:1;stroke:none;stroke-width:7.1554184;stroke-linecap:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" />
<rect
style="opacity:0.1;fill-opacity:1;stroke:none;stroke-width:8.00000095;stroke-linecap:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1;fill:#429aef"
style="opacity:0.1;fill-opacity:1;stroke:none;stroke-width:8.00000095;stroke-linecap:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1;fill:#d1606a"
id="rect933"
width="1"
height="128"
......@@ -351,7 +351,7 @@
x="201.92856"
y="-827.80542" />
<rect
style="opacity:1;fill-opacity:1;stroke:none;stroke-width:7.04273081;stroke-linecap:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1;fill:#f1f4f7"
style="opacity:1;fill-opacity:1;stroke:none;stroke-width:7.04273081;stroke-linecap:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1;fill:#f7f1f2"
id="rect949"
width="4.0000014"
height="31"
......@@ -363,7 +363,7 @@
height="31.999985"
width="1"
id="rect951"
style="opacity:0.1;fill-opacity:1;stroke:none;stroke-width:8.00000095;stroke-linecap:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1;fill:#429aef" />
style="opacity:0.1;fill-opacity:1;stroke:none;stroke-width:8.00000095;stroke-linecap:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1;fill:#d1606a" />
<rect
y="827.80542"
x="206.92856"
......@@ -377,20 +377,20 @@
height="0.99999982"
width="4"
id="rect955"
style="opacity:0.1;fill-opacity:1;stroke:none;stroke-width:8;stroke-linecap:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1;fill:#429aef" />
style="opacity:0.1;fill-opacity:1;stroke:none;stroke-width:8;stroke-linecap:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1;fill:#d1606a" />
</g>
<g
id="decoration-inactive-top"
transform="translate(238.28571,63.928709)">
<rect
style="opacity:1;fill-opacity:1;stroke:none;stroke-width:7.87400913;stroke-linecap:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1;fill:#f1f4f7"
style="opacity:1;fill-opacity:1;stroke:none;stroke-width:7.87400913;stroke-linecap:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1;fill:#f7f1f2"
id="rect987"
width="128"
height="31"
x="67.142853"
y="849.01959" />
<rect
style="opacity:0.1;fill-opacity:1;stroke:none;stroke-width:8.00000095;stroke-linecap:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1;fill:#429aef"
style="opacity:0.1;fill-opacity:1;stroke:none;stroke-width:8.00000095;stroke-linecap:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1;fill:#d1606a"
id="rect989"
width="127.99999"
height="0.99999994"
......@@ -490,7 +490,7 @@
x="201.42856"
y="-909.94836" />
<rect
style="opacity:1;fill:#429aef;fill-opacity:1;stroke:none;stroke-width:8.00000095;stroke-linecap:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
style="opacity:1;fill:#d1606a;fill-opacity:1;stroke:none;stroke-width:8.00000095;stroke-linecap:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
id="b02"
width="5"
height="31.999985"
......@@ -523,7 +523,7 @@
id="rect2306"
style="opacity:1;fill:url(#radialGradient2314);fill-opacity:1;stroke:none;stroke-width:8.00000095;stroke-linecap:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" />
<rect
style="opacity:1;fill:#f1f4f7;fill-opacity:1;stroke:none;stroke-width:8.00004864;stroke-linecap:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
style="opacity:1;fill:#f7f1f2;fill-opacity:1;stroke:none;stroke-width:8.00004864;stroke-linecap:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
id="XX5"
width="5.0000014"
height="5.0000577"
......@@ -534,7 +534,7 @@
id="XX6"
transform="translate(11.42856,859.091)"
d="m 187,218.85742 v 4 h -4 v 1 h 5 v -5 z"
style="opacity:0.9;fill:#429aef;fill-opacity:1;stroke:none;stroke-width:8.00000095;stroke-linecap:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" />
style="opacity:0.9;fill:#d1606a;fill-opacity:1;stroke:none;stroke-width:8.00000095;stroke-linecap:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" />
</g>
<use
x="0"
......
#!/usr/bin/python3
"""Tincture generates a desktop theme based on the current wallpaper"""
import sys
import os
import subprocess
import time
import colorsys
from PIL import Image
import fast_colorthief
NUM_COLORS = 10
# Template for colorscheme
plasma_colors = """[Colors:Window]
ForegroundNormal=#cc
BackgroundNormal=#aa
ForegroundNegative=255,40,40
ForegroundInactive=#ee
[Colors:Selection]
BackgroundNormal=#ee
ForegroundNormal=255,255,255
[Colors:Complementary]
BackgroundNormal=#kk
ForegroundNormal=#ll
DecorationFocus=255,255,0
ForegroundLink=255,0,255
ForegroundVisited=255,255,0
[Colors:Button]
ForegroundNormal=#cc
BackgroundNormal=#aa
DecorationFocus=#jj
DecorationHover=#ii
ForegroundNegative=0,255,255
[Colors:View]
ForegroundNormal=#dd
BackgroundNormal=#bb
DecorationHover=#gg
DecorationFocus=#ff
[Colors:Tooltip]
BackgroundNormal=#bb
ForegroundNormal=#dd
[Colors:Header]
ForegroundNormal=#cc
BackgroundNormal=#hh
DecorationHover=#ee
[Colors:Header][Inactive]
ForegroundNormal=#cc
BackgroundNormal=#hh
ForegroundActive=0,255,0
[ColorEffects:Inactive]
ChangeSelectionColor=false
Color=#ee
ColorAmount=0
ColorEffect=0
ContrastAmount=0.25
ContrastEffect=1
Enable=true
IntensityAmount=0
IntensityEffect=0
[General]
Name=Tincture
shadeSortColumn=true"""
# Template for window decoration config
auroraerc = """[General]
ActiveTextColor=#aa,255
InactiveTextColor=#bb,19
TitleAlignment=Left
TitleVerticalAlignment=Center
Animation=0
Shadow=false
[Layout]
TitleHeight=32
TitleEdgeBottom=0
TitleEdgeTop=0
TitleEdgeLeft=5
TitleEdgeRight=5
TitleBorderLeft=7
ButtonMarginTop=4
BorderRight=5
PaddingRight=15
BorderLeft=5
PaddingLeft=15
BorderBottom=5
PaddingBottom=15
PaddingTop=15
ButtonHeight=24
ButtonWidth=34
ButtonSpacing=0
TitleEdgeBottomMaximized=2
TitleEdgeRightMaximized=8
TitleEdgeLeftMaximized=8
ButtonWidthMenu=24
"""
def rgb_to_hex(rgb):
return '%02x%02x%02x' % rgb
def notify_user(message):
""" Simple notification to show something's happening """
icon_path = os.path.expanduser('~/.local/share/icons/hicolor/scalable/apps/tincture.svg')
icon = '--icon={}'.format(icon_path)
try:
subprocess.run(['notify-send',
icon,
'--expire-time=3500',
message])
except:
pass
def color_triplet(h, l, s):
"""Return color triplet to use in colorschemes"""
r, g, b = colorsys.hls_to_rgb(h, l, s)
if r > 1.0:
r = 1.0
r = int(r * 255)
if g > 1.0:
g = 1.0
g = int(g * 255)
if b > 1.0:
r = 1.0
b = int(b * 255)
return ','.join([str(r), str(g), str(b)])
def aurorae(rgb256, rgb256_hi):
"""Open decoration template, substitue our colour
then write decoration.svg"""
try:
with open(os.path.expanduser \
('~/.local/share/aurorae/themes/Tincture/decoration-template.svg')) \
as f:
auroraetemplate = f.read()
except IOError:
sys.exit("Unable to find Aurorae template.")
r = rgb256[0]
g = rgb256[1]
b = rgb256[2]
hex_colour = f'{int(r):02x}{int(g):02x}{int(b):02x}'
r = rgb256_hi[0]
g = rgb256_hi[1]
b = rgb256_hi[2]
hex_colour_hi = f'{int(r):02x}{int(g):02x}{int(b):02x}'
#r = rgb256_inact[0]
#g = rgb256_inact[1]
#b = rgb256_inact[2]
#hex_colour_inact = f'{int(r):02x}{int(g):02x}{int(b):02x}'
#r = border[0]
#g = border[1]
#b = border[2]
#hex_border = f'{int(r):02x}{int(g):02x}{int(b):02x}'
auroraetemplate = auroraetemplate.replace('TEMPLAT', hex_colour)
auroraetemplate = auroraetemplate.replace('HIPLAT', hex_colour_hi)
#auroraetemplate = auroraetemplate.replace('INPLAT', hex_colour_inact)
#auroraetemplate = auroraetemplate.replace('BORD', hex_border)
try:
with open(os.path.expanduser \
('~/.local/share/aurorae/themes/Tincture/Tincturerc'), 'w') as f:
f.write(auroraerc)
except IOError:
sys.exit("Fatal. Unable to write aurorae decoration.")
try:
with open(os.path.expanduser \
('~/.local/share/aurorae/themes/Tincture/decoration.svg'), 'w') as f:
f.write(auroraetemplate)
except IOError:
sys.exit("Fatal. Unable to write aurorae decoration.")
def get_average(fd):
""" Get average hue of image"""
with Image.open(fd) as img:
pil_image = img.resize((1,1))
q = pil_image.getpixel((0,0))
#print("Average single pixel: ", q)
hls = colorsys.rgb_to_hls(q[0]/255, q[1]/255, q[2]/255)
return(hls)
# ---- Tincture starts here -------------------------------------------------
# Try sending a notification to show we're working
# notify_user("Generating Desktop Theme")
# Raise flag when finding correct session in plasmarc
flag = False
# Holder for current activity ID
activity = ""
try:
with open(os.path.expanduser(
'~/.config/plasma-org.kde.plasma.desktop-appletsrc')) as f:
plasmaconfig = f.readlines()
except:
sys.exit('Unable to find plasma config.')
try:
with open(os.path.expanduser('~/.config/kactivitymanagerdrc')) as f:
activityrc = f.readlines()
except:
print('Unable to find kactivity manager rc. Presuming only default activity.')
activityrc = None
flag = True # There is only default activity
# Retrieve current activity
if activityrc is not None:
a = [a for a in activityrc if 'current' in a]
a = a[0].split('=')
activity = a[1].rstrip()
# Flag if wallpaper is found
found = False
# Find current activity then grab next Image= key
for line in plasmaconfig:
if activity in line:
flag = True
if 'Image=' in line and flag:
found = True
break
if not found:
notify_user("""You need to set your own wallpaper\n\
before I can work.""" )
sys.exit("I didn't find your wallpaper. Have you set one yet?")
line = line[6:]
if line[0] == 'f':
line = line[7:]
wallpaper = line.strip()
if not os.path.exists(wallpaper):
notify_user("I can't your wallpaper."
.format(wallpaper))
sys.exit("I think the wallpaper is {0} but I can't find it."
.format(wallpaper))
try:
image_filename = open(wallpaper.rstrip(), 'rb')
except:
sys.exit("Could not open image file.")
av_hue, av_lum, av_sat = get_average(image_filename)
#r, g, b = fast_colorthief.get_dominant_color(image_filename, 1)
palette_list = fast_colorthief.get_palette(image_filename, 5, 1)
choice1_h, choice1_l, choice1_s = colorsys.rgb_to_hls(palette_list[0][0]/255, palette_list[0][1]/255, palette_list[0][2]/255)
choice2_h, choice2_l, choice2_s = colorsys.rgb_to_hls(palette_list[1][0]/255, palette_list[1][1]/255, palette_list[1][2]/255)
#print(av_hue, av_lum, av_sat)
#print(choice1_h, choice1_l, choice1_s)
#print(choice2_h, choice2_l, choice2_s)
hue_delta_1 = abs(av_hue - choice1_h)
hue_delta_2 = abs(av_hue - choice2_h)
#print(hue_delta_1, hue_delta_2)
if hue_delta_1 < hue_delta_2:
primary_h = choice1_h
primary_l = choice1_l
primary_s = choice1_s
else:
primary_h = choice2_h
primary_l = choice2_l
primary_s = choice2_s
#sys.exit()
#primary_h, primary_l, primary_s = colorsys.rgb_to_hls(r/255, g/255, b/255)
# Choose light or dark theme based on wallpaper average lum
if av_lum > 0.36:
# Calculate palette for light theme
app_background = color_triplet(primary_h, 0.96, 0.3)
window_border = color_triplet(primary_h, 0.6, 0.0)
view_background = "255,255,255"
app_foreground = "45,45,45"
#app_foreground = color_triplet(primary_h, 0.15, 0.1)
view_foreground = "30,30,30"
win_border = color_triplet(primary_h, 0.4, primary_s)
#win_border_inactive = color_triplet(primary_h, 0.9, 0.15)
accent = color_triplet(primary_h, 0.6, min(0.82, primary_s))
print("Accent ", primary_s)
view_focus = color_triplet(primary_h, 0.75, primary_s)
view_hover = color_triplet(primary_h, 0.8, primary_s/2.0)
header_background = color_triplet(primary_h, 0.97, 0.5)
button_hover = color_triplet(primary_h, 0.6, 0.0)
print(button_hover)
button_focus = color_triplet(primary_h, 0.65, 0.3)
logout_bg = color_triplet(primary_h, 0.4, 0.5)
logout_fg = color_triplet(primary_h, 0.98, 0.8)
else:
# Calculate palette for dark theme
app_background = color_triplet(primary_h, 0.08, 0.08)
view_background = color_triplet(primary_h, 0.12, 0.16)
app_foreground = color_triplet(primary_h, 0.98, 0.6)
view_foreground = app_foreground
win_border = color_triplet(primary_h, 0.3, primary_s)
win_border_inactive = color_triplet(primary_h, 0.25, 0.07)
accent = color_triplet(primary_h, 0.35, primary_s)
view_focus = accent
view_hover = color_triplet(primary_h, 0.35, primary_s/2.0)
header_background = color_triplet(primary_h, 0.2, 0.1)
button_hover = color_triplet(primary_h, 0.31, 0.04)
button_focus = color_triplet(primary_h, 0.65, 0.3)
# Set window decoration colors
win_base = app_background.split(',')
win_hi = accent.split(',')
#win_hi_inact = win_border_inactive.split(',')
#win_frame = window_border.split(',')
# Fill the template with our colors
plasma_colors = plasma_colors.replace('#aa', app_background)
plasma_colors = plasma_colors.replace('#bb', view_background)
plasma_colors = plasma_colors.replace('#cc', app_foreground)
plasma_colors = plasma_colors.replace('#dd', view_foreground)
plasma_colors = plasma_colors.replace('#ee', accent)
plasma_colors = plasma_colors.replace('#ff', view_focus)
plasma_colors = plasma_colors.replace('#gg', view_hover)
plasma_colors = plasma_colors.replace('#hh', header_background)
plasma_colors = plasma_colors.replace('#ii', button_hover)
plasma_colors = plasma_colors.replace('#jj', button_focus)
plasma_colors = plasma_colors.replace('#kk', logout_bg)
plasma_colors = plasma_colors.replace('#ll', logout_fg)
auroraerc = auroraerc.replace('#aa', view_background)
auroraerc = auroraerc.replace('#bb', app_foreground)
# Write changes to aurorae config and re-generate decoration.svg
aurorae(win_base, win_hi)
# Set Global Colours
try:
with open(os.path.expanduser(
'~/.local/share/color-schemes/Tincture.colors'), 'w') as f:
f.write(plasma_colors)
except IOError as e:
sys.exit(e)
# If icon theme has changed, copy current icon theme into our global config
try:
with open(os.path.expanduser('~/.config/kdeglobals'), 'r') as f:
contents = f.readlines()
except IOError as e:
sys.exit(e)
flag = 0
icon_theme = ''
for line in contents:
if flag == 1:
icon_theme = line
break
if line.find('[Icons]') != -1:
flag = 1
if icon_theme:
print("Icon theme changed")
icon_theme = icon_theme.split('=')
icon_theme = icon_theme[1].strip()
try:
with open(os.path.expanduser('~/.local/share/plasma/look-and-feel/Tincture/contents/defaults'), 'r') as f:
contents = f.read()
except IOError as e:
sys.exit(e)
search_string = '[kdeglobals][Icons]\nTheme='
index = contents.find(search_string) + len(search_string)
search_end = contents[index:].find('\n')
current_theme = (contents[index:index+search_end].strip())
new_config = contents.replace(current_theme, icon_theme, 1)
try:
with open(os.path.expanduser('~/.local/share/plasma/look-and-feel/Tincture/contents/defaults'), 'w') as f:
f.write(new_config)
except IOError as e:
sys.exit(e)
try:
#subprocess.run(['kwriteconfig5', '--file=kwinrc',
#'--group=org.kde.kdecoration2', '--key=BorderSizeAuto', 'false'])
time.sleep(0.5)
subprocess.run(['lookandfeeltool', '--apply', 'Tincture', '2>/dev/null'], capture_output=True)
# Keep these if needed
# time.sleep(1.0)
# subprocess.run(['qdbus', 'org.kde.plasmashell', '/PlasmaShell', 'refreshCurrentShell'])
#subprocess.run(['qdbus', 'org.kde.KWin', '/KWin', 'reconfigure'])
except IOError as e:
sys.exit(e)
......@@ -200,7 +200,7 @@ def get_average(fd):
with Image.open(fd) as img:
pil_image = img.resize((1,1))
q = pil_image.getpixel((0,0))
print("Average single pixel: ", q)
#print("Average single pixel: ", q)
hls = colorsys.rgb_to_hls(q[0]/255, q[1]/255, q[2]/255)
return(hls)
......@@ -272,8 +272,20 @@ except:
av_hue, av_lum, av_sat = get_average(image_filename)
r, g, b = fast_colorthief.get_dominant_color(image_filename, 1)
primary_h, primary_l, primary_s = colorsys.rgb_to_hls(r/255, g/255, b/255)
palette_list = fast_colorthief.get_palette(image_filename, 5, 1)
choice1_h, choice1_l, choice1_s = colorsys.rgb_to_hls(palette_list[0][0]/255, palette_list[0][1]/255, palette_list[0][2]/255)
choice2_h, choice2_l, choice2_s = colorsys.rgb_to_hls(palette_list[1][0]/255, palette_list[1][1]/255, palette_list[1][2]/255)
hue_delta_1 = abs(av_hue - choice1_h)
hue_delta_2 = abs(av_hue - choice2_h)
if hue_delta_1 < hue_delta_2:
primary_h = choice1_h
primary_l = choice1_l
primary_s = choice1_s
else:
primary_h = choice2_h
primary_l = choice2_l
primary_s = choice2_s
# Choose light or dark theme based on wallpaper average lum
if av_lum > 0.36:
......@@ -285,14 +297,11 @@ if av_lum > 0.36:
#app_foreground = color_triplet(primary_h, 0.15, 0.1)
view_foreground = "30,30,30"
win_border = color_triplet(primary_h, 0.4, primary_s)
#win_border_inactive = color_triplet(primary_h, 0.9, 0.15)
accent = color_triplet(primary_h, 0.6, min(0.85, primary_s))
print("Accent ", primary_s)
accent = color_triplet(primary_h, 0.6, min(0.82, primary_s))
view_focus = color_triplet(primary_h, 0.75, primary_s)
view_hover = color_triplet(primary_h, 0.8, primary_s/2.0)
header_background = color_triplet(primary_h, 0.97, 0.5)
button_hover = color_triplet(primary_h, 0.6, 0.0)
print(button_hover)
button_focus = color_triplet(primary_h, 0.65, 0.3)
logout_bg = color_triplet(primary_h, 0.4, 0.5)
logout_fg = color_triplet(primary_h, 0.98, 0.8)
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment