Skip to content

Commit

Permalink
Merge branch 'dev' into testing
Browse files Browse the repository at this point in the history
  • Loading branch information
luisbocanegra committed Aug 16, 2022
2 parents 21d1137 + ce27503 commit 2bb89a9
Show file tree
Hide file tree
Showing 7 changed files with 739 additions and 244 deletions.
875 changes: 674 additions & 201 deletions LICENSE

Large diffs are not rendered by default.

11 changes: 3 additions & 8 deletions PKGBUILD
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ pkgrel=1
pkgdesc="Automatic Material You Colors Generator from your wallpaper for the Plasma Desktop"
arch=('x86_64')
url="https://github.com/luisbocanegra/kde-material-you-colors"
license=('APACHE')
depends=("dbus-python" "python-numpy")
license=('GPL3')
depends=("dbus-python" "python-numpy" "python-pillow" "python-regex" "python-material-color-utilities")
optdepends=('python-colr: colored hex codes printing'
'python-pywal: theme other programs using Material You Colors'
)
Expand All @@ -24,13 +24,8 @@ package() {
install -Dm644 kde-material-you-colors.desktop ${pkgdir}/usr/lib/${pkgname}/kde-material-you-colors.desktop
install -Dm644 sample_config.conf ${pkgdir}/usr/lib/${pkgname}/sample_config.conf
install -Dm755 kde-material-you-colors ${pkgdir}/usr/lib/${pkgname}/kde-material-you-colors
install -Dm755 utils.py ${pkgdir}/usr/lib/${pkgname}/utils.py
install -Dm755 color_utils.py ${pkgdir}/usr/lib/${pkgname}/color_utils.py
install -Dm755 schemeconfigs.py ${pkgdir}/usr/lib/${pkgname}/schemeconfigs.py
install -Dm755 material-color-utility-bin ${pkgdir}/usr/lib/${pkgname}/material-color-utility-bin
install -Dm755 libSkiaSharp.so ${pkgdir}/usr/lib/${pkgname}/libSkiaSharp.so
find . -type f -name "*.py" -exec install -Dm755 {,${pkgdir}/usr/lib/${pkgname}/}{} \;
install -dm755 ${pkgdir}/usr/bin
ln -s /usr/lib/${pkgname}/material-color-utility-bin ${pkgdir}/usr/bin/material-color-utility
ln -s /usr/lib/${pkgname}/kde-material-you-colors ${pkgdir}/usr/bin/kde-material-you-colors
install -Dm644 LICENSE ${pkgdir}/usr/share/licenses/${pkgname}/LICENSE
}
10 changes: 10 additions & 0 deletions color_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,16 @@ def lighteen_color(hex_color, min, blend):
# print(f"result after blend: {o}")
return o

def scale_saturation(hex_color, amount):
r, g, b = hex2rgb(hex_color)
# convert rgb to hls
h, s, v = colorsys.rgb_to_hsv(r, g, b)
# manipulate value and convert back to rgb
r, g, b = colorsys.hsv_to_rgb(h, amount, v)
o_hex = rgb2hex(int(r), int(g), int(b))
# print(f"scale_lightness color: {hex_color} * amount: {amount} = {o_hex}")
return o_hex

# Tests
if __name__ == '__main__':
# Test color blend
Expand Down
12 changes: 6 additions & 6 deletions install-fedora-based.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,11 @@ fi;

echo -e "${BGreen}Installing dependencies${clean}"
dnf update
dnf install python3 python3-dbus python3-numpy
dnf install python3 python3-dbus python3-numpy python3-pillow python3-pip

echo -e "${BGreen}Installing python PIP package material_color_utilities_python as user $SUDO_USER ${clean}"

sudo -u $SUDO_USER pip3 install monet/material_color_utilities_python-0.1.0-py3-none-any.whl

