-
-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
241 additions
and
217 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
Oops, something went wrong.