#!/usr/bin/env sh #// set variables export scrDir="$(dirname "$(realpath "$0")")" source "${scrDir}/globalcontrol.sh" wallbashImg="${1}" #// validate input if [ -z "${wallbashImg}" ] || [ ! -f "${wallbashImg}" ] ; then echo "Error: Input wallpaper not found!" exit 1 fi wallbashOut="${dcolDir}/$(set_hash "${wallbashImg}").dcol" if [ ! -f "${wallbashOut}" ] ; then "${scrDir}/swwwallcache.sh" -w "${wallbashImg}" &> /dev/null fi set -a source "${wallbashOut}" if [ -f "${hydeThemeDir}/theme.dcol" ] && [ "${enableWallDcol}" -eq 0 ] ; then source "${hydeThemeDir}/theme.dcol" echo "[theme] Overriding dominant colors from \"${hydeTheme}\"" echo "[note] Remove \"${hydeThemeDir}/theme.dcol\" to use wallpaper dominant colors" fi [ "${dcol_mode}" == "dark" ] && dcol_invt="light" || dcol_invt="dark" set +a #// deploy wallbash colors fn_wallbash () { local tplt="${1}" [ -f "${hydeConfDir}/hyde.conf" ] && source "${hydeConfDir}/hyde.conf" # Skips the the template declared in ./hyde.conf [[ " ${skip_wallbash[@]} " =~ " ${tplt} " ]] && echo "[skip: template] ${tplt}" && return 0 eval target="$(head -1 "${tplt}" | awk -F '|' '{print $1}')" [ ! -d "$(dirname "${target}")" ] && echo "[skip: no dir] \"${target}\"" && return 0 appexe="$(head -1 "${tplt}" | awk -F '|' '{print $2}')" sed '1d' "${tplt}" > "${target}" if [[ "${enableWallDcol}" -eq 2 && "${dcol_mode}" == "light" ]] || [[ "${enableWallDcol}" -eq 3 && "${dcol_mode}" == "dark" ]] ; then sed -i 's//'"${dcol_invt}"'/g s//'"${dcol_pry4}"'/g s//'"${dcol_txt4}"'/g s//'"${dcol_4xa9}"'/g s//'"${dcol_4xa8}"'/g s//'"${dcol_4xa7}"'/g s//'"${dcol_4xa6}"'/g s//'"${dcol_4xa5}"'/g s//'"${dcol_4xa4}"'/g s//'"${dcol_4xa3}"'/g s//'"${dcol_4xa2}"'/g s//'"${dcol_4xa1}"'/g s//'"${dcol_pry3}"'/g s//'"${dcol_txt3}"'/g s//'"${dcol_3xa9}"'/g s//'"${dcol_3xa8}"'/g s//'"${dcol_3xa7}"'/g s//'"${dcol_3xa6}"'/g s//'"${dcol_3xa5}"'/g s//'"${dcol_3xa4}"'/g s//'"${dcol_3xa3}"'/g s//'"${dcol_3xa2}"'/g s//'"${dcol_3xa1}"'/g s//'"${dcol_pry2}"'/g s//'"${dcol_txt2}"'/g s//'"${dcol_2xa9}"'/g s//'"${dcol_2xa8}"'/g s//'"${dcol_2xa7}"'/g s//'"${dcol_2xa6}"'/g s//'"${dcol_2xa5}"'/g s//'"${dcol_2xa4}"'/g s//'"${dcol_2xa3}"'/g s//'"${dcol_2xa2}"'/g s//'"${dcol_2xa1}"'/g s//'"${dcol_pry1}"'/g s//'"${dcol_txt1}"'/g s//'"${dcol_1xa9}"'/g s//'"${dcol_1xa8}"'/g s//'"${dcol_1xa7}"'/g s//'"${dcol_1xa6}"'/g s//'"${dcol_1xa5}"'/g s//'"${dcol_1xa4}"'/g s//'"${dcol_1xa3}"'/g s//'"${dcol_1xa2}"'/g s//'"${dcol_1xa1}"'/g s//'"${dcol_pry4_rgba}"'/g s//'"${dcol_txt4_rgba}"'/g s//'"${dcol_4xa9_rgba}"'/g s//'"${dcol_4xa8_rgba}"'/g s//'"${dcol_4xa7_rgba}"'/g s//'"${dcol_4xa6_rgba}"'/g s//'"${dcol_4xa5_rgba}"'/g s//'"${dcol_4xa4_rgba}"'/g s//'"${dcol_4xa3_rgba}"'/g s//'"${dcol_4xa2_rgba}"'/g s//'"${dcol_4xa1_rgba}"'/g s//'"${dcol_pry3_rgba}"'/g s//'"${dcol_txt3_rgba}"'/g s//'"${dcol_3xa9_rgba}"'/g s//'"${dcol_3xa8_rgba}"'/g s//'"${dcol_3xa7_rgba}"'/g s//'"${dcol_3xa6_rgba}"'/g s//'"${dcol_3xa5_rgba}"'/g s//'"${dcol_3xa4_rgba}"'/g s//'"${dcol_3xa3_rgba}"'/g s//'"${dcol_3xa2_rgba}"'/g s//'"${dcol_3xa1_rgba}"'/g s//'"${dcol_pry2_rgba}"'/g s//'"${dcol_txt2_rgba}"'/g s//'"${dcol_2xa9_rgba}"'/g s//'"${dcol_2xa8_rgba}"'/g s//'"${dcol_2xa7_rgba}"'/g s//'"${dcol_2xa6_rgba}"'/g s//'"${dcol_2xa5_rgba}"'/g s//'"${dcol_2xa4_rgba}"'/g s//'"${dcol_2xa3_rgba}"'/g s//'"${dcol_2xa2_rgba}"'/g s//'"${dcol_2xa1_rgba}"'/g s//'"${dcol_pry1_rgba}"'/g s//'"${dcol_txt1_rgba}"'/g s//'"${dcol_1xa9_rgba}"'/g s//'"${dcol_1xa8_rgba}"'/g s//'"${dcol_1xa7_rgba}"'/g s//'"${dcol_1xa6_rgba}"'/g s//'"${dcol_1xa5_rgba}"'/g s//'"${dcol_1xa4_rgba}"'/g s//'"${dcol_1xa3_rgba}"'/g s//'"${dcol_1xa2_rgba}"'/g s//'"${dcol_1xa1_rgba}"'/g' "${target}" else sed -i 's//'"${dcol_mode}"'/g s//'"${dcol_pry1}"'/g s//'"${dcol_txt1}"'/g s//'"${dcol_1xa1}"'/g s//'"${dcol_1xa2}"'/g s//'"${dcol_1xa3}"'/g s//'"${dcol_1xa4}"'/g s//'"${dcol_1xa5}"'/g s//'"${dcol_1xa6}"'/g s//'"${dcol_1xa7}"'/g s//'"${dcol_1xa8}"'/g s//'"${dcol_1xa9}"'/g s//'"${dcol_pry2}"'/g s//'"${dcol_txt2}"'/g s//'"${dcol_2xa1}"'/g s//'"${dcol_2xa2}"'/g s//'"${dcol_2xa3}"'/g s//'"${dcol_2xa4}"'/g s//'"${dcol_2xa5}"'/g s//'"${dcol_2xa6}"'/g s//'"${dcol_2xa7}"'/g s//'"${dcol_2xa8}"'/g s//'"${dcol_2xa9}"'/g s//'"${dcol_pry3}"'/g s//'"${dcol_txt3}"'/g s//'"${dcol_3xa1}"'/g s//'"${dcol_3xa2}"'/g s//'"${dcol_3xa3}"'/g s//'"${dcol_3xa4}"'/g s//'"${dcol_3xa5}"'/g s//'"${dcol_3xa6}"'/g s//'"${dcol_3xa7}"'/g s//'"${dcol_3xa8}"'/g s//'"${dcol_3xa9}"'/g s//'"${dcol_pry4}"'/g s//'"${dcol_txt4}"'/g s//'"${dcol_4xa1}"'/g s//'"${dcol_4xa2}"'/g s//'"${dcol_4xa3}"'/g s//'"${dcol_4xa4}"'/g s//'"${dcol_4xa5}"'/g s//'"${dcol_4xa6}"'/g s//'"${dcol_4xa7}"'/g s//'"${dcol_4xa8}"'/g s//'"${dcol_4xa9}"'/g s//'"${dcol_pry1_rgba}"'/g s//'"${dcol_txt1_rgba}"'/g s//'"${dcol_1xa1_rgba}"'/g s//'"${dcol_1xa2_rgba}"'/g s//'"${dcol_1xa3_rgba}"'/g s//'"${dcol_1xa4_rgba}"'/g s//'"${dcol_1xa5_rgba}"'/g s//'"${dcol_1xa6_rgba}"'/g s//'"${dcol_1xa7_rgba}"'/g s//'"${dcol_1xa8_rgba}"'/g s//'"${dcol_1xa9_rgba}"'/g s//'"${dcol_pry2_rgba}"'/g s//'"${dcol_txt2_rgba}"'/g s//'"${dcol_2xa1_rgba}"'/g s//'"${dcol_2xa2_rgba}"'/g s//'"${dcol_2xa3_rgba}"'/g s//'"${dcol_2xa4_rgba}"'/g s//'"${dcol_2xa5_rgba}"'/g s//'"${dcol_2xa6_rgba}"'/g s//'"${dcol_2xa7_rgba}"'/g s//'"${dcol_2xa8_rgba}"'/g s//'"${dcol_2xa9_rgba}"'/g s//'"${dcol_pry3_rgba}"'/g s//'"${dcol_txt3_rgba}"'/g s//'"${dcol_3xa1_rgba}"'/g s//'"${dcol_3xa2_rgba}"'/g s//'"${dcol_3xa3_rgba}"'/g s//'"${dcol_3xa4_rgba}"'/g s//'"${dcol_3xa5_rgba}"'/g s//'"${dcol_3xa6_rgba}"'/g s//'"${dcol_3xa7_rgba}"'/g s//'"${dcol_3xa8_rgba}"'/g s//'"${dcol_3xa9_rgba}"'/g s//'"${dcol_pry4_rgba}"'/g s//'"${dcol_txt4_rgba}"'/g s//'"${dcol_4xa1_rgba}"'/g s//'"${dcol_4xa2_rgba}"'/g s//'"${dcol_4xa3_rgba}"'/g s//'"${dcol_4xa4_rgba}"'/g s//'"${dcol_4xa5_rgba}"'/g s//'"${dcol_4xa6_rgba}"'/g s//'"${dcol_4xa7_rgba}"'/g s//'"${dcol_4xa8_rgba}"'/g s//'"${dcol_4xa9_rgba}"'/g' "${target}" fi [ -z "${appexe}" ] || bash -c "${appexe}" } export -f fn_wallbash [ -n "$HYPRLAND_INSTANCE_SIGNATURE" ] && hyprctl keyword misc:disable_autoreload 1 -q && trap 'hyprctl reload -q && echo "[swwwallbash] reload :: Hyprland"' EXIT #// switch theme wall based colors if [ "${enableWallDcol}" -eq 0 ] && [[ "${reload_flag}" -eq 1 ]] ; then echo ":: deploying ${hydeTheme} colors :: ${dcol_mode} wallpaper detected" mapfile -d '' -t deployList < <(find "${hydeThemeDir}" -type f -name "*.theme" -print0) while read -r pKey ; do fKey="$(find "${hydeThemeDir}" -type f -name "$(basename "${pKey%.dcol}.theme")")" [ -z "${fKey}" ] && deployList+=("${pKey}") done < <(find "${wallbashDir}/Wall-Dcol" -type f -name "*.dcol") parallel fn_wallbash ::: "${deployList[@]}" elif [ "${enableWallDcol}" -gt 0 ] ; then echo ":: deploying wallbash colors :: ${dcol_mode} wallpaper detected" find "${wallbashDir}/Wall-Dcol" -type f -name "*.dcol" | parallel fn_wallbash {} fi # Theme mode: detects the color-scheme set in hypr.theme and falls back if nothing is parsed. if [ "${enableWallDcol}" -eq 0 ]; then colorScheme="$({ grep -q "^[[:space:]]*\$COLOR-SCHEME\s*=" "${hydeThemeDir}/hypr.theme" && grep "^[[:space:]]*\$COLOR-SCHEME\s*=" "${hydeThemeDir}/hypr.theme" | cut -d '=' -f2 | sed 's/^[[:space:]]*//;s/[[:space:]]*$//' ;} || grep 'gsettings set org.gnome.desktop.interface color-scheme' "${hydeThemeDir}/hypr.theme" | awk -F "'" '{print $((NF - 1))}')" colorScheme=${colorScheme:-$(gsettings get org.gnome.desktop.interface color-scheme)} # should be declared explicitly so we can easily debug grep -q "dark" <<< "${colorScheme}" && enableWallDcol=2 grep -q "light" <<< "${colorScheme}" && enableWallDcol=3 fi find "${wallbashDir}/Wall-Ways" -type f -name "*.dcol" | parallel fn_wallbash {}