forked from Shinonome/caelestia-cli
scheme: dynamic light theme
Autodetect based on wallpaper Also resize wallpaper so faster And async magick blur so wallpaper doesnt block
This commit is contained in:
@@ -0,0 +1 @@
|
|||||||
|
__pycache__/
|
||||||
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
. (dirname (status filename))/util.fish
|
. (dirname (status filename))/util.fish
|
||||||
|
|
||||||
install-deps git hyprland-git hyprpaper-git okolors-git imagemagick wl-clipboard fuzzel-git socat foot jq
|
install-deps git hyprland-git hyprpaper-git okolors-git imagemagick wl-clipboard fuzzel-git socat foot jq python python-pillow python-materialyoucolor-git
|
||||||
install-optional-deps 'vesktop-bin (discord client)' 'btop (system monitor)' 'wf-recorder (screen recorder)' 'grim (screenshot tool)' 'firefox (web browser)' 'spotify-adblock (music player)'
|
install-optional-deps 'vesktop-bin (discord client)' 'btop (system monitor)' 'wf-recorder (screen recorder)' 'grim (screenshot tool)' 'firefox (web browser)' 'spotify-adblock (music player)'
|
||||||
|
|
||||||
set -l dist $CONFIG/scripts
|
set -l dist $CONFIG/scripts
|
||||||
|
|||||||
@@ -79,7 +79,6 @@ end
|
|||||||
if test -d $CONFIG/gtk
|
if test -d $CONFIG/gtk
|
||||||
log 'Generating GTK+ schemes'
|
log 'Generating GTK+ schemes'
|
||||||
gen-gtk $colours
|
gen-gtk $colours
|
||||||
$CONFIG/gtk/update-scheme.fish
|
|
||||||
end
|
end
|
||||||
|
|
||||||
# Reload programs if dynamic scheme
|
# Reload programs if dynamic scheme
|
||||||
|
|||||||
@@ -7,13 +7,19 @@ function nl-echo
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
. (dirname (status filename))/../util.fish
|
set -l src (dirname (status filename))
|
||||||
|
|
||||||
|
. $src/../util.fish
|
||||||
|
|
||||||
set -l colour_names rosewater flamingo pink mauve red maroon peach yellow green teal sky sapphire blue lavender
|
set -l colour_names rosewater flamingo pink mauve red maroon peach yellow green teal sky sapphire blue lavender
|
||||||
set -l layer_names text subtext1 subtext0 overlay2 overlay1 overlay0 surface2 surface1 surface0 base mantle crust
|
set -l layer_names text subtext1 subtext0 overlay2 overlay1 overlay0 surface2 surface1 surface0 base mantle crust
|
||||||
|
|
||||||
test -f "$argv[1]" && set -l img "$argv[1]" || set -l img $CACHE/wallpaper/current
|
test -f "$argv[1]" && set -l img "$argv[1]" || set -l img $CACHE/wallpaper/current
|
||||||
set -l colours_raw (okolors (realpath $img) -k 15 -w 0 -l 70,90,75,65,40,35,30,25,20,15,10,8,6)
|
set -l img ($src/resizeimg.py $img)
|
||||||
|
|
||||||
|
$src/islight.py $img && set -l light_vals 40,6,8,10,45,50,55,60,65,70,75,80,85,90 || set -l light_vals 70,90,75,65,40,35,30,25,20,15,10,8,6
|
||||||
|
|
||||||
|
set -l colours_raw (okolors (realpath $img) -k 15 -w 0 -l $light_vals)
|
||||||
set -l colours (string split ' ' $colours_raw[2])[2..]
|
set -l colours (string split ' ' $colours_raw[2])[2..]
|
||||||
set -l layers (nl-echo $colours_raw | cut -f 1 -d ' ')[3..]
|
set -l layers (nl-echo $colours_raw | cut -f 1 -d ' ')[3..]
|
||||||
|
|
||||||
|
|||||||
Executable
+16
@@ -0,0 +1,16 @@
|
|||||||
|
#!/bin/python
|
||||||
|
|
||||||
|
import sys
|
||||||
|
from PIL import Image
|
||||||
|
from materialyoucolor.quantize import QuantizeCelebi
|
||||||
|
from materialyoucolor.score.score import Score
|
||||||
|
from materialyoucolor.hct import Hct
|
||||||
|
from resizeimg import resize
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
with Image.open(sys.argv[1]) as img:
|
||||||
|
img = resize(img)[0]
|
||||||
|
colours = QuantizeCelebi(list(img.getdata()), 128)
|
||||||
|
hct = Hct.from_int(Score.score(colours)[0])
|
||||||
|
sys.exit(0 if hct.tone > 60 else 1)
|
||||||
Executable
+29
@@ -0,0 +1,29 @@
|
|||||||
|
#!/bin/python
|
||||||
|
|
||||||
|
import sys
|
||||||
|
import math
|
||||||
|
from PIL import Image
|
||||||
|
|
||||||
|
|
||||||
|
def calc_size(w, h, b = 128):
|
||||||
|
ia = w * h
|
||||||
|
ba = b * b
|
||||||
|
s = math.sqrt(ba / ia) if ia > ba else 1
|
||||||
|
return max(1, round(w * s)), max(1, round(h * s))
|
||||||
|
|
||||||
|
|
||||||
|
def resize(img):
|
||||||
|
w, h = calc_size(img.width, img.height)
|
||||||
|
if w < img.width or h < img.height:
|
||||||
|
return img.resize((w, h), Image.Resampling.BICUBIC), True
|
||||||
|
return img, False
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
with Image.open(sys.argv[1]) as img:
|
||||||
|
img, resized = resize(img)
|
||||||
|
if resized:
|
||||||
|
img.save("/tmp/caelestia-resize.png")
|
||||||
|
print("/tmp/caelestia-resize.png")
|
||||||
|
else:
|
||||||
|
print(sys.argv[1])
|
||||||
+1
-1
@@ -114,5 +114,5 @@ else
|
|||||||
mkdir -p $cache_dir
|
mkdir -p $cache_dir
|
||||||
echo $chosen_wallpaper > $last_wallpaper_path
|
echo $chosen_wallpaper > $last_wallpaper_path
|
||||||
ln -sf $chosen_wallpaper "$cache_dir/current"
|
ln -sf $chosen_wallpaper "$cache_dir/current"
|
||||||
magick $chosen_wallpaper -fill black -colorize 10% -blur 0x10 "$cache_dir/blur"
|
magick $chosen_wallpaper -fill black -colorize 10% -blur 0x10 "$cache_dir/blur" &
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user