echo -e "${BGreen}Installing kde-material-you-colors${clean}"
# Cleanup
Expand All @@ -19,8 +23,6 @@ rm -rf /usr/lib/${pkgname}
mkdir -p /usr/lib/${pkgname}
cp -f *.{py,conf,desktop} /usr/lib/${pkgname}/
cp -f kde-material-you-colors /usr/lib/${pkgname}/kde-material-you-colors
cp -f material-color-utility-bin /usr/lib/${pkgname}/material-color-utility-bin
cp -f libSkiaSharp.so /usr/lib/${pkgname}/libSkiaSharp.so
chmod 755 /usr/lib/${pkgname}/*.py

mkdir -p /usr/share/licenses/kde-material-you-colors/
Expand All @@ -29,7 +31,5 @@ chmod 664 /usr/share/licenses/${pkgname}/LICENSE
chmod 664 /usr/lib/${pkgname}/*.{desktop,conf}

chmod 755 /usr/lib/${pkgname}/kde-material-you-colors
chmod 755 /usr/lib/${pkgname}/material-color-utility-bin
chmod 755 /usr/lib/${pkgname}/libSkiaSharp.so
ln -sf /usr/lib/${pkgname}/kde-material-you-colors /usr/bin/kde-material-you-colors
ln -sf /usr/lib/${pkgname}/material-color-utility-bin /usr/bin/material-color-utility

11 changes: 5 additions & 6 deletions install-ubuntu-based.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,11 @@ fi;

echo -e "${BGreen}Installing dependencies${clean}"
apt update
apt install python3 python3-dbus python3-numpy
apt install python3 python3-dbus python3-numpy python3-pillow python3-pip

echo -e "${BGreen}Installing python PIP package material_color_utilities_python as user $SUDO_USER ${clean}"

sudo -u $SUDO_USER pip3 install monet/material_color_utilities_python-0.1.0-py3-none-any.whl

echo -e "${BGreen}Installing kde-material-you-colors${clean}"
# Cleanup
Expand All @@ -19,8 +23,6 @@ rm -rf /usr/lib/${pkgname}
mkdir -p /usr/lib/${pkgname}
cp -f *.{py,conf,desktop} /usr/lib/${pkgname}/
cp -f kde-material-you-colors /usr/lib/${pkgname}/kde-material-you-colors
cp -f material-color-utility-bin /usr/lib/${pkgname}/material-color-utility-bin
cp -f libSkiaSharp.so /usr/lib/${pkgname}/libSkiaSharp.so
chmod 755 /usr/lib/${pkgname}/*.py

mkdir -p /usr/share/licenses/kde-material-you-colors/
Expand All @@ -29,7 +31,4 @@ chmod 664 /usr/share/licenses/${pkgname}/LICENSE
chmod 664 /usr/lib/${pkgname}/*.{desktop,conf}

chmod 755 /usr/lib/${pkgname}/kde-material-you-colors
chmod 755 /usr/lib/${pkgname}/material-color-utility-bin
chmod 755 /usr/lib/${pkgname}/libSkiaSharp.so
ln -sf /usr/lib/${pkgname}/kde-material-you-colors /usr/bin/kde-material-you-colors
ln -sf /usr/lib/${pkgname}/material-color-utility-bin /usr/bin/material-color-utility
Binary file not shown.
64 changes: 41 additions & 23 deletions schemeconfigs.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from color_utils import blendColors, color_luminance, hex2rgb, hex2alpha, sort_colors_luminance, blend2contrast, lighteen_color
from color_utils import blendColors, contrast_ratio, hex2rgb, hex2alpha, scale_saturation, sort_colors_luminance, blend2contrast, lighteen_color
from utils import range_check, tup2str
class ThemeConfig:
def __init__(self, colors, wallpaper_data, light_blend_multiplier=1, dark_blend_multiplier=1, toolbar_opacity=100):
Expand Down Expand Up @@ -83,7 +83,7 @@ def __init__(self, colors, wallpaper_data, light_blend_multiplier=1, dark_blend_
for x in range(7):
str_x = str(x)
if (len(pywal_colors_dark) <= 7):
if str_x in colors_best.keys(): #and color_luminance(colors_best[str_x])[1] > .15
if str_x in colors_best.keys():
c = lighteen_color(colors_best[str_x],.2,tones_neutral[99])
pywal_colors_dark += (blend2contrast(c, pywal_colors_dark[0], tones_neutral[99], 4.5, .01, True),)
else:
Expand All @@ -109,43 +109,61 @@ def __init__(self, colors, wallpaper_data, light_blend_multiplier=1, dark_blend_
tones_neutral[99], sorted_colors[n], .85),)


tone = 38
tone = 50
pywal_colors_light = (extras['SurfaceLight'],)
pywal_colors_light_intense = (blendColors(
tones_neutral[20], colors_light['secondary'], .6*lbm),)
tones_neutral[20], colors_light['secondary'], .8*lbm),)
pywal_colors_light_faint = (blendColors(
tones_neutral[55], colors_light['secondary'], .6*lbm),)
tones_neutral[55], colors_light['secondary'], .8*lbm),)

# for x in range(7):
# str_x = str(x)
# if str_x in colors_best.keys()and color_luminance(colors_best[str_x])[1] > .15: #and contrast_ratio(pywal_colors_light[0],colors_best[str_x]) > .8
# pywal_colors_light += (blend2contrast(colors_best[str_x], pywal_colors_light[0], tones_neutral[20], 4.5, .01, False),)
# else:
# pywal_colors_light += (blend2contrast(tones_primary[tone], pywal_colors_light[0], tones_neutral[20], 4.5, .01, False),)
# pywal_colors_light += (blend2contrast(tones_tertiary[tone], pywal_colors_light[0], tones_neutral[20], 4.5, .01, False),)
# if tone < 91:
# tone += 8

for x in range(best_colors_count):
for x in range(7):
str_x = str(x)
if str_x in colors_best.keys()and color_luminance(colors_best[str_x])[1] > .15: #and contrast_ratio(pywal_colors_light[0],colors_best[str_x]) > .8
pywal_colors_light += (blend2contrast(colors_best[str_x], pywal_colors_light[0], tones_neutral[20], 4.5, .01, False),)
if (len(pywal_colors_light) <= 7):
if str_x in colors_best.keys():
c = scale_saturation(colors_best[str_x],1)
pywal_colors_light += (blend2contrast(c, pywal_colors_light[0], tones_neutral[20], 3, .01, False),)
else:
if (len(pywal_colors_light) <= 7):
c = scale_saturation(tones_primary[tone],1)
pywal_colors_light += (blend2contrast(c, pywal_colors_light[0], tones_neutral[20], 3, .01, False),)
if (len(pywal_colors_light) <= 7):
c = scale_saturation(tones_tertiary[tone],1)
pywal_colors_light += (blend2contrast(c, pywal_colors_light[0], tones_neutral[20], 3, .01, False),)
if tone < 91:
tone += 8
else:
pywal_colors_light += (blend2contrast(tones_primary[tone], pywal_colors_light[0], tones_neutral[20], 4.5, .01, False),)
pywal_colors_light += (blend2contrast(tones_tertiary[tone], pywal_colors_light[0], tones_neutral[20], 4.5, .01, False),)
if tone < 91:
tone += 8
break

all = pywal_colors_light
pywal_colors_light = (pywal_colors_light[0],)
sorted_colors = sort_colors_luminance(sort_colors_luminance(all,reverse=True)[-7:])
sorted_colors = sort_colors_luminance(all,True)[-7:]

for n in range(len(sorted_colors)):
pywal_colors_light_intense += (sorted_colors[n],)
pywal_colors_light += (blendColors(
tones_neutral[40], sorted_colors[n], .75*lbm),)
tones_neutral[30], sorted_colors[n], .8*lbm),)
pywal_colors_light_faint += (blendColors(
tones_neutral[40], sorted_colors[n], .6*lbm),)
tones_neutral[60], sorted_colors[n], .8*lbm),)


''' print("CONTRAST CHECK DARK")
for color in pywal_colors_dark:
c = contrast_ratio(color, pywal_colors_dark[0])
print(f"{color} - {c}")
print("CONTRAST CHECK LIGHT")
for color in pywal_colors_light:
c = contrast_ratio(pywal_colors_light[0],color)
print(f"{color} - {c}") '''
# print("CONTRAST CHECK DARK")
# for color in pywal_colors_dark:
# c = contrast_ratio(color, pywal_colors_dark[0])
# print(f"{color} - {c}")
# print("CONTRAST CHECK LIGHT")
# for color in pywal_colors_light:
# c = contrast_ratio(pywal_colors_light[0],color)
# print(f"{color} - {c}")

self._light_scheme = f"""[ColorEffects:Disabled]
Color={extras['SurfaceLight1']}
Expand Down

0 comments on commit 2bb89a9

Please sign in to comment.