diff options
| -rw-r--r-- | completions/caelestia.fish | 20 | ||||
| -rwxr-xr-x | main.fish | 6 | ||||
| -rwxr-xr-x | record.fish | 2 | ||||
| -rwxr-xr-x | scheme/gen-print-scheme.fish | 36 |
4 files changed, 53 insertions, 11 deletions
diff --git a/completions/caelestia.fish b/completions/caelestia.fish index 90f3314..1a6a065 100644 --- a/completions/caelestia.fish +++ b/completions/caelestia.fish @@ -45,34 +45,36 @@ complete -c caelestia -n $not_seen -a 'stop' -d 'Stop media' # Toggles set -l commands communication music specialws sysmon todo -complete -c caelestia -n "$seen toggle && not $seen $commands" -a "$commands" +complete -c caelestia -n "$seen toggle && not $seen $commands" -a "$commands" -d 'toggle' # Workspace action set -l commands workspace workspacegroup movetoworkspace movetoworkspacegroup -complete -c caelestia -n "$seen workspace-action && not $seen $commands" -a "$commands" +complete -c caelestia -n "$seen workspace-action && not $seen $commands" -a "$commands" -d 'action' # Scheme set -q XDG_DATA_HOME && set -l data_dir $XDG_DATA_HOME || set -l data_dir $HOME/.local/share set -l scheme_dir $data_dir/caelestia/scripts/data/schemes -set -l commands (basename -a (find $scheme_dir/ -mindepth 1 -maxdepth 1 -type d)) -complete -c caelestia -n "$seen scheme && not $seen $commands" -a "$commands" -for scheme in $commands +set -l schemes (basename -a (find $scheme_dir/ -mindepth 1 -maxdepth 1 -type d)) +set -l commands 'print' $schemes +complete -c caelestia -n "$seen scheme && not $seen $commands" -a 'print' -d 'Generate and print a colour scheme for an image' +complete -c caelestia -n "$seen scheme && not $seen $commands" -a "$schemes" -d 'scheme' +for scheme in $schemes set -l flavours (basename -a (find $scheme_dir/$scheme/ -mindepth 1 -maxdepth 1 -type d) 2> /dev/null) set -l modes (basename -s .txt (find $scheme_dir/$scheme/ -mindepth 1 -maxdepth 1 -type f) 2> /dev/null) if test -n "$modes" - complete -c caelestia -n "$seen scheme && $seen $scheme && not $seen $modes" -a "$modes" + complete -c caelestia -n "$seen scheme && $seen $scheme && not $seen $modes" -a "$modes" -d 'mode' else - complete -c caelestia -n "$seen scheme && $seen $scheme && not $seen $flavours" -a "$flavours" + complete -c caelestia -n "$seen scheme && $seen $scheme && not $seen $flavours" -a "$flavours" -d 'flavour' for flavour in $flavours set -l modes (basename -s .txt (find $scheme_dir/$scheme/$flavour/ -mindepth 1 -maxdepth 1 -type f)) - complete -c caelestia -n "$seen scheme && $seen $scheme && $seen $flavour && not $seen $modes" -a "$modes" + complete -c caelestia -n "$seen scheme && $seen $scheme && $seen $flavour && not $seen $modes" -a "$modes" -d 'mode' 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" +complete -c caelestia -n "$seen variant && not $seen $commands" -a "$commands" -d 'variant' # Record set -l not_seen "$seen record && not $has_opt -s h help" @@ -40,7 +40,11 @@ if test "$argv[1]" = workspace-action end if test "$argv[1]" = scheme - $src/scheme/main.fish $argv[2..] + if test "$argv[2]" = print + $src/scheme/gen-print-scheme.fish $argv[3..] + else + $src/scheme/main.fish $argv[2..] + end exit end diff --git a/record.fish b/record.fish index e3860e3..244cece 100755 --- a/record.fish +++ b/record.fish @@ -91,7 +91,7 @@ else # No hardware accel set -q _flag_n && set -l hwaccel --no-hw - wl-screenrec $region $audio $hwaccel -f $recording_path & disown + wl-screenrec $region $audio $hwaccel --codec hevc -f $recording_path & disown notify-send 'Recording started' 'Recording...' -i 'video-x-generic' -a 'caelestia-record' -p > $notif_id_path end diff --git a/scheme/gen-print-scheme.fish b/scheme/gen-print-scheme.fish new file mode 100755 index 0000000..75328e1 --- /dev/null +++ b/scheme/gen-print-scheme.fish @@ -0,0 +1,36 @@ +#!/bin/fish + +set -l src (dirname (status filename)) + +. $src/../util.fish + +test -f "$argv[1]" && set -l img (realpath "$argv[1]") || set -l img $C_STATE/wallpaper/thumbnail.jpg + +# Thumbnail image if not already thumbnail +if test $img != $C_STATE/wallpaper/thumbnail.jpg + set -l thumb_path $C_CACHE/thumbnails/(sha1sum $img | cut -d ' ' -f 1).jpg + if ! test -f $thumb_path + magick -define jpeg:size=256x256 $img -thumbnail 128x128\> $thumb_path + end + set img $thumb_path +end + +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) + +# Cache scheme +if ! test -d $C_CACHE/schemes/$hash/$variant + set -l colours ($src/score.py $img) + $src/autoadjust.py dark $variant $colours $C_CACHE/schemes/$hash + $src/autoadjust.py light $variant $colours $C_CACHE/schemes/$hash +end + +# Get mode from image +set -l lightness (magick $img -format '%[fx:int(mean*100)]' info:) +test $lightness -ge 60 && set -l mode light || set -l mode dark + +# Print scheme +cat $C_CACHE/schemes/$hash/$variant/default/$mode.txt |