39 lines
1.5 KiB
Bash
39 lines
1.5 KiB
Bash
|
#!/bin/sh
|
||
|
|
||
|
TARGET=$1 # image target
|
||
|
COLORS="/tmp/mimic" # path to the extracted colors file
|
||
|
WMVAR="$HOME/.config/wms/wms_var" # window manager variables
|
||
|
DAC="a0a0a0" # default active color
|
||
|
DIC="404040" # default inactive color
|
||
|
DBC="#000000" # default background color
|
||
|
|
||
|
if [ -f "$TARGET" ]; then # if cw.png exist, extract colors
|
||
|
convert $TARGET -colors 3 -depth 6 -format '%c' histogram:info:- | awk '{print $3}' | cut -c 2-7 > $COLORS
|
||
|
|
||
|
if [ "$(wc -w < $COLORS)" = "3" ]; then # if two colors turned out
|
||
|
mainc=$(sed '3 p;d' < $COLORS) # main color
|
||
|
secondc=$(sed '2 p;d' < $COLORS) # second color
|
||
|
thirdc=$(sed '1 p;d' < $COLORS) # third color
|
||
|
|
||
|
# change variables in ~/.wmvar
|
||
|
sed -i "s/^.*\bAC=\b.*$/AC=$mainc/" $WMVAR # new acive color
|
||
|
sed -i "s/^.*\bIC=\b.*$/IC=$secondc/" $WMVAR # new inactive color
|
||
|
sed -i "s/^.*\bBC=\b.*$/BC=$thirdc/" $WMVAR # new background color
|
||
|
|
||
|
else # if no two colors turned out
|
||
|
sed -i "s/^.*\bAC=\b.*$/AC=$DAC/" $WMVAR # default acive color
|
||
|
sed -i "s/^.*\bIC=\b.*$/IC=$DIC/" $WMVAR # default inactive color
|
||
|
sed -i "s/^.*\bBC=\b.*$/BC=$DBC/" $WMVAR # default background color
|
||
|
|
||
|
|
||
|
fi
|
||
|
|
||
|
cp .config/wms/wms_var /tmp/wms_var; # copy wms_var file into /tmp
|
||
|
wms_mainrole.sh -t # make it happen
|
||
|
|
||
|
else # if image target not exist
|
||
|
exit 0 # leave without change
|
||
|
|
||
|
fi
|
||
|
|