now tacke a screenshot and extract the color from there.

This commit is contained in:
#root_informatica 2024-01-14 23:28:27 -03:00
parent 74151c2a6e
commit 75d77160e0

View file

@ -1,18 +1,21 @@
#!/bin/sh
TARGET=$1 # image target
TMPCOL="/tmp/tmpcol" # path to the extracted colors file
TMPIMG="/tmp/mimic.png" # temp image target
TMPCOL="/tmp/tmpcol" # temp extracted colors file
WMSVAR="$HOME/.config/wms/wms_var" # window manager variables
XVAR="$HOME/.Xresources" # default x variable file
NC="3" # number of colors to extract
# spy on what's on the desktop
import -w root $TMPIMG
# color extractor
colext() {
convert $TARGET -colors $NC -depth 6 -format '%c' -alpha off histogram:info:- | awk -v RS="" '{print $11,$7,$3}' | tr -d '#'
convert $TMPIMG -colors $NC -depth 6 -format '%c' -alpha off histogram:info:- | awk -v RS="" '{print $11,$7,$3}' | tr -d '#'
}
# if the image file exists, extract the colors and store them temporarily
if [ -f "$TARGET" ]; then
if [ -f "$TMPIMG" ]; then
colext > $TMPCOL
# check if N colors have been extracted
@ -28,7 +31,6 @@ if [ -f "$TARGET" ]; then
# overwrite the xterm, emacs and nsxiv values in ~/.Xresources
sed -i "s/\(XTerm\*background:\).*/\XTerm\*background: \#$bc/" $XVAR
sed -i "s/\(Nsxiv\*window.background:\).*/\Nsxiv\*window.background: \#$bc/" $XVAR
sed -i "s/\(Emacs\*background:\).*/\Emacs\*background: \#$bc/" $XVAR
# apply the change
wms_value.sh -d