Skip to content

Commit 49fd15e

Browse files
committed
Merge branch 'dev' into testing
2 parents b1712e8 + 865262f commit 49fd15e

File tree

8 files changed

+241
-217
lines changed

8 files changed

+241
-217
lines changed

PKGBUILD

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,13 @@ package() {
2323
cd "${pkgname}-${pkgver}"
2424
install -Dm644 kde-material-you-colors.desktop ${pkgdir}/usr/lib/${pkgname}/kde-material-you-colors.desktop
2525
install -Dm644 sample_config.conf ${pkgdir}/usr/lib/${pkgname}/sample_config.conf
26-
install -Dm755 kde-material-you-colors.py ${pkgdir}/usr/lib/${pkgname}/kde-material-you-colors.py
27-
install -Dm755 kde-material-you-colors ${pkgdir}/usr/bin/kde-material-you-colors
26+
install -Dm755 kde-material-you-colors /usr/lib/${pkgname}/kde-material-you-colors
2827
install -Dm755 color_utils.py ${pkgdir}/usr/lib/${pkgname}/color_utils.py
2928
install -Dm755 utils.py ${pkgdir}/usr/lib/${pkgname}/utils.py
3029
install -Dm755 schemeconfigs.py ${pkgdir}/usr/lib/${pkgname}/schemeconfigs.py
3130
install -Dm755 material-color-utility-bin ${pkgdir}/usr/lib/${pkgname}/material-color-utility-bin
3231
install -Dm755 libSkiaSharp.so ${pkgdir}/usr/lib/${pkgname}/libSkiaSharp.so
32+
ln -s /usr/lib/${pkgname}/kde-material-you-colors ${pkgdir}/usr/bin/kde-material-you-colors
3333
ln -s /usr/lib/${pkgname}/material-color-utility-bin ${pkgdir}/usr/bin/material-color-utility
3434
install -Dm644 LICENSE ${pkgdir}/usr/share/licenses/${pkgname}/LICENSE
3535
}

README.md

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ monitor = 0
162162
plugin = org.kde.image
163163

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

168168
# Enable Light mode
@@ -183,47 +183,49 @@ ncolor = 0
183183
# Commented by default
184184
#iconsdark = Papirus-Dark
185185

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

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

197200
# The amount of perceptible color for backgrounds in dark mode
198201
# A number between 0 and 4.0 (limited for accessibility purposes)
199202
# Defaults to 1 if not set
200-
light_blend_multiplier = 1.0
203+
#light_blend_multiplier = 1.0
201204

202205
# The amount of perceptible color for backgrounds in dark mode
203206
# A number between 0 and 4.0 (limited for accessibility purposes)
204207
# Defaults to 1 if not set
205-
dark_blend_multiplier = 1.0
208+
#dark_blend_multiplier = 1.0
206209

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

212214
# Tint SierraBreeze decoration buttons https://github.com/ishovkun/SierraBreeze
213215
# Accepted values are True or False
214216
# Default is False
215217
# NOTE:
216-
# This WILL OVERWRITE any set colors and reload KWin
218+
# This WILL OVERWRITE any set colors and reload KWin (screen will blink on x11)
217219
#sierra_breeze_buttons_color = True
218220

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

install-fedora-based.sh

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,12 @@ dnf update
1313
dnf install python3 python3-dbus python3-numpy
1414

