forked from Shinonome/caelestia-cli
scheme: optionally specify colour theme
Allow specifying colour theme (light/dark) for dynamic scheme when changing wallpaper
This commit is contained in:
+20
-6
@@ -7,21 +7,35 @@ function nl-echo
|
||||
end
|
||||
end
|
||||
|
||||
function light-theme
|
||||
set -g light_vals 40,10,16,22,34,46,59,69,78,85,97,94,90
|
||||
set -g colour_scheme light
|
||||
end
|
||||
|
||||
function dark-theme
|
||||
set -g light_vals 70,90,75,63,52,42,32,26,20,16,12,9,6
|
||||
set -g colour_scheme dark
|
||||
end
|
||||
|
||||
set -l src (dirname (status filename))
|
||||
|
||||
. $src/../util.fish
|
||||
|
||||
if test "$argv[1]" = --theme
|
||||
set theme $argv[2]
|
||||
set -e argv[1]
|
||||
set -e argv[2]
|
||||
end
|
||||
|
||||
test -f "$argv[1]" && set -l img "$argv[1]" || set -l img $C_STATE/wallpaper/current
|
||||
set -l img (realpath $img)
|
||||
|
||||
if set -q theme
|
||||
test "$theme" = light && light-theme || dark-theme
|
||||
else
|
||||
# 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,10,16,22,34,46,59,69,78,85,97,94,90
|
||||
set colour_scheme light
|
||||
else
|
||||
set light_vals 70,90,75,63,52,42,32,26,20,16,12,9,6
|
||||
set colour_scheme dark
|
||||
test "$bg_fg[1]" -gt "$bg_fg[2]" && light-theme || dark-theme
|
||||
end
|
||||
|
||||
echo -n $colour_scheme > $C_STATE/scheme/dynamic-mode.txt
|
||||
|
||||
+7
-4
@@ -15,6 +15,7 @@ argparse -n 'caelestia-wallpaper' -X 0 -x 'h,f,d' -x 'F,t' \
|
||||
'd/directory=' \
|
||||
'F/no-filter' \
|
||||
't/threshold=!_validate_int --min 0' \
|
||||
'T/theme=!test $_flag_value = light -o $_flag_value = dark' \
|
||||
-- $argv
|
||||
or exit
|
||||
|
||||
@@ -24,9 +25,9 @@ if set -q _flag_h
|
||||
echo 'Usage:'
|
||||
echo ' caelestia wallpaper'
|
||||
echo ' caelestia wallpaper [ -h | --help ]'
|
||||
echo ' caelestia wallpaper [ -f | --file ]'
|
||||
echo ' caelestia wallpaper [ -d | --directory ] [ -F | --no-filter ]'
|
||||
echo ' caelestia wallpaper [ -d | --directory ] [ -t | --threshold ]'
|
||||
echo ' caelestia wallpaper [ -f | --file ] [ -T | --theme ]'
|
||||
echo ' caelestia wallpaper [ -d | --directory ] [ -F | --no-filter ] [ -T | --theme ]'
|
||||
echo ' caelestia wallpaper [ -d | --directory ] [ -t | --threshold ] [ -T | --theme ]'
|
||||
echo
|
||||
echo 'Options:'
|
||||
echo ' -h, --help Print this help message and exit'
|
||||
@@ -34,6 +35,7 @@ if set -q _flag_h
|
||||
echo ' -d, --directory <directory> The folder to select a random wallpaper from (default '$wallpapers_dir')'
|
||||
echo ' -F, --no-filter Do not filter by size'
|
||||
echo ' -t, --threshold <threshold> The minimum percentage of the size the image must be greater than to be selected (default '$threshold')'
|
||||
echo ' -T, --theme <"light" | "dark"> Set light/dark theme for dynamic scheme'
|
||||
else
|
||||
set state_dir $C_STATE/wallpaper
|
||||
|
||||
@@ -112,7 +114,8 @@ else
|
||||
|
||||
# Generate colour scheme for wallpaper
|
||||
set -l src (dirname (status filename))
|
||||
$src/scheme/gen-scheme.fish $chosen_wallpaper > $src/data/schemes/dynamic.txt
|
||||
set -q _flag_T && set -l theme --theme $_flag_T
|
||||
$src/scheme/gen-scheme.fish $theme $chosen_wallpaper > $src/data/schemes/dynamic.txt
|
||||
if test -f $C_STATE/scheme/current.txt -a "$(cat $C_STATE/scheme/current-name.txt)" = 'dynamic'
|
||||
caelestia scheme dynamic
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user