now tacke a screenshot and extract the color from there.
This commit is contained in:
parent
74151c2a6e
commit
75d77160e0
12
wms_mimic.sh
12
wms_mimic.sh
|
@ -1,18 +1,21 @@
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
|
||||||
TARGET=$1 # image target
|
TMPIMG="/tmp/mimic.png" # temp image target
|
||||||
TMPCOL="/tmp/tmpcol" # path to the extracted colors file
|
TMPCOL="/tmp/tmpcol" # temp extracted colors file
|
||||||
WMSVAR="$HOME/.config/wms/wms_var" # window manager variables
|
WMSVAR="$HOME/.config/wms/wms_var" # window manager variables
|
||||||
XVAR="$HOME/.Xresources" # default x variable file
|
XVAR="$HOME/.Xresources" # default x variable file
|
||||||
NC="3" # number of colors to extract
|
NC="3" # number of colors to extract
|
||||||
|
|
||||||
|
# spy on what's on the desktop
|
||||||
|
import -w root $TMPIMG
|
||||||
|
|
||||||
# color extractor
|
# color extractor
|
||||||
colext() {
|
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 the image file exists, extract the colors and store them temporarily
|
||||||
if [ -f "$TARGET" ]; then
|
if [ -f "$TMPIMG" ]; then
|
||||||
colext > $TMPCOL
|
colext > $TMPCOL
|
||||||
|
|
||||||
# check if N colors have been extracted
|
# check if N colors have been extracted
|
||||||
|
@ -28,7 +31,6 @@ if [ -f "$TARGET" ]; then
|
||||||
# overwrite the xterm, emacs and nsxiv values in ~/.Xresources
|
# overwrite the xterm, emacs and nsxiv values in ~/.Xresources
|
||||||
sed -i "s/\(XTerm\*background:\).*/\XTerm\*background: \#$bc/" $XVAR
|
sed -i "s/\(XTerm\*background:\).*/\XTerm\*background: \#$bc/" $XVAR
|
||||||
sed -i "s/\(Nsxiv\*window.background:\).*/\Nsxiv\*window.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
|
# apply the change
|
||||||
wms_value.sh -d
|
wms_value.sh -d
|
||||||
|
|
Loading…
Reference in a new issue