summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author2 * r + 2 * t <61896496+soramanew@users.noreply.github.com>2025-01-26 00:05:01 +1100
committer2 * r + 2 * t <61896496+soramanew@users.noreply.github.com>2025-01-26 00:05:01 +1100
commit231185d3397483c58483a714e0cf0d4ec5bd8e5a (patch)
tree35205bec9a8469eb7b4e686ed1d81ebb02329cf5
parenttoggle-communication: use discord integration (diff)
downloadcaelestia-cli-231185d3397483c58483a714e0cf0d4ec5bd8e5a.tar.gz
caelestia-cli-231185d3397483c58483a714e0cf0d4ec5bd8e5a.tar.bz2
caelestia-cli-231185d3397483c58483a714e0cf0d4ec5bd8e5a.zip
scheme: dynamic scheme
-rw-r--r--data/foot.template36
-rwxr-xr-xmain.fish2
-rwxr-xr-xscheme/apply-scheme.fish53
-rwxr-xr-xscheme/gen-scheme.fish26
-rwxr-xr-xwallpaper.fish6
5 files changed, 121 insertions, 2 deletions
diff --git a/data/foot.template b/data/foot.template
new file mode 100644
index 0000000..edb68db
--- /dev/null
+++ b/data/foot.template
@@ -0,0 +1,36 @@
+[cursor]
+color=$crust $rosewater
+
+[colors]
+foreground=$text
+background=$base
+
+regular0=$surface1
+regular1=$red
+regular2=$green
+regular3=$yellow
+regular4=$blue
+regular5=$pink
+regular6=$teal
+regular7=$subtext1
+
+bright0=$surface2
+bright1=$red
+bright2=$green
+bright3=$yellow
+bright4=$blue
+bright5=$pink
+bright6=$teal
+bright7=$subtext0
+
+16=$peach
+17=$rosewater
+
+selection-foreground=$text
+selection-background=$surface1
+
+search-box-no-match=$crust $red
+search-box-match=$text $surface0
+
+jump-labels=$crust $peach
+urls=$blue
diff --git a/main.fish b/main.fish
index 5dcef11..382d2ea 100755
--- a/main.fish
+++ b/main.fish
@@ -32,7 +32,7 @@ if test "$argv[1]" = workspace-action
end
if test "$argv[1]" = scheme
- set -l valid_schemes mocha macchiato frappe latte
+ set -l valid_schemes dynamic mocha macchiato frappe latte
contains "$argv[2]" $valid_schemes && echo -n $argv[2] > $CACHE/scheme/current.txt || error "Invalid scheme: $argv[2]"
exit
end
diff --git a/scheme/apply-scheme.fish b/scheme/apply-scheme.fish
new file mode 100755
index 0000000..df5bcba
--- /dev/null
+++ b/scheme/apply-scheme.fish
@@ -0,0 +1,53 @@
+#!/bin/fish
+
+function gen-hypr
+ for colour in $argv
+ set -l split (string split ' ' $colour)
+ echo "\$$split[1] = $split[2]"
+ end
+end
+
+function gen-scss
+ for colour in $argv
+ set -l split (string split ' ' $colour)
+ echo "\$$split[1]: #$split[2];"
+ end
+end
+
+function gen-foot
+ cp (dirname (status filename))/../data/foot.template $CONFIG/../foot/schemes/dynamic.ini
+ for colour in $argv
+ set -l split (string split ' ' $colour)
+ sed -i "s/\$$split[1]/$split[2]/g" $CONFIG/../foot/schemes/dynamic.ini
+ end
+end
+
+. (dirname (status filename))/../util.fish
+
+set -l src (dirname (status filename))
+set -l colours ($src/gen-scheme.fish $argv[1])
+
+if test -d $CONFIG/hypr/scheme
+ log 'Generating hypr scheme'
+ gen-hypr $colours > $CONFIG/hypr/scheme/dynamic.conf
+end
+
+if test -d $CONFIG/shell/scss/scheme
+ log 'Generating shell scheme'
+ gen-scss $colours > $CONFIG/shell/scss/scheme/_dynamic.scss
+end
+
+if test -d $CONFIG/safeeyes/scheme
+ log 'Generating SafeEyes scheme'
+ gen-scss $colours > $CONFIG/safeeyes/scheme/_dynamic.scss
+end
+
+if test -d $CONFIG/../foot/schemes
+ log 'Generating foot scheme'
+ gen-foot $colours
+end
+
+# Reload programs if dynamic scheme
+if test -f $CACHE/scheme/current.txt -a "$(cat $CACHE/scheme/current.txt)" = 'dynamic'
+ caelestia scheme dynamic
+end
diff --git a/scheme/gen-scheme.fish b/scheme/gen-scheme.fish
new file mode 100755
index 0000000..d8e8158
--- /dev/null
+++ b/scheme/gen-scheme.fish
@@ -0,0 +1,26 @@
+#!/bin/fish
+
+function nl-echo
+ # Echo with newlines
+ for a in $argv
+ echo $a
+ end
+end
+
+. (dirname (status filename))/../util.fish
+
+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
+
+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 colours (string split ' ' $colours_raw[2])[2..]
+set -l layers (nl-echo $colours_raw | cut -f 1 -d ' ')[3..]
+
+for i in (seq 1 (count $colour_names))
+ echo "$colour_names[$i] $colours[$i]"
+end
+
+for i in (seq 1 (count $layer_names))
+ echo "$layer_names[$i] $layers[$i]"
+end
diff --git a/wallpaper.fish b/wallpaper.fish
index 0bde3f2..150bdd1 100755
--- a/wallpaper.fish
+++ b/wallpaper.fish
@@ -38,7 +38,7 @@ else
# Use wallpaper given as argument else choose random
if set -q _flag_f
- set chosen_wallpaper "$(cd $(dirname $_flag_f) && pwd)/$(basename $_flag_f)"
+ set chosen_wallpaper (realpath $_flag_f)
# Set last wallpaper if not same as given
if [ -f "$last_wallpaper_path" ]
@@ -96,6 +96,10 @@ else
# Unload unused wallpapers to preserve memory
hyprctl hyprpaper unload unused > /dev/null
+ # Generate colour scheme for wallpaper
+ set -l src (dirname (status filename))
+ $src/scheme/apply-scheme.fish $chosen_wallpaper
+
# Store the wallpaper chosen
mkdir -p $cache_dir
echo $chosen_wallpaper > $last_wallpaper_path