1515
echo -e "${BGreen}Installing kde-material-you-colors${clean}"
16+
# Cleanup
17+
rm -rf /usr/lib/${pkgname}
18+
1619
mkdir -p /usr/lib/${pkgname}
1720
cp -f *.{py,conf,desktop} /usr/lib/${pkgname}/
18-
cp -f kde-material-you-colors /usr/bin/kde-material-you-colors
21+
cp -f kde-material-you-colors /usr/lib/${pkgname}/kde-material-you-colors
1922
cp -f material-color-utility-bin /usr/lib/${pkgname}/material-color-utility-bin
2023
cp -f libSkiaSharp.so /usr/lib/${pkgname}/libSkiaSharp.so
2124
chmod 755 /usr/lib/${pkgname}/*.py
@@ -25,7 +28,8 @@ cp -f LICENSE /usr/share/licenses/${pkgname}/LICENSE
2528
chmod 664 /usr/share/licenses/${pkgname}/LICENSE
2629
chmod 664 /usr/lib/${pkgname}/*.{desktop,conf}
2730

28-
chmod 755 /usr/bin/kde-material-you-colors
31+
chmod 755 /usr/lib/${pkgname}/kde-material-you-colors
2932
chmod 755 /usr/lib/${pkgname}/material-color-utility-bin
3033
chmod 755 /usr/lib/${pkgname}/libSkiaSharp.so
34+
ln -sf /usr/lib/${pkgname}/kde-material-you-colors /usr/bin/kde-material-you-colors
3135
ln -sf /usr/lib/${pkgname}/material-color-utility-bin /usr/bin/material-color-utility

install-ubuntu-based.sh

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,12 @@ apt update
1313
apt install python3 python3-dbus python3-numpy
1414

1515
echo -e "${BGreen}Installing kde-material-you-colors${clean}"
16+
# Cleanup
17+
rm -rf /usr/lib/${pkgname}
18+
1619
mkdir -p /usr/lib/${pkgname}
1720
cp -f *.{py,conf,desktop} /usr/lib/${pkgname}/
18-
cp -f kde-material-you-colors /usr/bin/kde-material-you-colors
21+
cp -f kde-material-you-colors /usr/lib/${pkgname}/kde-material-you-colors
1922
cp -f material-color-utility-bin /usr/lib/${pkgname}/material-color-utility-bin
2023
cp -f libSkiaSharp.so /usr/lib/${pkgname}/libSkiaSharp.so
2124
chmod 755 /usr/lib/${pkgname}/*.py
@@ -25,7 +28,8 @@ cp -f LICENSE /usr/share/licenses/${pkgname}/LICENSE
2528
chmod 664 /usr/share/licenses/${pkgname}/LICENSE
2629
chmod 664 /usr/lib/${pkgname}/*.{desktop,conf}
2730

28-
chmod 755 /usr/bin/kde-material-you-colors
31+
chmod 755 /usr/lib/${pkgname}/kde-material-you-colors
2932
chmod 755 /usr/lib/${pkgname}/material-color-utility-bin
3033
chmod 755 /usr/lib/${pkgname}/libSkiaSharp.so
31-
ln -sf /usr/lib/${pkgname}/material-color-utility-bin /usr/bin/material-color-utility
34+
ln -sf /usr/lib/${pkgname}/kde-material-you-colors /usr/bin/kde-material-you-colors
35+
ln -sf /usr/lib/${pkgname}/material-color-utility-bin /usr/bin/material-color-utility

kde-material-you-colors

Lines changed: 190 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,190 @@
1-
#!/bin/sh
2-
/usr/bin/python3 /usr/lib/kde-material-you-colors/kde-material-you-colors.py "$@"
1+
#!/usr/bin/python3
2+
import logging
3+
import time
4+
import os
5+
import argparse
6+
import utils
7+
from schemeconfigs import ThemeConfig
8+
if __name__ == '__main__':
9+
# Make sure the schemes path exists
10+
if not os.path.exists(utils.USER_SCHEMES_PATH):
11+
os.makedirs(utils.USER_SCHEMES_PATH)
12+
parser = argparse.ArgumentParser(
13+
description='Automatic Material You Colors Generator from your wallpaper for the Plasma Desktop')
14+
parser.add_argument('--monitor', '-m', type=int,
15+
help='Monitor to get wallpaper (default is 0) but second one is 6 in my case, play with this to find yours', default=None)
16+
parser.add_argument('--plugin', '-p', type=str,
17+
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)
18+
parser.add_argument('--file', '-f', type=str,
19+
help='Text file that contains wallpaper absolute path (Takes precedence over the above options)', default=None)
20+
parser.add_argument('--ncolor', '-n', type=int,
21+
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)
22+
parser.add_argument('--light', '-l', action='store_true',
23+
help='Enable Light mode (default is Dark)')
24+
parser.add_argument('--dark', '-d', action='store_true',
25+
help='Enable Dark mode (ignores user config)')
26+
parser.add_argument('--autostart', '-a', action='store_true',
27+
help='Enable (copies) the startup script to automatically start with KDE')
28+
parser.add_argument('--copyconfig', '-c', action='store_true',
29+
help='Copies the default config to ~/.config/kde-material-you-colors/config.conf')
30+
parser.add_argument('--iconslight', type=str,
31+
help='Icons for Dark scheme', default=None)
32+
parser.add_argument('--iconsdark', type=str,
33+
help='Icons for Light scheme', default=None)
34+
parser.add_argument('--pywal', '-wal', action='store_true',
35+
help='Use pywal to theme other apps with Material You')
36+
parser.add_argument('--pywallight', '-wall', action='store_true',
37+
help='Use Light mode for pywal controlled apps')
38+
parser.add_argument('--pywaldark', '-wald', action='store_true',
39+
help='Use Dark mode for pywal controlled apps')
40+
parser.add_argument('--lbmultiplier', '-lbm', type=float,
41+
help='The amount of color for backgrounds in Light mode (value from 0 to 4.0, default is 1)',default=None)
42+
parser.add_argument('--dbmultiplier', '-dbm', type=float,
43+
help='The amount of color for backgrounds in Dark mode (value from 0 to 4.0, default is 1)',default=None)
44+
parser.add_argument('--on-change-hook', type=str,
45+
help='A script/command that will be executed on start or wallpaper/dark/light/settings change',default=None)
46+
parser.add_argument('--sierra-breeze-buttons-color', '-sbb', action='store_true',
47+
help='Tint SierraBreeze decoration buttons')
48+
parser.add_argument('--konsole-profile', '-kp', type=str,
49+
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)
50+
51+
# Get arguments
52+
args = parser.parse_args()
53+
# Get config from file
54+
config = utils.Configs(args)
55+
#kill existing instance if found
56+
utils.kill_existing()
57+
options_old = config.options
58+
logging.debug(f"Config: {options_old}")
59+
icons_old = [options_old['iconslight'], options_old['iconsdark']]
60+
light_old = options_old['light']
61+
# Get the current wallpaper on startup
62+
wallpaper_old = utils.currentWallpaper(options_old)
63+
kde_globals_light_old=utils.kde_globals_light()
64+
pywal_light_old=options_old['pywal_light']
65+
konsole_profile_old=options_old['konsole_profile']
66+
konsole_profile_mod_time_old = None
67+
if konsole_profile_old != None:
68+
konsole_profile_mod_time_old = utils.get_last_modification(utils.KONSOLE_DIR+konsole_profile_old+".profile")
69+
if wallpaper_old != None and wallpaper_old[1] != None:
70+
wallpaper_old_type = wallpaper_old[0]
71+
wallpaper_old_data = wallpaper_old[1]
72+
logging.info(f'Using wallpaper: {wallpaper_old_data}')
73+
colors = utils.get_color_schemes(wallpaper_old,options_old['ncolor'])
74+
75+
# if wallpaper is image save time of last modification
76+
if wallpaper_old_type == "image":
77+
wallpaper_mod_time_old = utils.get_last_modification(wallpaper_old_data)
78+
else:
79+
wallpaper_mod_time_old = None
80+
81+
light = False
82+
if options_old['light'] == None:
83+
if kde_globals_light_old != None:
84+
light=kde_globals_light_old
85+
else:
86+
light = options_old['light']
87+
88+
if colors != None:
89+
schemes = ThemeConfig(colors,wallpaper_old_data,light_blend_multiplier=options_old['lbm'], dark_blend_multiplier=options_old['dbm'])
90+
utils.make_plasma_scheme(schemes=schemes)
91+
utils.apply_color_schemes(
92+
light=light)
93+
if options_old['sierra_breeze_buttons_color'] == True:
94+
utils.sierra_breeze_button_colors(schemes,light)
95+
utils.set_icons(icons_light=options_old['iconslight'],
96+
icons_dark=options_old['iconsdark'], light=options_old['light'])
97+
utils.make_konsole_mirror_profile(konsole_profile_old)
98+
utils.konsole_apply_color_scheme(light,options_old['pywal_light'],schemes,options_old['konsole_profile'])
99+
utils.apply_pywal_schemes(
100+
light=light, use_pywal=options_old['pywal'], pywal_light=options_old['pywal_light'], schemes=schemes)
101+
utils.run_hook(options_old['on_change_hook'])
102+
print("---------------------")
103+
# check wallpaper change
104+
while True:
105+
# reload config file
106+
config = utils.Configs(args)
107+
options_new = config.options
108+
wallpaper_new = utils.currentWallpaper(options_new)
109+
kde_globals_light_new=utils.kde_globals_light()
110+
pywal_light_new=options_new['pywal_light']
111+
konsole_profile_new=options_new['konsole_profile']
112+
konsole_profile_mod_time_new = None
113+
if konsole_profile_new != None:
114+
konsole_profile_mod_time_new = utils.get_last_modification(utils.KONSOLE_DIR+konsole_profile_new+".profile")
115+
if wallpaper_new != None and wallpaper_new[1] != None:
116+
wallpaper_new_type = wallpaper_new[0]
117+
wallpaper_new_data = wallpaper_new[1]
118+
119+
# if wallpaper is image save time of last modification
120+
if wallpaper_new_type == "image":
121+
wallpaper_mod_time_new = utils.get_last_modification(wallpaper_new_data)
122+
else:
123+
wallpaper_mod_time_new = None
124+
125+
icons_new = [options_new['iconslight'], options_new['iconsdark']]
126+
light_new = options_new['light']
127+
128+
wallpaper_changed = wallpaper_old != wallpaper_new
129+
wallpaper_modified = wallpaper_mod_time_old != wallpaper_mod_time_new
130+
options_changed = options_new != options_old
131+
icons_changed = icons_new != icons_old
132+
light_changed = light_new != light_old
133+
kde_globals_light_changed = kde_globals_light_old != kde_globals_light_new
134+
pywal_light_changed = pywal_light_old != pywal_light_new
135+
konsole_profile_changed = konsole_profile_old != konsole_profile_new
136+
konsole_profile_modified = konsole_profile_mod_time_new != konsole_profile_mod_time_old
137+
light=False
138+
if options_new['light'] == None:
139+
if kde_globals_light_new != None:
140+
light=kde_globals_light_new
141+
else:
142+
light = options_new['light']
143+
if konsole_profile_modified == True or konsole_profile_changed == True:
144+
utils.make_konsole_mirror_profile(konsole_profile_new)
145+
konsole_profile_mod_time_old = konsole_profile_mod_time_new
146+
147+
if wallpaper_changed or options_changed or wallpaper_modified:
148+
if wallpaper_changed or wallpaper_modified:
149+
logging.info(f'Wallpaper changed: {wallpaper_new_data}')
150+
if options_changed:
151+
logging.debug(f"New Config: {options_new}")
152+
colors = utils.get_color_schemes(wallpaper_new,options_new['ncolor'])
153+
if colors != None:
154+
schemes = ThemeConfig(colors,wallpaper_new_data,light_blend_multiplier=options_new['lbm'], dark_blend_multiplier=options_new['dbm'])
155+
utils.make_plasma_scheme(schemes=schemes)
156+
if options_changed:
157+
if icons_changed or light_changed:
158+
utils.set_icons(
159+
icons_light=options_new['iconslight'], icons_dark=options_new['iconsdark'], light=light)
160+
161+
utils.apply_color_schemes(light=light)
162+
if options_new['sierra_breeze_buttons_color'] == True:
163+
utils.sierra_breeze_button_colors(schemes,light)
164+
utils.konsole_apply_color_scheme(light,options_new['pywal_light'],schemes,options_new['konsole_profile'])
165+
utils.apply_pywal_schemes(
166+
light=light, use_pywal=options_new['pywal'], pywal_light=options_new['pywal_light'], schemes=schemes)
167+
utils.run_hook(options_new['on_change_hook'])
168+
print("---------------------")
169+
elif kde_globals_light_changed and kde_globals_light_new != None:
170+
if colors != None:
171+
if options_new['sierra_breeze_buttons_color'] == True:
172+
utils.sierra_breeze_button_colors(schemes,kde_globals_light_new)
173+
utils.set_icons(icons_light=options_new['iconslight'],
174+
icons_dark=options_new['iconsdark'], light=kde_globals_light_new)
175+
utils.konsole_apply_color_scheme(light,options_new['pywal_light'],schemes,options_new['konsole_profile'])
176+
utils.apply_pywal_schemes(
177+
light=kde_globals_light_new, use_pywal=options_new['pywal'], pywal_light=options_new['pywal_light'], schemes=schemes)
178+
179+
utils.run_hook(options_new['on_change_hook'])
180+
print("---------------------")
181+
wallpaper_old = wallpaper_new
182+
wallpaper_mod_time_old = wallpaper_mod_time_new
183+
options_old = options_new
184+
icons_old = icons_new
185+
light_old = light_new
186+
kde_globals_light_old = kde_globals_light_new
187+
pywal_light_old = pywal_light_new
188+
konsole_profile_old = konsole_profile_new
189+
konsole_profile_mod_time_old = konsole_profile_mod_time_new
190+
time.sleep(1)

0 commit comments

Comments
 (0)