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 Apr 27, 2022
2 parents b1712e8 + 865262f commit 49fd15e
Show file tree
Hide file tree
Showing 8 changed files with 241 additions and 217 deletions.
4 changes: 2 additions & 2 deletions PKGBUILD
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,13 @@ package() {
cd "${pkgname}-${pkgver}"
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.py ${pkgdir}/usr/lib/${pkgname}/kde-material-you-colors.py
install -Dm755 kde-material-you-colors ${pkgdir}/usr/bin/kde-material-you-colors
install -Dm755 kde-material-you-colors /usr/lib/${pkgname}/kde-material-you-colors
install -Dm755 color_utils.py ${pkgdir}/usr/lib/${pkgname}/color_utils.py
install -Dm755 utils.py ${pkgdir}/usr/lib/${pkgname}/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
ln -s /usr/lib/${pkgname}/kde-material-you-colors ${pkgdir}/usr/bin/kde-material-you-colors
ln -s /usr/lib/${pkgname}/material-color-utility-bin ${pkgdir}/usr/bin/material-color-utility
install -Dm644 LICENSE ${pkgdir}/usr/share/licenses/${pkgname}/LICENSE
}
24 changes: 13 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ monitor = 0
plugin = org.kde.image

# File containing absolute path of an image (Takes precedence over the above options as they are no longer needed)
# Commented out by default
# Commented by default
#file = /tmp/000_eDP-1_current_wallpaper

# Enable Light mode
Expand All @@ -183,47 +183,49 @@ ncolor = 0
# Commented by default
#iconsdark = Papirus-Dark

# Use pywal to theme other programs using Material You colors (experimental)
# Use pywal to theme other programs using Material You colors
# https://github.com/dylanaraps/pywal/wiki/Customization
# You need to install pywal python module first
# Accepted values are True or False
# Commented by default
#pywal=True

# Force light/dark mode for pywal
# Force light/dark mode for pywal and/or Konsole
# Accepted values are True or False comment out to dark/light scheme
# Commented by default
# Commented by default (Follows light option above)
# NOTE:
# Theming konsole only doesn't require pywal, just setting konsole_profile below
#pywal_light = False

# The amount of perceptible color for backgrounds in dark mode
# A number between 0 and 4.0 (limited for accessibility purposes)
# Defaults to 1 if not set
light_blend_multiplier = 1.0
#light_blend_multiplier = 1.0

# The amount of perceptible color for backgrounds in dark mode
# A number between 0 and 4.0 (limited for accessibility purposes)
# Defaults to 1 if not set
dark_blend_multiplier = 1.0
#dark_blend_multiplier = 1.0

# A script/command that will be executed on start or wallpaper/dark/light/settings change
# Commented by default
# example below using https://github.com/vlevit/notify-send.sh to send a desktop notification
# example below using https://github.com/vlevit/notify-send.sh to send a desktop notification:
#on_change_hook = notify-send.sh "kde-material-you-colors" "This is a test" -t 2000

# Tint SierraBreeze decoration buttons https://github.com/ishovkun/SierraBreeze
# Accepted values are True or False
# Default is False
# NOTE:
# This WILL OVERWRITE any set colors and reload KWin
# This WILL OVERWRITE any set colors and reload KWin (screen will blink on x11)
#sierra_breeze_buttons_color = True

