A fork of the Materia GTK theme.

Important information: Google announced that, from September 2026, Android devices will require ALL apps to be signed by Google, effectively leading to an iOS situation. Value your right to a computer that does what you want; do not tolerate this monopolistic practice! Contact me if you don't understand why it is bad. Click to learn more.

 mix.sh

View raw Download
text/x-shellscript • 874 B
Bourne-Again shell script, ASCII text executable
        
            
1
#!/usr/bin/env bash
2
set -ueo pipefail
3
#set -x
4
5
mix_channel() {
6
value1="$(printf '%03d' "0x$1")"
7
value2="$(printf '%03d' "0x$2")"
8
ratio="$3"
9
result=$(bc <<< "scale=0; ($value1 * 100 * $ratio + $value2 * 100 * (1 - $ratio))/100")
10
if [[ "$result" -lt 0 ]] ; then
11
result=0
12
elif [[ "$result" -gt 255 ]] ; then
13
result=255
14
fi
15
echo "$result"
16
}
17
18
19
mix() {
20
hexinput1=$(tr '[:lower:]' '[:upper:]' <<< "$1")
21
hexinput2=$(tr '[:lower:]' '[:upper:]' <<< "$2")
22
ratio="${3-0.5}"
23
24
a="$(cut -c-2 <<< "$hexinput1")"
25
b="$(cut -c3-4 <<< "$hexinput1")"
26
c="$(cut -c5-6 <<< "$hexinput1")"
27
d="$(cut -c-2 <<< "$hexinput2")"
28
e="$(cut -c3-4 <<< "$hexinput2")"
29
f="$(cut -c5-6 <<< "$hexinput2")"
30
31
r="$(mix_channel "$a" "$d" "$ratio")"
32
g="$(mix_channel "$b" "$e" "$ratio")"
33
b="$(mix_channel "$c" "$f" "$ratio")"
34
35
printf '%02x%02x%02x\n' "$r" "$g" "$b"
36
}
37
38
mix "$@"
39