publish: the public projection begins here
This is a projection, not a development branch. The tree above was constructed from the internal source named below under a manifest that decides which paths may leave, then scanned as a whole tree rather than as a series of patches, and only then published. Public history starts here because the history before it was not admissible, and neither was the tree. What used to stand in this repository included a rescue copy of another machine, a directory of phone handoffs, deployment wired to one house, and a submodule pointing at a forge no stranger can reach. None of that was ever the product. It stays in the private forge, which is allowed to hold the whole working organism, and this is what was deliberately sent out instead. Three mechanisms produced this tree, in decreasing order of trust. A top-level path the manifest does not name never arrives at all, which is the one that catches directories nobody has thought of yet. Named internal files inside admitted roots are dropped. A short, reviewed table replaces deployment defaults that a public build must not carry -- an endpoint aimed at one LAN, a VPN profile belonging to one phone, packaging built from one checkout path. Everything after this commit is an ordinary publication with the same three trailers, so a force push stops being routine and starts meaning that something deliberate happened. The trailers bind the projection to its source without pretending the public SHA is the private one: same lineage, different tree, and the record says so. Source-Sha: 8f27b1e76a8fef560a336aba18e6990713ff1047 Policy-Sha: 6b261d2f3e6e1fb19874846ba4bb1dfe15565d25b8618c1c1afba0419c101d27 Tree-Digest: 18ec3563c5e5ef9a414993a9f6734b251ff9ed3cd56eebdd6cac01e45c6e3067
This commit is contained in:
commit
8f42fc953d
1476 changed files with 238455 additions and 0 deletions
65
surfaces/quickshell/ii-phone/scripts/ai/gemini-categorize-wallpaper.sh
Executable file
65
surfaces/quickshell/ii-phone/scripts/ai/gemini-categorize-wallpaper.sh
Executable file
|
|
@ -0,0 +1,65 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
if [[ -z "$1" ]]; then
|
||||
echo "Usage: $0 <image_path> [model] [prompt]"
|
||||
echo "Tip: set GEMINI_WALLPAPER_MODEL and/or GEMINI_WALLPAPER_PROMPT to provide defaults."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Variables
|
||||
SOURCE_IMG_PATH="$1"
|
||||
MODEL="${2:-${GEMINI_WALLPAPER_MODEL:-gemini-3.6-flash}}" # Souveraine overlay: gemini-2.5-flash 404s for new free-tier keys (2026-08)
|
||||
WALLPAPER_NAME="$(basename "$SOURCE_IMG_PATH")"
|
||||
PROMPT="${3:-${GEMINI_WALLPAPER_PROMPT:-Categorize the wallpaper. Its file name is $WALLPAPER_NAME}}"
|
||||
RESIZED_IMG_PATH="/tmp/quickshell/ai/wallpaper.jpg"
|
||||
|
||||
# Resize image for speed
|
||||
mkdir -p "$(dirname "$RESIZED_IMG_PATH")"
|
||||
magick "$SOURCE_IMG_PATH" -resize 200x -quality 50 "$RESIZED_IMG_PATH"
|
||||
|
||||
# Get API key
|
||||
API_KEY=$(secret-tool lookup 'application' 'illogical-impulse' | jq -r '.apiKeys.gemini')
|
||||
|
||||
# Encode image to base64
|
||||
if [[ "$(base64 --version 2>&1)" = *"FreeBSD"* ]]; then
|
||||
B64FLAGS="--input"
|
||||
else
|
||||
B64FLAGS="-w0"
|
||||
fi
|
||||
B64DATA="$(base64 $B64FLAGS $RESIZED_IMG_PATH)"
|
||||
# echo $B64DATA
|
||||
|
||||
# Prepare request data
|
||||
payload='{
|
||||
"contents": [{
|
||||
"parts":[
|
||||
{
|
||||
"inline_data": {
|
||||
"mime_type":"image/jpeg",
|
||||
"data": "'"$B64DATA"'"
|
||||
}
|
||||
},
|
||||
{"text": "'"$PROMPT"'"}
|
||||
]
|
||||
}],
|
||||
"generationConfig": {
|
||||
"responseMimeType": "text/x.enum",
|
||||
"responseSchema": {
|
||||
"type": "string",
|
||||
"enum": [ "abstract", "anime", "city", "minimalist", "landscape", "plants", "person", "space" ]
|
||||
},
|
||||
"temperature": 0
|
||||
}
|
||||
}'
|
||||
# echo "$payload" | jq
|
||||
|
||||
# Make the request
|
||||
response=$(curl "https://generativelanguage.googleapis.com/v1beta/models/${MODEL}:generateContent" \
|
||||
-H "x-goog-api-key: $API_KEY" \
|
||||
-H 'Content-Type: application/json' \
|
||||
-X POST \
|
||||
-d "$payload" 2> /dev/null)
|
||||
# echo "$response" | jq
|
||||
|
||||
# Write the result
|
||||
echo "$response" | jq -r '.candidates[0].content.parts[0].text'
|
||||
477
surfaces/quickshell/ii-phone/scripts/colors/switchwall.sh
Executable file
477
surfaces/quickshell/ii-phone/scripts/colors/switchwall.sh
Executable file
|
|
@ -0,0 +1,477 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
QUICKSHELL_CONFIG_NAME="ii"
|
||||
XDG_CONFIG_HOME="${XDG_CONFIG_HOME:-$HOME/.config}"
|
||||
XDG_CACHE_HOME="${XDG_CACHE_HOME:-$HOME/.cache}"
|
||||
XDG_STATE_HOME="${XDG_STATE_HOME:-$HOME/.local/state}"
|
||||
CONFIG_DIR="$XDG_CONFIG_HOME/quickshell/$QUICKSHELL_CONFIG_NAME"
|
||||
CACHE_DIR="$XDG_CACHE_HOME/quickshell"
|
||||
STATE_DIR="$XDG_STATE_HOME/quickshell"
|
||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
SHELL_CONFIG_FILE="$XDG_CONFIG_HOME/illogical-impulse/config.json"
|
||||
MATUGEN_DIR="$XDG_CONFIG_HOME/matugen"
|
||||
terminalscheme="$SCRIPT_DIR/terminal/scheme-base.json"
|
||||
|
||||
handle_kde_material_you_colors() {
|
||||
# Check if Qt app theming is enabled in config
|
||||
if [ -f "$SHELL_CONFIG_FILE" ]; then
|
||||
enable_qt_apps=$(jq -r '.appearance.wallpaperTheming.enableQtApps' "$SHELL_CONFIG_FILE")
|
||||
if [ "$enable_qt_apps" == "false" ]; then
|
||||
return
|
||||
fi
|
||||
fi
|
||||
|
||||
# Map $type_flag to allowed scheme variants for kde-material-you-colors-wrapper.sh
|
||||
local kde_scheme_variant=""
|
||||
case "$type_flag" in
|
||||
scheme-content|scheme-expressive|scheme-fidelity|scheme-fruit-salad|scheme-monochrome|scheme-neutral|scheme-rainbow|scheme-tonal-spot)
|
||||
kde_scheme_variant="$type_flag"
|
||||
;;
|
||||
*)
|
||||
kde_scheme_variant="scheme-tonal-spot" # default
|
||||
;;
|
||||
esac
|
||||
"$XDG_CONFIG_HOME"/matugen/templates/kde/kde-material-you-colors-wrapper.sh --scheme-variant "$kde_scheme_variant"
|
||||
}
|
||||
|
||||
pre_process() {
|
||||
local mode_flag="$1"
|
||||
# Set GNOME color-scheme if mode_flag is dark or light
|
||||
if [[ "$mode_flag" == "dark" ]]; then
|
||||
gsettings set org.gnome.desktop.interface color-scheme 'prefer-dark'
|
||||
gsettings set org.gnome.desktop.interface gtk-theme 'adw-gtk3-dark'
|
||||
elif [[ "$mode_flag" == "light" ]]; then
|
||||
gsettings set org.gnome.desktop.interface color-scheme 'prefer-light'
|
||||
gsettings set org.gnome.desktop.interface gtk-theme 'adw-gtk3'
|
||||
fi
|
||||
|
||||
if [ ! -d "$CACHE_DIR"/user/generated ]; then
|
||||
mkdir -p "$CACHE_DIR"/user/generated
|
||||
fi
|
||||
}
|
||||
|
||||
post_process() {
|
||||
local screen_width="$1"
|
||||
local screen_height="$2"
|
||||
local wallpaper_path="$3"
|
||||
|
||||
handle_kde_material_you_colors &
|
||||
"$SCRIPT_DIR/code/material-code-set-color.sh" &
|
||||
}
|
||||
|
||||
check_and_prompt_upscale() {
|
||||
local img="$1"
|
||||
min_width_desired="$(hyprctl monitors -j | jq '([.[].width] | max)' | xargs)" # max monitor width
|
||||
min_height_desired="$(hyprctl monitors -j | jq '([.[].height] | max)' | xargs)" # max monitor height
|
||||
|
||||
# blueline: upscayl not installed and the blocking notify-send -A stalls
|
||||
# the whole wallpaper switch on phone — skip the prompt entirely.
|
||||
return 0
|
||||
if command -v identify &>/dev/null && [ -f "$img" ]; then
|
||||
local img_width img_height
|
||||
if is_video "$img"; then # Not check resolution for videos, just let em pass
|
||||
img_width=$min_width_desired
|
||||
img_height=$min_height_desired
|
||||
else
|
||||
img_width=$(identify -format "%w" "$img" 2>/dev/null)
|
||||
img_height=$(identify -format "%h" "$img" 2>/dev/null)
|
||||
fi
|
||||
if [[ "$img_width" -lt "$min_width_desired" || "$img_height" -lt "$min_height_desired" ]]; then
|
||||
action=$(notify-send "Upscale?" \
|
||||
"Image resolution (${img_width}x${img_height}) is lower than screen resolution (${min_width_desired}x${min_height_desired})" \
|
||||
-A "open_upscayl=Open Upscayl"\
|
||||
-a "Wallpaper switcher")
|
||||
if [[ "$action" == "open_upscayl" ]]; then
|
||||
if command -v upscayl &>/dev/null; then
|
||||
nohup upscayl > /dev/null 2>&1 &
|
||||
else
|
||||
action2=$(notify-send \
|
||||
-a "Wallpaper switcher" \
|
||||
-c "im.error" \
|
||||
-A "install_upscayl=Install Upscayl (Arch)" \
|
||||
"Install Upscayl?" \
|
||||
"yay -S upscayl-bin")
|
||||
if [[ "$action2" == "install_upscayl" ]]; then
|
||||
kitty -1 yay -S upscayl-bin
|
||||
if command -v upscayl &>/dev/null; then
|
||||
nohup upscayl > /dev/null 2>&1 &
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
CUSTOM_DIR="$XDG_CONFIG_HOME/hypr/custom"
|
||||
RESTORE_SCRIPT_DIR="$CUSTOM_DIR/scripts"
|
||||
RESTORE_SCRIPT="$RESTORE_SCRIPT_DIR/__restore_video_wallpaper.sh"
|
||||
THUMBNAIL_DIR="$RESTORE_SCRIPT_DIR/mpvpaper_thumbnails"
|
||||
VIDEO_OPTS="no-audio loop hwdec=auto scale=bilinear interpolation=no video-sync=display-resample panscan=1.0 video-scale-x=1.0 video-scale-y=1.0 video-align-x=0.5 video-align-y=0.5 load-scripts=no"
|
||||
|
||||
is_video() {
|
||||
local extension="${1##*.}"
|
||||
[[ "$extension" == "mp4" || "$extension" == "webm" || "$extension" == "mkv" || "$extension" == "avi" || "$extension" == "mov" ]] && return 0 || return 1
|
||||
}
|
||||
|
||||
kill_existing_mpvpaper() {
|
||||
pkill -f -9 mpvpaper || true
|
||||
}
|
||||
|
||||
create_restore_script() {
|
||||
local video_path=$1
|
||||
cat > "$RESTORE_SCRIPT.tmp" << EOF
|
||||
#!/bin/bash
|
||||
# Generated by switchwall.sh - Don't modify it by yourself.
|
||||
# Time: $(date)
|
||||
|
||||
pkill -f -9 mpvpaper
|
||||
|
||||
for monitor in \$(hyprctl monitors -j | jq -r '.[] | .name'); do
|
||||
mpvpaper -o "$VIDEO_OPTS" "\$monitor" "$video_path" &
|
||||
sleep 0.1
|
||||
done
|
||||
EOF
|
||||
mv "$RESTORE_SCRIPT.tmp" "$RESTORE_SCRIPT"
|
||||
chmod +x "$RESTORE_SCRIPT"
|
||||
}
|
||||
|
||||
remove_restore() {
|
||||
cat > "$RESTORE_SCRIPT.tmp" << EOF
|
||||
#!/bin/bash
|
||||
# The content of this script will be generated by switchwall.sh - Don't modify it by yourself.
|
||||
EOF
|
||||
mv "$RESTORE_SCRIPT.tmp" "$RESTORE_SCRIPT"
|
||||
}
|
||||
|
||||
set_wallpaper_path() {
|
||||
local path="$1"
|
||||
if [ -f "$SHELL_CONFIG_FILE" ]; then
|
||||
jq --arg path "$path" '.background.wallpaperPath = $path' "$SHELL_CONFIG_FILE" > "$SHELL_CONFIG_FILE.tmp" && mv "$SHELL_CONFIG_FILE.tmp" "$SHELL_CONFIG_FILE"
|
||||
fi
|
||||
}
|
||||
|
||||
set_thumbnail_path() {
|
||||
local path="$1"
|
||||
if [ -f "$SHELL_CONFIG_FILE" ]; then
|
||||
jq --arg path "$path" '.background.thumbnailPath = $path' "$SHELL_CONFIG_FILE" > "$SHELL_CONFIG_FILE.tmp" && mv "$SHELL_CONFIG_FILE.tmp" "$SHELL_CONFIG_FILE"
|
||||
fi
|
||||
}
|
||||
|
||||
categorize_wallpaper() {
|
||||
img_cat=$("$SCRIPT_DIR/../ai/gemini-categorize-wallpaper.sh" "$1")
|
||||
# notify-send "Wallpaper category" "$img_cat"
|
||||
echo "$img_cat" > "$STATE_DIR/user/generated/wallpaper/category.txt"
|
||||
}
|
||||
|
||||
switch() {
|
||||
imgpath="$1"
|
||||
mode_flag="$2"
|
||||
type_flag="$3"
|
||||
color_flag="$4"
|
||||
color="$5"
|
||||
|
||||
# Start Gemini auto-categorization if enabled
|
||||
aiStylingEnabled=$(jq -r '.background.widgets.clock.cookie.aiStyling' "$SHELL_CONFIG_FILE")
|
||||
if [[ "$aiStylingEnabled" == "true" ]]; then
|
||||
categorize_wallpaper "$imgpath" &
|
||||
fi
|
||||
|
||||
read scale screenx screeny screensizey < <(hyprctl monitors -j | jq '.[] | select(.focused) | .scale, .x, .y, .height' | xargs)
|
||||
cursorposx=$(hyprctl cursorpos -j | jq '.x' 2>/dev/null) || cursorposx=960
|
||||
cursorposx=$(bc <<< "scale=0; ($cursorposx - $screenx) * $scale / 1")
|
||||
cursorposy=$(hyprctl cursorpos -j | jq '.y' 2>/dev/null) || cursorposy=540
|
||||
cursorposy=$(bc <<< "scale=0; ($cursorposy - $screeny) * $scale / 1")
|
||||
cursorposy_inverted=$((screensizey - cursorposy))
|
||||
|
||||
matugen_args=(--source-color-index 0)
|
||||
|
||||
if [[ "$color_flag" == "1" ]]; then
|
||||
matugen_args+=(color hex "$color")
|
||||
generate_colors_material_args=(--color "$color")
|
||||
else
|
||||
if [[ -z "$imgpath" ]]; then
|
||||
echo 'Aborted'
|
||||
exit 0
|
||||
fi
|
||||
|
||||
check_and_prompt_upscale "$imgpath" &
|
||||
kill_existing_mpvpaper
|
||||
|
||||
if is_video "$imgpath"; then
|
||||
mkdir -p "$THUMBNAIL_DIR"
|
||||
|
||||
missing_deps=()
|
||||
if ! command -v mpvpaper &> /dev/null; then
|
||||
missing_deps+=("mpvpaper")
|
||||
fi
|
||||
if ! command -v ffmpeg &> /dev/null; then
|
||||
missing_deps+=("ffmpeg")
|
||||
fi
|
||||
if [ ${#missing_deps[@]} -gt 0 ]; then
|
||||
echo "Missing deps: ${missing_deps[*]}"
|
||||
echo "Arch: sudo pacman -S ${missing_deps[*]}"
|
||||
action=$(notify-send \
|
||||
-a "Wallpaper switcher" \
|
||||
-c "im.error" \
|
||||
-A "install_arch=Install (Arch)" \
|
||||
"Can't switch to video wallpaper" \
|
||||
"Missing dependencies: ${missing_deps[*]}")
|
||||
if [[ "$action" == "install_arch" ]]; then
|
||||
kitty -1 sudo pacman -S "${missing_deps[*]}"
|
||||
if command -v mpvpaper &>/dev/null && command -v ffmpeg &>/dev/null; then
|
||||
notify-send 'Wallpaper switcher' 'Alright, try again!' -a "Wallpaper switcher"
|
||||
fi
|
||||
fi
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# Set wallpaper path
|
||||
set_wallpaper_path "$imgpath"
|
||||
|
||||
# Set video wallpaper
|
||||
local video_path="$imgpath"
|
||||
monitors=$(hyprctl monitors -j | jq -r '.[] | .name')
|
||||
for monitor in $monitors; do
|
||||
mpvpaper -o "$VIDEO_OPTS" "$monitor" "$video_path" &
|
||||
sleep 0.1
|
||||
done
|
||||
|
||||
# Extract first frame for color generation
|
||||
thumbnail="$THUMBNAIL_DIR/$(basename "$imgpath").jpg"
|
||||
ffmpeg -y -i "$imgpath" -vframes 1 "$thumbnail" 2>/dev/null
|
||||
|
||||
# Set thumbnail path
|
||||
set_thumbnail_path "$thumbnail"
|
||||
|
||||
if [ -f "$thumbnail" ]; then
|
||||
matugen_args+=(image "$thumbnail")
|
||||
generate_colors_material_args=(--path "$thumbnail")
|
||||
create_restore_script "$video_path"
|
||||
else
|
||||
echo "Cannot create image to colorgen"
|
||||
remove_restore
|
||||
exit 1
|
||||
fi
|
||||
else
|
||||
matugen_args+=(image "$imgpath")
|
||||
generate_colors_material_args=(--path "$imgpath")
|
||||
# Update wallpaper path in config
|
||||
set_wallpaper_path "$imgpath"
|
||||
remove_restore
|
||||
fi
|
||||
fi
|
||||
|
||||
# Determine mode if not set
|
||||
if [[ -z "$mode_flag" ]]; then
|
||||
current_mode=$(gsettings get org.gnome.desktop.interface color-scheme 2>/dev/null | tr -d "'")
|
||||
if [[ "$current_mode" == "prefer-dark" ]]; then
|
||||
mode_flag="dark"
|
||||
else
|
||||
mode_flag="light"
|
||||
fi
|
||||
fi
|
||||
|
||||
# enforce dark mode for terminal
|
||||
if [[ -n "$mode_flag" ]]; then
|
||||
matugen_args+=(--mode "$mode_flag")
|
||||
if [[ $(jq -r '.appearance.wallpaperTheming.terminalGenerationProps.forceDarkMode' "$SHELL_CONFIG_FILE") == "true" ]]; then
|
||||
generate_colors_material_args+=(--mode "dark")
|
||||
else
|
||||
generate_colors_material_args+=(--mode "$mode_flag")
|
||||
fi
|
||||
fi
|
||||
[[ -n "$type_flag" ]] && matugen_args+=(--type "$type_flag") && generate_colors_material_args+=(--scheme "$type_flag")
|
||||
generate_colors_material_args+=(--termscheme "$terminalscheme" --blend_bg_fg)
|
||||
generate_colors_material_args+=(--cache "$STATE_DIR/user/generated/color.txt")
|
||||
|
||||
pre_process "$mode_flag"
|
||||
|
||||
# Check if app and shell theming is enabled in config
|
||||
if [ -f "$SHELL_CONFIG_FILE" ]; then
|
||||
enable_apps_shell=$(jq -r '.appearance.wallpaperTheming.enableAppsAndShell' "$SHELL_CONFIG_FILE")
|
||||
if [ "$enable_apps_shell" == "false" ]; then
|
||||
echo "App and shell theming disabled, skipping matugen and color generation"
|
||||
return
|
||||
fi
|
||||
fi
|
||||
|
||||
# Set harmony and related properties
|
||||
if [ -f "$SHELL_CONFIG_FILE" ]; then
|
||||
harmony=$(jq -r '.appearance.wallpaperTheming.terminalGenerationProps.harmony' "$SHELL_CONFIG_FILE")
|
||||
harmonize_threshold=$(jq -r '.appearance.wallpaperTheming.terminalGenerationProps.harmonizeThreshold' "$SHELL_CONFIG_FILE")
|
||||
term_fg_boost=$(jq -r '.appearance.wallpaperTheming.terminalGenerationProps.termFgBoost' "$SHELL_CONFIG_FILE")
|
||||
[[ "$harmony" != "null" && -n "$harmony" ]] && generate_colors_material_args+=(--harmony "$harmony")
|
||||
[[ "$harmonize_threshold" != "null" && -n "$harmonize_threshold" ]] && generate_colors_material_args+=(--harmonize_threshold "$harmonize_threshold")
|
||||
[[ "$term_fg_boost" != "null" && -n "$term_fg_boost" ]] && generate_colors_material_args+=(--term_fg_boost "$term_fg_boost")
|
||||
fi
|
||||
|
||||
matugen "${matugen_args[@]}"
|
||||
source "$HOME/.local/state/quickshell/.venv/bin/activate"
|
||||
python3 "$SCRIPT_DIR/generate_colors_material.py" "${generate_colors_material_args[@]}" \
|
||||
> "$STATE_DIR"/user/generated/material_colors.scss
|
||||
deactivate
|
||||
"$SCRIPT_DIR"/applycolor.sh
|
||||
|
||||
# Pass screen width, height, and wallpaper path to post_process
|
||||
max_width_desired="$(hyprctl monitors -j | jq '([.[].width] | min)' | xargs)"
|
||||
max_height_desired="$(hyprctl monitors -j | jq '([.[].height] | min)' | xargs)"
|
||||
post_process "$max_width_desired" "$max_height_desired" "$imgpath"
|
||||
}
|
||||
|
||||
main() {
|
||||
imgpath=""
|
||||
mode_flag=""
|
||||
type_flag=""
|
||||
color_flag=""
|
||||
color=""
|
||||
noswitch_flag=""
|
||||
|
||||
get_type_from_config() {
|
||||
jq -r '.appearance.palette.type' "$SHELL_CONFIG_FILE" 2>/dev/null || echo "auto"
|
||||
}
|
||||
get_accent_color_from_config() {
|
||||
jq -r '.appearance.palette.accentColor' "$SHELL_CONFIG_FILE" 2>/dev/null || echo ""
|
||||
}
|
||||
set_accent_color() {
|
||||
local color="$1"
|
||||
jq --arg color "$color" '.appearance.palette.accentColor = $color' "$SHELL_CONFIG_FILE" > "$SHELL_CONFIG_FILE.tmp" && mv "$SHELL_CONFIG_FILE.tmp" "$SHELL_CONFIG_FILE"
|
||||
}
|
||||
|
||||
detect_scheme_type_from_image() {
|
||||
local img="$1"
|
||||
source "$HOME/.local/state/quickshell/.venv/bin/activate"
|
||||
"$SCRIPT_DIR"/scheme_for_image.py "$img" 2>/dev/null | tr -d '\n'
|
||||
deactivate
|
||||
}
|
||||
|
||||
while [[ $# -gt 0 ]]; do
|
||||
case "$1" in
|
||||
--mode)
|
||||
mode_flag="$2"
|
||||
shift 2
|
||||
;;
|
||||
--type)
|
||||
type_flag="$2"
|
||||
shift 2
|
||||
;;
|
||||
--color)
|
||||
if [[ "$2" =~ ^#?[A-Fa-f0-9]{6}$ ]]; then
|
||||
set_accent_color "$2"
|
||||
shift 2
|
||||
elif [[ "$2" == "clear" ]]; then
|
||||
set_accent_color ""
|
||||
shift 2
|
||||
else
|
||||
set_accent_color $(hyprpicker --no-fancy)
|
||||
shift
|
||||
fi
|
||||
;;
|
||||
--image)
|
||||
imgpath="$2"
|
||||
shift 2
|
||||
;;
|
||||
--noswitch)
|
||||
noswitch_flag="1"
|
||||
imgpath=$(jq -r '.background.wallpaperPath' "$SHELL_CONFIG_FILE" 2>/dev/null || echo "")
|
||||
shift
|
||||
;;
|
||||
*)
|
||||
if [[ -z "$imgpath" ]]; then
|
||||
imgpath="$1"
|
||||
fi
|
||||
shift
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
# If accentColor is set in config, use it
|
||||
config_color="$(get_accent_color_from_config)"
|
||||
if [[ "$config_color" =~ ^#?[A-Fa-f0-9]{6}$ ]]; then
|
||||
color_flag="1"
|
||||
color="$config_color"
|
||||
fi
|
||||
|
||||
# If type_flag is not set, get it from config
|
||||
if [[ -z "$type_flag" ]]; then
|
||||
type_flag="$(get_type_from_config)"
|
||||
fi
|
||||
|
||||
# Validate type_flag (allow 'auto' as well)
|
||||
allowed_types=(scheme-content scheme-expressive scheme-fidelity scheme-fruit-salad scheme-monochrome scheme-neutral scheme-rainbow scheme-tonal-spot auto)
|
||||
valid_type=0
|
||||
for t in "${allowed_types[@]}"; do
|
||||
if [[ "$type_flag" == "$t" ]]; then
|
||||
valid_type=1
|
||||
break
|
||||
fi
|
||||
done
|
||||
if [[ $valid_type -eq 0 ]]; then
|
||||
echo "[switchwall.sh] Warning: Invalid type '$type_flag', defaulting to 'auto'" >&2
|
||||
type_flag="auto"
|
||||
fi
|
||||
|
||||
# Only prompt for wallpaper if not using --color and not using --noswitch and no imgpath set
|
||||
if [[ -z "$imgpath" && -z "$color_flag" && -z "$noswitch_flag" ]]; then
|
||||
cd "$(xdg-user-dir PICTURES)/Wallpapers/showcase" 2>/dev/null || cd "$(xdg-user-dir PICTURES)/Wallpapers" 2>/dev/null || cd "$(xdg-user-dir PICTURES)" || return 1
|
||||
imgpath="$(kdialog --getopenfilename . --title 'Choose wallpaper')"
|
||||
fi
|
||||
|
||||
if [[ -n "$imgpath" && -z "$noswitch_flag" ]]; then
|
||||
set_accent_color ""
|
||||
color_flag=""
|
||||
color=""
|
||||
fi
|
||||
|
||||
# If type_flag is 'auto', detect scheme type from image (after imgpath is set)
|
||||
if [[ "$type_flag" == "auto" ]]; then
|
||||
if [[ -n "$imgpath" && -f "$imgpath" ]]; then
|
||||
detected_type="$(detect_scheme_type_from_image "$imgpath")"
|
||||
# Only use detected_type if it's valid
|
||||
valid_detected=0
|
||||
for t in "${allowed_types[@]}"; do
|
||||
if [[ "$detected_type" == "$t" && "$detected_type" != "auto" ]]; then
|
||||
valid_detected=1
|
||||
break
|
||||
fi
|
||||
done
|
||||
if [[ $valid_detected -eq 1 ]]; then
|
||||
type_flag="$detected_type"
|
||||
else
|
||||
echo "[switchwall] Warning: Could not auto-detect a valid scheme, defaulting to 'scheme-tonal-spot'" >&2
|
||||
type_flag="scheme-tonal-spot"
|
||||
fi
|
||||
else
|
||||
echo "[switchwall] Warning: No image to auto-detect scheme from, defaulting to 'scheme-tonal-spot'" >&2
|
||||
type_flag="scheme-tonal-spot"
|
||||
fi
|
||||
fi
|
||||
|
||||
# If mode_flag is dark or light, try to find a variant with that mode suffix
|
||||
if [[ "$mode_flag" == "dark" || "$mode_flag" == "light" ]]; then
|
||||
# Get directory, filename without extension, and extension
|
||||
local imgdir="$(dirname "$imgpath")"
|
||||
local imgbase="$(basename "$imgpath")"
|
||||
local imgname="${imgbase%.*}"
|
||||
local imgext="${imgbase##*.}"
|
||||
|
||||
# Strip existing -dark or -light suffix
|
||||
local stripped_name="${imgname%-dark}"
|
||||
stripped_name="${stripped_name%-light}"
|
||||
|
||||
# Construct the new path with the requested mode suffix
|
||||
local new_imgpath="${imgdir}/${stripped_name}-${mode_flag}.${imgext}"
|
||||
local new_stripped_imgpath="${imgdir}/${stripped_name}.${imgext}"
|
||||
|
||||
# If the variant exists, use it
|
||||
if [[ -f "$new_imgpath" ]]; then
|
||||
imgpath="$new_imgpath"
|
||||
elif [[ -f "$new_stripped_imgpath" ]]; then
|
||||
imgpath="$new_stripped_imgpath"
|
||||
fi
|
||||
fi
|
||||
|
||||
switch "$imgpath" "$mode_flag" "$type_flag" "$color_flag" "$color"
|
||||
}
|
||||
|
||||
main "$@"
|
||||
Loading…
Reference in a new issue