mirror of
https://github.com/caelestia-dots/cli.git
synced 2026-06-05 14:59:29 -05:00
feat: up to 3 options for dynamic scheme
Have up to 3 options for base colour for dynamic scheme Variants moved to new command Also remove parallel dependency
This commit is contained in:
@@ -23,6 +23,7 @@ COMMAND := help | install | shell | toggle | workspace-action | scheme | screens
|
|||||||
toggle: toggle a special workspace
|
toggle: toggle a special workspace
|
||||||
workspace-action: execute a Hyprland workspace dispatcher in the current group
|
workspace-action: execute a Hyprland workspace dispatcher in the current group
|
||||||
scheme: change the current colour scheme
|
scheme: change the current colour scheme
|
||||||
|
variant: change the current scheme variant
|
||||||
screenshot: take a screenshot
|
screenshot: take a screenshot
|
||||||
record: take a screen recording
|
record: take a screen recording
|
||||||
clipboard: open clipboard history
|
clipboard: open clipboard history
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
set -l seen '__fish_seen_subcommand_from'
|
set -l seen '__fish_seen_subcommand_from'
|
||||||
set -l has_opt '__fish_contains_opt'
|
set -l has_opt '__fish_contains_opt'
|
||||||
set -l commands help install shell toggle workspace-action scheme screenshot record clipboard clipboard-delete emoji-picker wallpaper pip
|
set -l commands help install shell toggle workspace-action scheme variant screenshot record clipboard clipboard-delete emoji-picker wallpaper pip
|
||||||
set -l not_seen "not $seen $commands"
|
set -l not_seen "not $seen $commands"
|
||||||
|
|
||||||
# Disable file completions
|
# Disable file completions
|
||||||
@@ -13,6 +13,7 @@ complete -c caelestia -n $not_seen -a 'shell' -d 'Start the shell or message it'
|
|||||||
complete -c caelestia -n $not_seen -a 'toggle' -d 'Toggle a special workspace'
|
complete -c caelestia -n $not_seen -a 'toggle' -d 'Toggle a special workspace'
|
||||||
complete -c caelestia -n $not_seen -a 'workspace-action' -d 'Exec a dispatcher in the current group'
|
complete -c caelestia -n $not_seen -a 'workspace-action' -d 'Exec a dispatcher in the current group'
|
||||||
complete -c caelestia -n $not_seen -a 'scheme' -d 'Switch the current colour scheme'
|
complete -c caelestia -n $not_seen -a 'scheme' -d 'Switch the current colour scheme'
|
||||||
|
complete -c caelestia -n $not_seen -a 'variant' -d 'Switch the current scheme variant'
|
||||||
complete -c caelestia -n $not_seen -a 'screenshot' -d 'Take a screenshot'
|
complete -c caelestia -n $not_seen -a 'screenshot' -d 'Take a screenshot'
|
||||||
complete -c caelestia -n $not_seen -a 'record' -d 'Take a screen recording'
|
complete -c caelestia -n $not_seen -a 'record' -d 'Take a screen recording'
|
||||||
complete -c caelestia -n $not_seen -a 'clipboard' -d 'Open clipboard history'
|
complete -c caelestia -n $not_seen -a 'clipboard' -d 'Open clipboard history'
|
||||||
@@ -69,6 +70,10 @@ for scheme in $commands
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Variant
|
||||||
|
set -l commands vibrant tonalspot expressive fidelity fruitsalad rainbow neutral content monochrome
|
||||||
|
complete -c caelestia -n "$seen variant && not $seen $commands" -a "$commands"
|
||||||
|
|
||||||
# Record
|
# Record
|
||||||
set -l not_seen "$seen record && not $has_opt -s h help"
|
set -l not_seen "$seen record && not $has_opt -s h help"
|
||||||
complete -c caelestia -n "$not_seen && not $has_opt -s s sound && not $has_opt -s r region && not $has_opt -s c compression && not $has_opt -s H hwaccel" \
|
complete -c caelestia -n "$not_seen && not $has_opt -s s sound && not $has_opt -s r region && not $has_opt -s c compression && not $has_opt -s H hwaccel" \
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
. (dirname (status filename))/util.fish
|
. (dirname (status filename))/util.fish
|
||||||
|
|
||||||
install-deps git hyprland-git hyprpaper-git imagemagick wl-clipboard fuzzel-git socat foot jq python xdg-user-dirs python-materialyoucolor-git app2unit-git parallel
|
install-deps git hyprland-git hyprpaper-git imagemagick wl-clipboard fuzzel-git socat foot jq python xdg-user-dirs python-materialyoucolor-git app2unit-git
|
||||||
install-optional-deps 'equibop-bin (discord client)' 'btop (system monitor)' 'wf-recorder (screen recorder)' 'grim (screenshot tool)' 'zen-browser (web browser)' 'spotify-adblock (music player)'
|
install-optional-deps 'equibop-bin (discord client)' 'btop (system monitor)' 'wf-recorder (screen recorder)' 'grim (screenshot tool)' 'zen-browser (web browser)' 'spotify-adblock (music player)'
|
||||||
|
|
||||||
set -l dist $C_DATA/scripts
|
set -l dist $C_DATA/scripts
|
||||||
|
|||||||
@@ -44,6 +44,18 @@ if test "$argv[1]" = scheme
|
|||||||
exit
|
exit
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if test "$argv[1]" = variant
|
||||||
|
set -l variants vibrant tonalspot expressive fidelity fruitsalad rainbow neutral content monochrome
|
||||||
|
if contains -- "$argv[2]" $variants
|
||||||
|
echo -n $argv[2] > $C_STATE/scheme/current-variant.txt
|
||||||
|
$src/scheme/gen-scheme.fish
|
||||||
|
else
|
||||||
|
error "Invalid variant: $argv[2]"
|
||||||
|
end
|
||||||
|
|
||||||
|
exit
|
||||||
|
end
|
||||||
|
|
||||||
if test "$argv[1]" = install
|
if test "$argv[1]" = install
|
||||||
set -l valid_modules scripts btop discord firefox fish foot fuzzel hypr safeeyes shell slurp spicetify gtk qt vscode
|
set -l valid_modules scripts btop discord firefox fish foot fuzzel hypr safeeyes shell slurp spicetify gtk qt vscode
|
||||||
if test "$argv[2]" = all
|
if test "$argv[2]" = all
|
||||||
@@ -76,6 +88,7 @@ echo ' shell: start the shell or message it'
|
|||||||
echo ' toggle: toggle a special workspace'
|
echo ' toggle: toggle a special workspace'
|
||||||
echo ' workspace-action: execute a Hyprland workspace dispatcher in the current group'
|
echo ' workspace-action: execute a Hyprland workspace dispatcher in the current group'
|
||||||
echo ' scheme: change the current colour scheme'
|
echo ' scheme: change the current colour scheme'
|
||||||
|
echo ' variant: change the current scheme variant'
|
||||||
echo ' screenshot: take a screenshot'
|
echo ' screenshot: take a screenshot'
|
||||||
echo ' record: take a screen recording'
|
echo ' record: take a screen recording'
|
||||||
echo ' clipboard: open clipboard history'
|
echo ' clipboard: open clipboard history'
|
||||||
|
|||||||
+47
-29
@@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
import sys
|
import sys
|
||||||
from colorsys import hls_to_rgb, rgb_to_hls
|
from colorsys import hls_to_rgb, rgb_to_hls
|
||||||
|
from pathlib import Path
|
||||||
|
|
||||||
from materialyoucolor.dynamiccolor.material_dynamic_colors import (
|
from materialyoucolor.dynamiccolor.material_dynamic_colors import (
|
||||||
DynamicScheme,
|
DynamicScheme,
|
||||||
@@ -17,7 +18,6 @@ from materialyoucolor.scheme.scheme_neutral import SchemeNeutral
|
|||||||
from materialyoucolor.scheme.scheme_rainbow import SchemeRainbow
|
from materialyoucolor.scheme.scheme_rainbow import SchemeRainbow
|
||||||
from materialyoucolor.scheme.scheme_tonal_spot import SchemeTonalSpot
|
from materialyoucolor.scheme.scheme_tonal_spot import SchemeTonalSpot
|
||||||
from materialyoucolor.scheme.scheme_vibrant import SchemeVibrant
|
from materialyoucolor.scheme.scheme_vibrant import SchemeVibrant
|
||||||
from materialyoucolor.utils.color_utils import argb_from_rgb
|
|
||||||
|
|
||||||
light_colours = [
|
light_colours = [
|
||||||
"dc8a78",
|
"dc8a78",
|
||||||
@@ -101,7 +101,9 @@ def grayscale(hls: HLS, light: bool) -> HLS:
|
|||||||
def mix(a: HLS, b: HLS, w: float) -> HLS:
|
def mix(a: HLS, b: HLS, w: float) -> HLS:
|
||||||
r1, g1, b1 = hls_to_rgb(*a)
|
r1, g1, b1 = hls_to_rgb(*a)
|
||||||
r2, g2, b2 = hls_to_rgb(*b)
|
r2, g2, b2 = hls_to_rgb(*b)
|
||||||
return rgb_to_hls(r1 * (1 - w) + r2 * w, g1 * (1 - w) + g2 * w, b1 * (1 - w) + b2 * w)
|
return rgb_to_hls(
|
||||||
|
r1 * (1 - w) + r2 * w, g1 * (1 - w) + g2 * w, b1 * (1 - w) + b2 * w
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
def darken(colour: HLS, amount: float) -> HLS:
|
def darken(colour: HLS, amount: float) -> HLS:
|
||||||
@@ -161,16 +163,23 @@ def get_scheme(scheme: str) -> DynamicScheme:
|
|||||||
return SchemeVibrant
|
return SchemeVibrant
|
||||||
|
|
||||||
|
|
||||||
|
def get_alt(i: int) -> str:
|
||||||
|
names = ["default", "alt1", "alt2"]
|
||||||
|
return names[i]
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
light = sys.argv[1] == "light"
|
light = sys.argv[1] == "light"
|
||||||
scheme = sys.argv[2]
|
scheme = sys.argv[2]
|
||||||
colours_in = sys.argv[3].split(" ")
|
primaries = sys.argv[3].split(" ")
|
||||||
|
colours_in = sys.argv[4].split(" ")
|
||||||
|
out_path = sys.argv[5]
|
||||||
|
|
||||||
base = light_colours if light else dark_colours
|
base = light_colours if light else dark_colours
|
||||||
chroma_mult = 1.5 if light else 1.2
|
chroma_mult = 1.5 if light else 1.2
|
||||||
|
|
||||||
# Convert to HLS
|
# Convert to HLS
|
||||||
colours = [hex_to_hls(c) for c in colours_in[1:]]
|
colours = [hex_to_hls(c) for c in colours_in]
|
||||||
|
|
||||||
# Sort colours and turn into dict
|
# Sort colours and turn into dict
|
||||||
colours = smart_sort(colours, base)
|
colours = smart_sort(colours, base)
|
||||||
@@ -192,36 +201,45 @@ if __name__ == "__main__":
|
|||||||
|
|
||||||
colour.chroma *= chroma_mult
|
colour.chroma *= chroma_mult
|
||||||
|
|
||||||
colours[name] = hex_to_hls("{:02X}{:02X}{:02X}".format(*colour.to_rgba()[:3]))
|
colours[name] = hex_to_hls(
|
||||||
|
"{:02X}{:02X}{:02X}".format(*colour.to_rgba()[:3])
|
||||||
|
)
|
||||||
|
|
||||||
# Success and error colours
|
# Success and error colours
|
||||||
colours["success"] = mix(colours["green"], hex_to_hls(base[8]), 0.8)
|
colours["success"] = mix(colours["green"], hex_to_hls(base[8]), 0.8)
|
||||||
colours["error"] = mix(colours["red"], hex_to_hls(base[4]), 0.8)
|
colours["error"] = mix(colours["red"], hex_to_hls(base[4]), 0.8)
|
||||||
|
|
||||||
# Layers and accents
|
# Layers and accents
|
||||||
material = {}
|
for i, primary in enumerate(primaries):
|
||||||
primary_scheme = MatScheme(Hct.from_int(int(f"0xFF{colours_in[0]}", 16)), not light, 0)
|
material = {}
|
||||||
for colour in vars(MaterialDynamicColors).keys():
|
primary_scheme = MatScheme(
|
||||||
colour_name = getattr(MaterialDynamicColors, colour)
|
Hct.from_int(int(f"0xFF{primary}", 16)), not light, 0
|
||||||
if hasattr(colour_name, "get_hct"):
|
)
|
||||||
rgb = colour_name.get_hct(primary_scheme).to_rgba()[:3]
|
for colour in vars(MaterialDynamicColors).keys():
|
||||||
material[colour] = hex_to_hls("{:02X}{:02X}{:02X}".format(*rgb))
|
colour_name = getattr(MaterialDynamicColors, colour)
|
||||||
|
if hasattr(colour_name, "get_hct"):
|
||||||
|
rgb = colour_name.get_hct(primary_scheme).to_rgba()[:3]
|
||||||
|
material[colour] = hex_to_hls("{:02X}{:02X}{:02X}".format(*rgb))
|
||||||
|
|
||||||
colours["primary"] = material["primary"]
|
colours["primary"] = material["primary"]
|
||||||
colours["secondary"] = material["secondary"]
|
colours["secondary"] = material["secondary"]
|
||||||
colours["tertiary"] = material["tertiary"]
|
colours["tertiary"] = material["tertiary"]
|
||||||
colours["text"] = material["onBackground"]
|
colours["text"] = material["onBackground"]
|
||||||
colours["subtext1"] = material["onSurfaceVariant"]
|
colours["subtext1"] = material["onSurfaceVariant"]
|
||||||
colours["subtext0"] = material["outline"]
|
colours["subtext0"] = material["outline"]
|
||||||
colours["overlay2"] = mix(material["surface"], material["outline"], 0.86)
|
colours["overlay2"] = mix(material["surface"], material["outline"], 0.86)
|
||||||
colours["overlay1"] = mix(material["surface"], material["outline"], 0.71)
|
colours["overlay1"] = mix(material["surface"], material["outline"], 0.71)
|
||||||
colours["overlay0"] = mix(material["surface"], material["outline"], 0.57)
|
colours["overlay0"] = mix(material["surface"], material["outline"], 0.57)
|
||||||
colours["surface2"] = mix(material["surface"], material["outline"], 0.43)
|
colours["surface2"] = mix(material["surface"], material["outline"], 0.43)
|
||||||
colours["surface1"] = mix(material["surface"], material["outline"], 0.29)
|
colours["surface1"] = mix(material["surface"], material["outline"], 0.29)
|
||||||
colours["surface0"] = mix(material["surface"], material["outline"], 0.14)
|
colours["surface0"] = mix(material["surface"], material["outline"], 0.14)
|
||||||
colours["base"] = material["surface"]
|
colours["base"] = material["surface"]
|
||||||
colours["mantle"] = darken(material["surface"], 0.03)
|
colours["mantle"] = darken(material["surface"], 0.03)
|
||||||
colours["crust"] = darken(material["surface"], 0.05)
|
colours["crust"] = darken(material["surface"], 0.05)
|
||||||
|
|
||||||
for name, colour in colours.items():
|
out_file = Path(f"{out_path}/{scheme}/{get_alt(i)}/{sys.argv[1]}.txt")
|
||||||
print(f"{name} {hls_to_hex(*colour)}")
|
out_file.parent.mkdir(parents=True, exist_ok=True)
|
||||||
|
colour_arr = [
|
||||||
|
f"{name} {hls_to_hex(*colour)}" for name, colour in colours.items()
|
||||||
|
]
|
||||||
|
out_file.write_text("\n".join(colour_arr))
|
||||||
|
|||||||
+18
-19
@@ -5,30 +5,29 @@ set -l src (dirname (status filename))
|
|||||||
. $src/../util.fish
|
. $src/../util.fish
|
||||||
|
|
||||||
test -f "$argv[1]" && set -l img (realpath "$argv[1]") || set -l img $C_STATE/wallpaper/thumbnail.jpg
|
test -f "$argv[1]" && set -l img (realpath "$argv[1]") || set -l img $C_STATE/wallpaper/thumbnail.jpg
|
||||||
contains -- "$argv[2]" light dark && set -l theme $argv[2] || set -l theme dark
|
|
||||||
|
|
||||||
set -l variants vibrant tonalspot expressive fidelity fruitsalad rainbow neutral content monochrome
|
set -l variants vibrant tonalspot expressive fidelity fruitsalad rainbow neutral content monochrome
|
||||||
|
contains -- "$argv[2]" $variants && set -l variant $argv[2] || set -l variant (cat $C_STATE/scheme/current-variant.txt 2> /dev/null)
|
||||||
|
contains -- "$variant" $variants || set -l variant tonalspot
|
||||||
|
|
||||||
set -l hash (sha1sum $img | cut -d ' ' -f 1)
|
set -l hash (sha1sum $img | cut -d ' ' -f 1)
|
||||||
|
|
||||||
# Cache schemes
|
# Cache scheme
|
||||||
mkdir -p $C_CACHE/schemes
|
if ! test -d $C_CACHE/schemes/$hash/$variant
|
||||||
set -l dirty_variants
|
|
||||||
if test -d $C_CACHE/schemes/$hash
|
|
||||||
for variant in $variants
|
|
||||||
test -f $C_CACHE/schemes/$hash/$variant/$theme.txt || set -a dirty_variants $variant
|
|
||||||
end
|
|
||||||
else
|
|
||||||
set dirty_variants $variants
|
|
||||||
end
|
|
||||||
|
|
||||||
if test -n "$dirty_variants"
|
|
||||||
# Generate schemes for variants that need it
|
|
||||||
set -l colours ($src/score.py $img)
|
set -l colours ($src/score.py $img)
|
||||||
parallel "mkdir -p $C_CACHE/schemes/$hash/{} && $src/autoadjust.py $theme {} '$colours' | head -c -1 > $C_CACHE/schemes/$hash/{}/$theme.txt" ::: $dirty_variants
|
$src/autoadjust.py dark $variant $colours $C_CACHE/schemes/$hash
|
||||||
|
$src/autoadjust.py light $variant $colours $C_CACHE/schemes/$hash
|
||||||
end
|
end
|
||||||
|
|
||||||
# Copy schemes from cache
|
# Copy scheme from cache
|
||||||
for variant in $variants
|
rm -rf $src/../data/schemes/dynamic
|
||||||
mkdir -p $src/../data/schemes/dynamic/$variant
|
cp -r $C_CACHE/schemes/$hash/$variant $src/../data/schemes/dynamic
|
||||||
cp $C_CACHE/schemes/$hash/$variant/$theme.txt $src/../data/schemes/dynamic/$variant/$theme.txt
|
|
||||||
|
# Update if current
|
||||||
|
set -l variant (string match -gr 'dynamic-(.*)' (cat $C_STATE/scheme/current-name.txt 2> /dev/null))
|
||||||
|
if test -n "$variant"
|
||||||
|
# If variant doesn't exist, use default
|
||||||
|
test -d $src/../data/schemes/dynamic/$variant || set -l variant default
|
||||||
|
# Apply scheme
|
||||||
|
$src/main.fish dynamic $variant $MODE > /dev/null
|
||||||
end
|
end
|
||||||
|
|||||||
+38
-19
@@ -2,10 +2,10 @@
|
|||||||
|
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
from materialyoucolor.quantize import ImageQuantizeCelebi
|
|
||||||
from materialyoucolor.hct import Hct
|
|
||||||
from materialyoucolor.utils.math_utils import sanitize_degrees_int, difference_degrees
|
|
||||||
from materialyoucolor.dislike.dislike_analyzer import DislikeAnalyzer
|
from materialyoucolor.dislike.dislike_analyzer import DislikeAnalyzer
|
||||||
|
from materialyoucolor.hct import Hct
|
||||||
|
from materialyoucolor.quantize import ImageQuantizeCelebi
|
||||||
|
from materialyoucolor.utils.math_utils import difference_degrees, sanitize_degrees_int
|
||||||
|
|
||||||
|
|
||||||
class Score:
|
class Score:
|
||||||
@@ -20,7 +20,7 @@ class Score:
|
|||||||
pass
|
pass
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def score(colors_to_population: dict) -> list[int]:
|
def score(colors_to_population: dict) -> tuple[list[Hct], list[Hct]]:
|
||||||
desired = 14
|
desired = 14
|
||||||
filter_enabled = False
|
filter_enabled = False
|
||||||
dislike_filter = True
|
dislike_filter = True
|
||||||
@@ -72,7 +72,8 @@ class Score:
|
|||||||
chosen_colors = []
|
chosen_colors = []
|
||||||
for difference_degrees_ in range(90, 0, -1):
|
for difference_degrees_ in range(90, 0, -1):
|
||||||
chosen_colors.clear()
|
chosen_colors.clear()
|
||||||
for hct in [item["hct"] for item in scored_hct]:
|
for item in scored_hct:
|
||||||
|
hct = item["hct"]
|
||||||
duplicate_hue = any(
|
duplicate_hue = any(
|
||||||
difference_degrees(hct.hue, chosen_hct.hue) < difference_degrees_
|
difference_degrees(hct.hue, chosen_hct.hue) < difference_degrees_
|
||||||
for chosen_hct in chosen_colors
|
for chosen_hct in chosen_colors
|
||||||
@@ -85,31 +86,49 @@ class Score:
|
|||||||
break
|
break
|
||||||
|
|
||||||
# Get primary colour
|
# Get primary colour
|
||||||
got_primary = False
|
primary = None
|
||||||
for cutoff in range(20, 0, -1):
|
for cutoff in range(20, 0, -1):
|
||||||
for item in scored_hct:
|
for item in scored_hct:
|
||||||
if item["hct"].chroma > cutoff and item["hct"].tone > cutoff * 3:
|
if item["hct"].chroma > cutoff and item["hct"].tone > cutoff * 3:
|
||||||
chosen_colors.insert(0, item["hct"])
|
primary = item["hct"]
|
||||||
got_primary = True
|
|
||||||
break
|
break
|
||||||
if got_primary:
|
if primary:
|
||||||
|
break
|
||||||
|
|
||||||
|
# Choose distinct primaries
|
||||||
|
chosen_primaries = [primary]
|
||||||
|
for difference_degrees_ in range(90, 14, -1):
|
||||||
|
chosen_primaries = [primary]
|
||||||
|
for item in scored_hct:
|
||||||
|
hct = item["hct"]
|
||||||
|
duplicate_hue = any(
|
||||||
|
difference_degrees(hct.hue, chosen_hct.hue) < difference_degrees_
|
||||||
|
for chosen_hct in chosen_primaries
|
||||||
|
)
|
||||||
|
if not duplicate_hue:
|
||||||
|
chosen_primaries.append(hct)
|
||||||
|
if len(chosen_primaries) >= 3:
|
||||||
|
break
|
||||||
|
if len(chosen_primaries) >= 3:
|
||||||
break
|
break
|
||||||
|
|
||||||
# Fix disliked colours
|
# Fix disliked colours
|
||||||
if dislike_filter:
|
if dislike_filter:
|
||||||
for chosen_hct in chosen_colors:
|
for i, chosen_hct in enumerate(chosen_primaries):
|
||||||
chosen_colors[chosen_colors.index(chosen_hct)] = (
|
chosen_primaries[i] = DislikeAnalyzer.fix_if_disliked(chosen_hct)
|
||||||
DislikeAnalyzer.fix_if_disliked(chosen_hct)
|
for i, chosen_hct in enumerate(chosen_colors):
|
||||||
)
|
chosen_colors[i] = DislikeAnalyzer.fix_if_disliked(chosen_hct)
|
||||||
|
|
||||||
return chosen_colors
|
return chosen_primaries, chosen_colors
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
img = sys.argv[1]
|
img = sys.argv[1]
|
||||||
|
mode = sys.argv[2] if len(sys.argv) > 2 else "hex"
|
||||||
|
|
||||||
colours = ImageQuantizeCelebi(img, 1, 128)
|
colours = Score.score(ImageQuantizeCelebi(img, 1, 128))
|
||||||
colours = [c.to_rgba()[:3] for c in Score.score(colours)]
|
for l in colours:
|
||||||
|
if mode != "hex":
|
||||||
# print("".join(["\x1b[48;2;{};{};{}m \x1b[0m".format(*colour) for colour in colours]))
|
print("".join(["\x1b[48;2;{};{};{}m \x1b[0m".format(*c.to_rgba()[:3]) for c in l]))
|
||||||
print(" ".join(["{:02X}{:02X}{:02X}".format(*colour) for colour in colours]))
|
if mode != "swatch":
|
||||||
|
print(" ".join(["{:02X}{:02X}{:02X}".format(*c.to_rgba()[:3]) for c in l]))
|
||||||
|
|||||||
+7
-16
@@ -114,24 +114,15 @@ else
|
|||||||
end
|
end
|
||||||
cp $thumb_path $state_dir/thumbnail.jpg
|
cp $thumb_path $state_dir/thumbnail.jpg
|
||||||
|
|
||||||
|
# Light/dark mode detection if not specified
|
||||||
|
if ! set -q _flag_T
|
||||||
|
set -l lightness (magick $state_dir/thumbnail.jpg -format '%[fx:int(mean*100)]' info:)
|
||||||
|
test $lightness -ge 60 && set _flag_T light || set _flag_T dark
|
||||||
|
end
|
||||||
|
|
||||||
# Generate colour scheme for wallpaper
|
# Generate colour scheme for wallpaper
|
||||||
set -l src (dirname (status filename))
|
set -l src (dirname (status filename))
|
||||||
$src/scheme/gen-scheme.fish $state_dir/thumbnail.jpg dark &
|
MODE=$_flag_T $src/scheme/gen-scheme.fish &
|
||||||
$src/scheme/gen-scheme.fish $state_dir/thumbnail.jpg light &
|
|
||||||
if test -f $C_STATE/scheme/current-name.txt
|
|
||||||
set -l variant (string match -gr 'dynamic-(.*)' (cat $C_STATE/scheme/current-name.txt))
|
|
||||||
if test -n "$variant"
|
|
||||||
# Light/dark mode detection if not specified
|
|
||||||
if ! set -q _flag_T
|
|
||||||
set -l lightness (magick $state_dir/thumbnail.jpg -format '%[fx:int(mean*100)]' info:)
|
|
||||||
test $lightness -ge 60 && set _flag_T light || set _flag_T dark
|
|
||||||
end
|
|
||||||
# Wait for async scheme gen to finish
|
|
||||||
wait
|
|
||||||
# Apply scheme
|
|
||||||
caelestia scheme dynamic $variant $_flag_T > /dev/null
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
# Store the wallpaper chosen
|
# Store the wallpaper chosen
|
||||||
mkdir -p $state_dir
|
mkdir -p $state_dir
|
||||||
|
|||||||
Reference in New Issue
Block a user