mirror of
https://github.com/caelestia-dots/cli.git
synced 2026-06-05 14:59:29 -05:00
scheme: better light/dark theme detection
This commit is contained in:
@@ -1 +0,0 @@
|
|||||||
__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 python python-pillow python-materialyoucolor-git
|
install-deps git hyprland-git hyprpaper-git okolors-git imagemagick wl-clipboard fuzzel-git socat foot jq python
|
||||||
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
|
||||||
|
|||||||
@@ -15,9 +15,11 @@ set -l colour_names rosewater flamingo pink mauve red maroon peach yellow green
|
|||||||
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 img ($src/resizeimg.py $img)
|
set -l img (realpath $img)
|
||||||
|
|
||||||
if $src/islight.py $img
|
# Light theme if background lighter than foreground
|
||||||
|
set -l bg_fg ($src/getlightness.py (okolors $img -k 2 | string split ' '))
|
||||||
|
if test "$bg_fg[1]" -gt "$bg_fg[2]"
|
||||||
set light_vals 40,6,8,10,45,50,55,60,65,70,75,80,85,90
|
set light_vals 40,6,8,10,45,50,55,60,65,70,75,80,85,90
|
||||||
set colour_scheme light
|
set colour_scheme light
|
||||||
else
|
else
|
||||||
@@ -27,7 +29,7 @@ end
|
|||||||
|
|
||||||
test "$(cat $CACHE/scheme/current.txt)" = dynamic && gsettings set org.gnome.desktop.interface color-scheme \'prefer-$colour_scheme\'
|
test "$(cat $CACHE/scheme/current.txt)" = dynamic && gsettings set org.gnome.desktop.interface color-scheme \'prefer-$colour_scheme\'
|
||||||
|
|
||||||
set -l colours_raw (okolors (realpath $img) -k 15 -w 0 -l $light_vals)
|
set -l colours_raw (okolors $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
+8
@@ -0,0 +1,8 @@
|
|||||||
|
#!/bin/python3
|
||||||
|
|
||||||
|
import sys
|
||||||
|
from colorsys import rgb_to_hls
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
for arg in sys.argv[1:]:
|
||||||
|
print(rgb_to_hls(*tuple(int(arg[i:i+2], 16) for i in (0, 2, 4)))[1])
|
||||||
@@ -1,16 +0,0 @@
|
|||||||
#!/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)
|
|
||||||
@@ -1,29 +0,0 @@
|
|||||||
#!/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])
|
|
||||||
Reference in New Issue
Block a user