From 75d77160e07ec6294725882cae494e42a22b0e88 Mon Sep 17 00:00:00 2001 From: root_sti Date: Sun, 14 Jan 2024 23:28:27 -0300 Subject: [PATCH] now tacke a screenshot and extract the color from there. --- wms_mimic.sh | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/wms_mimic.sh b/wms_mimic.sh index 4a8fc09..5367f93 100755 --- a/wms_mimic.sh +++ b/wms_mimic.sh @@ -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