commit dbb05b5889e5ae9bef368f486da8de607df035fe
parent e58f5c5c047572d164b63873ef18debf61ec82f8
Author: Matthew Carlson <matt@mattcarlson.org>
Date: Sat, 22 Mar 2025 22:38:48 -0400
make wp grayscale too
Diffstat:
2 files changed, 45 insertions(+), 2 deletions(-)
diff --git a/.local/bin/color.sh b/.local/bin/color.sh
@@ -10,6 +10,12 @@ COMPOSITOR='picom'
# we can make windows mono via shader
SHADER="${XDG_DATA_HOME:-${HOME}/.local/share/}/picom/gray.glsl"
+# wp symlink location
+WP="${XDG_DATA_HOME:-${HOME}/.local/share/}/wp"
+
+# gray wp dir
+GRAY_DIR="${XDG_CACHE_HOME:-${HOME}/.cache/}/dots/gray/"
+
start() {
# get mode stored in cache
# 0 means mono
@@ -33,6 +39,9 @@ toggle() {
$(kill ${shader_id} && \
sleep 1 && \
${COMPOSITOR} -b --backend glx) || return 1
+ rm -rf "${GRAY_DIR}"
+ mv "${WP}.bak" "${WP}"
+ feh --no-fehbg --bg-scale "${WP}"
mode=1
# shader disabled, meaning color
# DISABLE COLOR
@@ -41,6 +50,17 @@ toggle() {
$(kill ${comp_id} && \
sleep 1 && \
${COMPOSITOR} -b --backend glx --window-shader-fg="${SHADER}" 2>/dev/null) || return 1
+ # follow symlink to get actual wp location
+ wp="$(symlink.sh "${WP}")"
+ # get extension of wp
+ ext="${wp##*.}"
+ # new filename for gray wallpaper
+ gray="${GRAY_DIR}/$(basename "${wp%.*}-gray.${ext}")"
+ mkdir "${GRAY_DIR}"
+ magick "${wp}" -colorspace Gray "${gray}" >/dev/null 2>&1
+ cp -a "${WP}" "${WP}.bak"
+ ln -sf "${gray}" "${WP}"
+ feh --no-fehbg --bg-scale "${WP}"
mode=0
fi
diff --git a/.local/bin/wp.sh b/.local/bin/wp.sh
@@ -11,6 +11,10 @@ COLORS="${XDG_CACHE_HOME:-${HOME}/.cache/}/wal/colors.sh"
DEFAULTFG=259
# xresources handles suckless vars
XRESOURCES="${XDG_CONFIG_HOME:-${HOME}/.config/}/x/xresources"
+# file holding system color state
+COLOR="${XDG_CACHE_HOME:-${HOME}/.cache/}/dots/color"
+# gray wp dir
+GRAY_DIR="${XDG_CACHE_HOME:-${HOME}/.cache/}/dots/gray/"
# get random valid file in dir
get_rand_file() {
@@ -71,8 +75,27 @@ check_file () {
}
wp () {
- # create wp sym link
- ln -sf "${file}" "${WP}"
+ # get system color state (0 = grayscale, 1 = rgb)
+ mode="$(cat "${COLOR}")"
+
+ # rgb
+ if [ "${mode}" -eq 1 ]; then
+ # create wp sym link as normal
+ ln -sf "${file}" "${WP}"
+ else
+ # gen grayscale wp
+ ext="${file##*.}"
+ gray="${GRAY_DIR}/$(basename "${file%.*}-gray.${ext}")"
+ if [ -e "${GRAY_DIR}" ]; then
+ rm -rf "${GRAY_DIR}"
+ mkdir "${GRAY_DIR}"
+ fi
+ magick "${file}" -colorspace Gray "${gray}" >/dev/null 2>&1
+
+ # use grayscale wp as normal symlink and color wp as bak
+ ln -sf "${gray}" "${WP}"
+ ln -sf "${file}" "${WP}.bak"
+ fi
# change bg
feh --no-fehbg --bg-scale "${WP}"