# Dynamically updated Konsole color scheme
# Accepted value is the name of your current Konsole profile, except TempMyou and Default profile as is read only
# Default is commented (disabled)
# WARNING:
# I recommend you to backup the ~/.local/share/konsole/ folder before trying this because it will edit your profiles
# NOTE:
# This makes a temp profile named TempMyou.profile and MaterialYou/MaterialYouAlt color schemes to switch between them automatically in all open Konsole instances
# You can make direct changes to your profile, but for the color scheme edit MaterialYou one
# WARNING:
# I recommend you to backup the ~/.local/share/konsole/ folder before trying this because it will edit your profiles
#konsole_profile = Profile 1
```

Expand Down
8 changes: 6 additions & 2 deletions install-fedora-based.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,12 @@ dnf update
dnf install python3 python3-dbus python3-numpy

echo -e "${BGreen}Installing kde-material-you-colors${clean}"
# Cleanup
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/bin/kde-material-you-colors
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
Expand All @@ -25,7 +28,8 @@ cp -f LICENSE /usr/share/licenses/${pkgname}/LICENSE
chmod 664 /usr/share/licenses/${pkgname}/LICENSE
chmod 664 /usr/lib/${pkgname}/*.{desktop,conf}

chmod 755 /usr/bin/kde-material-you-colors
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
10 changes: 7 additions & 3 deletions install-ubuntu-based.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,12 @@ apt update
apt install python3 python3-dbus python3-numpy

echo -e "${BGreen}Installing kde-material-you-colors${clean}"
# Cleanup
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/bin/kde-material-you-colors
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
Expand All @@ -25,7 +28,8 @@ cp -f LICENSE /usr/share/licenses/${pkgname}/LICENSE
chmod 664 /usr/share/licenses/${pkgname}/LICENSE
chmod 664 /usr/lib/${pkgname}/*.{desktop,conf}

chmod 755 /usr/bin/kde-material-you-colors
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}/material-color-utility-bin /usr/bin/material-color-utility
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
192 changes: 190 additions & 2 deletions kde-material-you-colors
Original file line number Diff line number Diff line change
@@ -1,2 +1,190 @@
#!/bin/sh
/usr/bin/python3 /usr/lib/kde-material-you-colors/kde-material-you-colors.py "$@"
#!/usr/bin/python3
import logging
import time
import os
import argparse
import utils
from schemeconfigs import ThemeConfig
if __name__ == '__main__':
# Make sure the schemes path exists
if not os.path.exists(utils.USER_SCHEMES_PATH):
os.makedirs(utils.USER_SCHEMES_PATH)
parser = argparse.ArgumentParser(
description='Automatic Material You Colors Generator from your wallpaper for the Plasma Desktop')
parser.add_argument('--monitor', '-m', type=int,
help='Monitor to get wallpaper (default is 0) but second one is 6 in my case, play with this to find yours', default=None)
parser.add_argument('--plugin', '-p', type=str,
help=f'Wallpaper plugin id (default is {utils.DEFAULT_PLUGIN}) you can find them in: /usr/share/plasma/wallpapers/ or ~/.local/share/plasma/wallpapers', default=None)
parser.add_argument('--file', '-f', type=str,
help='Text file that contains wallpaper absolute path (Takes precedence over the above options)', default=None)
parser.add_argument('--ncolor', '-n', type=int,
help='Alternative color mode (default is 0), some images return more than one color, this will use either the matched or last one', default=None)
parser.add_argument('--light', '-l', action='store_true',
help='Enable Light mode (default is Dark)')
parser.add_argument('--dark', '-d', action='store_true',
help='Enable Dark mode (ignores user config)')
parser.add_argument('--autostart', '-a', action='store_true',
help='Enable (copies) the startup script to automatically start with KDE')
parser.add_argument('--copyconfig', '-c', action='store_true',
help='Copies the default config to ~/.config/kde-material-you-colors/config.conf')
parser.add_argument('--iconslight', type=str,
help='Icons for Dark scheme', default=None)
parser.add_argument('--iconsdark', type=str,
help='Icons for Light scheme', default=None)
parser.add_argument('--pywal', '-wal', action='store_true',
help='Use pywal to theme other apps with Material You')
parser.add_argument('--pywallight', '-wall', action='store_true',
help='Use Light mode for pywal controlled apps')
parser.add_argument('--pywaldark', '-wald', action='store_true',
help='Use Dark mode for pywal controlled apps')
parser.add_argument('--lbmultiplier', '-lbm', type=float,
help='The amount of color for backgrounds in Light mode (value from 0 to 4.0, default is 1)',default=None)
parser.add_argument('--dbmultiplier', '-dbm', type=float,
help='The amount of color for backgrounds in Dark mode (value from 0 to 4.0, default is 1)',default=None)
parser.add_argument('--on-change-hook', type=str,
help='A script/command that will be executed on start or wallpaper/dark/light/settings change',default=None)
parser.add_argument('--sierra-breeze-buttons-color', '-sbb', action='store_true',
help='Tint SierraBreeze decoration buttons')
parser.add_argument('--konsole-profile', '-kp', type=str,
help='The name of your (existing) Konsole profile that is going to be themed, you can check your current profiles with konsole --list-profiles', default=None)

# Get arguments
args = parser.parse_args()
# Get config from file
config = utils.Configs(args)
#kill existing instance if found
utils.kill_existing()
options_old = config.options
logging.debug(f"Config: {options_old}")
icons_old = [options_old['iconslight'], options_old['iconsdark']]
light_old = options_old['light']
# Get the current wallpaper on startup
wallpaper_old = utils.currentWallpaper(options_old)
kde_globals_light_old=utils.kde_globals_light()
pywal_light_old=options_old['pywal_light']
konsole_profile_old=options_old['konsole_profile']
konsole_profile_mod_time_old = None
if konsole_profile_old != None:
konsole_profile_mod_time_old = utils.get_last_modification(utils.KONSOLE_DIR+konsole_profile_old+".profile")
if wallpaper_old != None and wallpaper_old[1] != None:
wallpaper_old_type = wallpaper_old[0]
wallpaper_old_data = wallpaper_old[1]
logging.info(f'Using wallpaper: {wallpaper_old_data}')
colors = utils.get_color_schemes(wallpaper_old,options_old['ncolor'])

# if wallpaper is image save time of last modification
if wallpaper_old_type == "image":
wallpaper_mod_time_old = utils.get_last_modification(wallpaper_old_data)
else:
wallpaper_mod_time_old = None

light = False
if options_old['light'] == None:
if kde_globals_light_old != None:
light=kde_globals_light_old
else:
light = options_old['light']

if colors != None:
schemes = ThemeConfig(colors,wallpaper_old_data,light_blend_multiplier=options_old['lbm'], dark_blend_multiplier=options_old['dbm'])
utils.make_plasma_scheme(schemes=schemes)
utils.apply_color_schemes(
light=light)
if options_old['sierra_breeze_buttons_color'] == True:
utils.sierra_breeze_button_colors(schemes,light)
utils.set_icons(icons_light=options_old['iconslight'],
icons_dark=options_old['iconsdark'], light=options_old['light'])
utils.make_konsole_mirror_profile(konsole_profile_old)
utils.konsole_apply_color_scheme(light,options_old['pywal_light'],schemes,options_old['konsole_profile'])
utils.apply_pywal_schemes(
light=light, use_pywal=options_old['pywal'], pywal_light=options_old['pywal_light'], schemes=schemes)
utils.run_hook(options_old['on_change_hook'])
print("---------------------")
# check wallpaper change
while True:
# reload config file
config = utils.Configs(args)
options_new = config.options
wallpaper_new = utils.currentWallpaper(options_new)
kde_globals_light_new=utils.kde_globals_light()
pywal_light_new=options_new['pywal_light']
konsole_profile_new=options_new['konsole_profile']
konsole_profile_mod_time_new = None
if konsole_profile_new != None:
konsole_profile_mod_time_new = utils.get_last_modification(utils.KONSOLE_DIR+konsole_profile_new+".profile")
if wallpaper_new != None and wallpaper_new[1] != None:
wallpaper_new_type = wallpaper_new[0]
wallpaper_new_data = wallpaper_new[1]

# if wallpaper is image save time of last modification
if wallpaper_new_type == "image":
wallpaper_mod_time_new = utils.get_last_modification(wallpaper_new_data)
else:
wallpaper_mod_time_new = None

icons_new = [options_new['iconslight'], options_new['iconsdark']]
light_new = options_new['light']

wallpaper_changed = wallpaper_old != wallpaper_new
wallpaper_modified = wallpaper_mod_time_old != wallpaper_mod_time_new
options_changed = options_new != options_old
icons_changed = icons_new != icons_old
light_changed = light_new != light_old
kde_globals_light_changed = kde_globals_light_old != kde_globals_light_new
pywal_light_changed = pywal_light_old != pywal_light_new
konsole_profile_changed = konsole_profile_old != konsole_profile_new
konsole_profile_modified = konsole_profile_mod_time_new != konsole_profile_mod_time_old
light=False
if options_new['light'] == None:
if kde_globals_light_new != None:
light=kde_globals_light_new
else:
light = options_new['light']
if konsole_profile_modified == True or konsole_profile_changed == True:
utils.make_konsole_mirror_profile(konsole_profile_new)
konsole_profile_mod_time_old = konsole_profile_mod_time_new

if wallpaper_changed or options_changed or wallpaper_modified:
if wallpaper_changed or wallpaper_modified:
logging.info(f'Wallpaper changed: {wallpaper_new_data}')
if options_changed:
logging.debug(f"New Config: {options_new}")
colors = utils.get_color_schemes(wallpaper_new,options_new['ncolor'])
if colors != None:
schemes = ThemeConfig(colors,wallpaper_new_data,light_blend_multiplier=options_new['lbm'], dark_blend_multiplier=options_new['dbm'])
utils.make_plasma_scheme(schemes=schemes)
if options_changed:
if icons_changed or light_changed:
utils.set_icons(
icons_light=options_new['iconslight'], icons_dark=options_new['iconsdark'], light=light)

utils.apply_color_schemes(light=light)
if options_new['sierra_breeze_buttons_color'] == True:
utils.sierra_breeze_button_colors(schemes,light)
utils.konsole_apply_color_scheme(light,options_new['pywal_light'],schemes,options_new['konsole_profile'])
utils.apply_pywal_schemes(
light=light, use_pywal=options_new['pywal'], pywal_light=options_new['pywal_light'], schemes=schemes)
utils.run_hook(options_new['on_change_hook'])
print("---------------------")
elif kde_globals_light_changed and kde_globals_light_new != None:
if colors != None:
if options_new['sierra_breeze_buttons_color'] == True:
utils.sierra_breeze_button_colors(schemes,kde_globals_light_new)
utils.set_icons(icons_light=options_new['iconslight'],
icons_dark=options_new['iconsdark'], light=kde_globals_light_new)
utils.konsole_apply_color_scheme(light,options_new['pywal_light'],schemes,options_new['konsole_profile'])
utils.apply_pywal_schemes(
light=kde_globals_light_new, use_pywal=options_new['pywal'], pywal_light=options_new['pywal_light'], schemes=schemes)

utils.run_hook(options_new['on_change_hook'])
print("---------------------")
wallpaper_old = wallpaper_new
wallpaper_mod_time_old = wallpaper_mod_time_new
options_old = options_new
icons_old = icons_new
light_old = light_new
kde_globals_light_old = kde_globals_light_new
pywal_light_old = pywal_light_new
konsole_profile_old = konsole_profile_new
konsole_profile_mod_time_old = konsole_profile_mod_time_new
time.sleep(1)
Loading

0 comments on commit 49fd15e

Please sign in to comment.