La til en parser for å gjøre det enklere å scanne farger med Linshang LS171
authorEinar Jørgen Haraldseid <einar@haraldseid.net>
Tue, 3 Dec 2024 20:15:45 +0000 (21:15 +0100)
committerEinar Jørgen Haraldseid <einar@haraldseid.net>
Tue, 3 Dec 2024 20:15:45 +0000 (21:15 +0100)
colorscan.sh [new file with mode: 0755]

diff --git a/colorscan.sh b/colorscan.sh
new file mode 100755 (executable)
index 0000000..bcb9689
--- /dev/null
@@ -0,0 +1,25 @@
+#!/bin/bash
+n=1
+while read scan; do
+  if [ "${n}" != 1 ]; then
+    echo ""
+  fi
+  echo "Scan ${n}:"
+  lab=$(echo "${scan}" | jq -cr '.scan.lab | join(", ")')
+  lch=$(echo "${scan}" | jq -cr '.scan.lch | join(", ")')
+  rgb=$(echo "${scan}" | jq -cr '.scan.rgb | join(", ")')
+  r=$(echo "${rgb}" | cut -f 1 -d "," | tr -d " ")
+  g=$(echo "${rgb}" | cut -f 2 -d "," | tr -d " ")
+  b=$(echo "${rgb}" | cut -f 3 -d "," | tr -d " ")
+  rH=$(printf "%x\n" ${r})
+  gH=$(printf "%x\n" ${g})
+  bH=$(printf "%x\n" ${b})
+  for i in {1..10}; do
+    echo -e "\033[48;2;${r};${g};${b}m                        \e[0m"
+  done
+  echo "L*a*b:  ${lab}"
+  echo "L*C*h:  ${lch}"
+  echo "RGB:    ${rgb}"
+  echo "HEX:    #${rH}${gH}${bH}"
+  ((n++))
+done < <(bluecolor --format json)