From fb8c1380e3e22e2d7295cffe43a87f69d8dd33f4 Mon Sep 17 00:00:00 2001 From: q3aql Date: Fri, 9 Jul 2021 12:56:32 +0200 Subject: [PATCH] Add custom color selection --- images/custom.png | Bin 0 -> 10414 bytes zenidrv-g203-lightsync | 208 ++++++++++++++++++++++++++++++++++++----- zenidrv-g203-prodigy | 208 ++++++++++++++++++++++++++++++++++++----- 3 files changed, 368 insertions(+), 48 deletions(-) create mode 100644 images/custom.png diff --git a/images/custom.png b/images/custom.png new file mode 100644 index 0000000000000000000000000000000000000000..a62d11e6f639bbfe99a8f2bf9a9368d31a405450 GIT binary patch literal 10414 zcmeHNc{tSVyB`rkvSn9eB&1#+t~!g^V%7V9b~qyRwue5nfVck1R>DWXTdy z%9=<>S+ZqINLlKPdY9hcdCxi5d#>~Q<6PHkX1?b8Joo*1?)&rH_x*jY`ZTGxAlJdxPV8JQn#9`^7!O^)RtL=AXdfJ$>+9vARjT;*RnGRtaR+qg zHte@2&CQ=*MLk#a%|Cl~Z7^VG&tVmyhYf)4lhqMgp6)&o!ch9 zDj6|Ju~VP%tWY`QRpQIBK7ZNgbnStV#lpd?=hr-&y1#AB*swl2^@{z?-Ldegfhhkt z#B7#A&OOsoYfhSYMaJiTEsnhsvIWkD$7L#fj7!`h7r6qe@1A&Mxbu4D?bp<%NA1{I z=$c?4hg#$zbbQW}-oJ7CjS)Sgw{$I68U5PN#lBh&A<}yO%{|liK8%rZl+mS?&D<;V z?A{YScSNff6CTxGLvQzNt>5BZec^D-YWeb)n)REVL7wCD=R-!rDPH@aSsNGO^NzO` zwyZb>j=&vv0=kw}kfKS%?W^;MRnno)li)*He*UVV!T%due>kQr7W^sVOGfh=Xpq0N;5S-l4Nv8JWv(b66jWTWaRcG-5rad5$| z)6}_9YCY}Q&_s&xgsTYp`&hsz1B2Q3E3})tK~iNz>NOf!yh(!Y{lsYGw5|AHOkkJeuBT(0831de{NvEX?qsB($Wpqit4^ zBCH@A$YS}C14ba=MppPkc`0?VWTE zi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ire|nqD95hIq{ymh zaNZ!R9kI8j093wNU1J+>%Q)P>s9W#967E%Pm`{nM3uEy+if=b~ebm0;JZ7XurpPOy}d3N!r+VX0Y49Ifk09F((6nvl!fD-e;TyI1aly}wTQ?yTQjQ8+(6 z`QmXan74RL(C97qBftH1vLiQ|_ILR&YXmiZn{<%dYW9oXGOyg(%R~P)$`yZKof`3H z)+2FocS3w5ho5vV(4=o&GjbV9r~oo<$OXx~!a~pJOgy-8H{@{8@+LcD{rs6&i;zKj P9RV2V7;BemIfefR-GoJ- literal 0 HcmV?d00001 diff --git a/zenidrv-g203-lightsync b/zenidrv-g203-lightsync index f012cc3..2e7afc6 100755 --- a/zenidrv-g203-lightsync +++ b/zenidrv-g203-lightsync @@ -44,7 +44,7 @@ while [ ${showMenu} -eq 0 ] ; do ${imagesPath}/mouse-dpi.png "Set DPI" ${imagesPath}/light-off.png "Light off" ${imagesPath}/exit.png "Exit") if [ "${opcion}" == "${imagesPath}/solid.png" ] ; then color_selected=$(zenity --list --width=260 --height=570 --title "zenidrv-g203-lightsync ${VERSION} ($M_DATE)" \ - --window-icon=${iconPath} --imagelist --column "Color" --column "Name color" ${imagesPath}/black.png Black \ + --window-icon=${iconPath} --imagelist --column "Color" --column "Name color" ${imagesPath}/custom.png Custom \ ${imagesPath}/white.png White ${imagesPath}/red.png Red ${imagesPath}/lime.png Lime ${imagesPath}/blue.png Blue \ ${imagesPath}/yellow.png Yellow ${imagesPath}/cyan.png Cyan ${imagesPath}/magenta.png Magenta \ ${imagesPath}/silver.png Silver ${imagesPath}/gray.png Gray ${imagesPath}/maroon.png Maroon \ @@ -52,8 +52,84 @@ while [ ${showMenu} -eq 0 ] ; do ${imagesPath}/navy.png Navy) canceled=$? if [ ${canceled} -eq 0 ] ; then - if [ "${color_selected}" == "${imagesPath}/black.png" ] ; then - color_apply="000000" + if [ "${color_selected}" == "${imagesPath}/custom.png" ] ; then + custom_color=$(zenity --color-selection) + # Crop numbers from rgb system + first_value=$(echo ${custom_color} | cut -d "(" -f 2 | cut -d "," -f 1) + second_value=$(echo ${custom_color} | cut -d "(" -f 2 | cut -d "," -f 2) + third_value_prev=$(echo ${custom_color} | cut -d "(" -f 2 | cut -d "," -f 3) + third_value=$(echo ${third_value_prev} | cut -d ")" -f 1) + # Convert rgb numbers to hex + first_hex=$(echo "obase=16; ${first_value}" | bc) + second_hex=$(echo "obase=16; ${second_value}" | bc) + third_hex=$(echo "obase=16; ${third_value}" | bc) + # Apply number 0 after if have only one number + if [ ${first_hex} == "0" ] ; then + first_hex="00" + elif [ ${first_hex} == "1" ] ; then + first_hex="01" + elif [ ${first_hex} == "2" ] ; then + first_hex="02" + elif [ ${first_hex} == "3" ] ; then + first_hex="03" + elif [ ${first_hex} == "4" ] ; then + first_hex="04" + elif [ ${first_hex} == "5" ] ; then + first_hex="05" + elif [ ${first_hex} == "6" ] ; then + first_hex="06" + elif [ ${first_hex} == "7" ] ; then + first_hex="07" + elif [ ${first_hex} == "8" ] ; then + first_hex="08" + elif [ ${first_hex} == "9" ] ; then + first_hex="09" + fi + if [ ${second_hex} == "0" ] ; then + second_hex="00" + elif [ ${second_hex} == "1" ] ; then + second_hex="01" + elif [ ${second_hex} == "2" ] ; then + second_hex="02" + elif [ ${second_hex} == "3" ] ; then + second_hex="03" + elif [ ${second_hex} == "4" ] ; then + second_hex="04" + elif [ ${second_hex} == "5" ] ; then + second_hex="05" + elif [ ${second_hex} == "6" ] ; then + second_hex="06" + elif [ ${second_hex} == "7" ] ; then + second_hex="07" + elif [ ${second_hex} == "8" ] ; then + second_hex="08" + elif [ ${second_hex} == "9" ] ; then + second_hex="09" + fi + if [ ${third_hex} == "0" ] ; then + third_hex="00" + elif [ ${third_hex} == "1" ] ; then + third_hex="01" + elif [ ${third_hex} == "2" ] ; then + third_hex="02" + elif [ ${third_hex} == "3" ] ; then + third_hex="03" + elif [ ${third_hex} == "4" ] ; then + third_hex="04" + elif [ ${third_hex} == "5" ] ; then + third_hex="05" + elif [ ${third_hex} == "6" ] ; then + third_hex="06" + elif [ ${third_hex} == "7" ] ; then + third_hex="07" + elif [ ${third_hex} == "8" ] ; then + third_hex="08" + elif [ ${third_hex} == "9" ] ; then + third_hex="09" + fi + # Custom color in hex + color_custom=$(echo ${first_hex}${second_hex}${third_hex}) + color_apply="${color_custom}" elif [ "${color_selected}" == "${imagesPath}/white.png" ] ; then color_apply="FFFFFF" elif [ "${color_selected}" == "${imagesPath}/red.png" ] ; then @@ -85,17 +161,21 @@ while [ ${showMenu} -eq 0 ] ; do elif [ "${color_selected}" == "${imagesPath}/navy.png" ] ; then color_apply="000080" fi - sleep 2 | zenity --progress --title "zenidrv-g203-lightsync ${VERSION} (${M_DATE})" --text "Applying Solid effect" \ - --window-icon=${iconPath} --pulsate --no-cancel --auto-close - g203-led.py lightsync solid "${color_apply}" - device_error=$? - if [ ${device_error} -eq 0 ] ; then - echo > /dev/null + if [ -z "${color_apply}" ] ; then + color_apply="none" else - zenity --title "zenidrv-g203-lightsync ${VERSION} ($M_DATE)" --error --window-icon=${iconPath} --width=280 \ - --text "Device not found or connected" + sleep 2 | zenity --progress --title "zenidrv-g203-lightsync ${VERSION} (${M_DATE})" --text "Applying Solid effect" \ + --window-icon=${iconPath} --pulsate --no-cancel --auto-close + g203-led.py lightsync solid "${color_apply}" + device_error=$? + if [ ${device_error} -eq 0 ] ; then + echo > /dev/null + else + zenity --title "zenidrv-g203-lightsync ${VERSION} ($M_DATE)" --error --window-icon=${iconPath} --width=280 \ + --text "Device not found or connected" + fi + color_apply="none" fi - color_apply="none" else color_apply="none" fi @@ -112,7 +192,7 @@ while [ ${showMenu} -eq 0 ] ; do fi elif [ "${opcion}" == "${imagesPath}/breathe.png" ] ; then color_selected=$(zenity --list --width=260 --height=565 --title "zenidrv-g203-lightsync ${VERSION} ($M_DATE)" \ - --window-icon=${iconPath} --imagelist --column "Color" --column "Name color" ${imagesPath}/black.png Black \ + --window-icon=${iconPath} --imagelist --column "Color" --column "Name color" ${imagesPath}/custom.png Custom \ ${imagesPath}/white.png White ${imagesPath}/red.png Red ${imagesPath}/lime.png Lime ${imagesPath}/blue.png Blue \ ${imagesPath}/yellow.png Yellow ${imagesPath}/cyan.png Cyan ${imagesPath}/magenta.png Magenta \ ${imagesPath}/silver.png Silver ${imagesPath}/gray.png Gray ${imagesPath}/maroon.png Maroon \ @@ -120,8 +200,84 @@ while [ ${showMenu} -eq 0 ] ; do ${imagesPath}/navy.png Navy) canceled=$? if [ ${canceled} -eq 0 ] ; then - if [ "${color_selected}" == "${imagesPath}/black.png" ] ; then - color_apply="000000" + if [ "${color_selected}" == "${imagesPath}/custom.png" ] ; then + custom_color=$(zenity --color-selection) + # Crop numbers from rgb system + first_value=$(echo ${custom_color} | cut -d "(" -f 2 | cut -d "," -f 1) + second_value=$(echo ${custom_color} | cut -d "(" -f 2 | cut -d "," -f 2) + third_value_prev=$(echo ${custom_color} | cut -d "(" -f 2 | cut -d "," -f 3) + third_value=$(echo ${third_value_prev} | cut -d ")" -f 1) + # Convert rgb numbers to hex + first_hex=$(echo "obase=16; ${first_value}" | bc) + second_hex=$(echo "obase=16; ${second_value}" | bc) + third_hex=$(echo "obase=16; ${third_value}" | bc) + # Apply number 0 after if have only one number + if [ ${first_hex} == "0" ] ; then + first_hex="00" + elif [ ${first_hex} == "1" ] ; then + first_hex="01" + elif [ ${first_hex} == "2" ] ; then + first_hex="02" + elif [ ${first_hex} == "3" ] ; then + first_hex="03" + elif [ ${first_hex} == "4" ] ; then + first_hex="04" + elif [ ${first_hex} == "5" ] ; then + first_hex="05" + elif [ ${first_hex} == "6" ] ; then + first_hex="06" + elif [ ${first_hex} == "7" ] ; then + first_hex="07" + elif [ ${first_hex} == "8" ] ; then + first_hex="08" + elif [ ${first_hex} == "9" ] ; then + first_hex="09" + fi + if [ ${second_hex} == "0" ] ; then + second_hex="00" + elif [ ${second_hex} == "1" ] ; then + second_hex="01" + elif [ ${second_hex} == "2" ] ; then + second_hex="02" + elif [ ${second_hex} == "3" ] ; then + second_hex="03" + elif [ ${second_hex} == "4" ] ; then + second_hex="04" + elif [ ${second_hex} == "5" ] ; then + second_hex="05" + elif [ ${second_hex} == "6" ] ; then + second_hex="06" + elif [ ${second_hex} == "7" ] ; then + second_hex="07" + elif [ ${second_hex} == "8" ] ; then + second_hex="08" + elif [ ${second_hex} == "9" ] ; then + second_hex="09" + fi + if [ ${third_hex} == "0" ] ; then + third_hex="00" + elif [ ${third_hex} == "1" ] ; then + third_hex="01" + elif [ ${third_hex} == "2" ] ; then + third_hex="02" + elif [ ${third_hex} == "3" ] ; then + third_hex="03" + elif [ ${third_hex} == "4" ] ; then + third_hex="04" + elif [ ${third_hex} == "5" ] ; then + third_hex="05" + elif [ ${third_hex} == "6" ] ; then + third_hex="06" + elif [ ${third_hex} == "7" ] ; then + third_hex="07" + elif [ ${third_hex} == "8" ] ; then + third_hex="08" + elif [ ${third_hex} == "9" ] ; then + third_hex="09" + fi + # Custom color in hex + color_custom=$(echo ${first_hex}${second_hex}${third_hex}) + color_apply="${color_custom}" elif [ "${color_selected}" == "${imagesPath}/white.png" ] ; then color_apply="FFFFFF" elif [ "${color_selected}" == "${imagesPath}/red.png" ] ; then @@ -153,17 +309,21 @@ while [ ${showMenu} -eq 0 ] ; do elif [ "${color_selected}" == "${imagesPath}/navy.png" ] ; then color_apply="000080" fi - sleep 2 | zenity --progress --title "zenidrv-g203-lightsync ${VERSION} (${M_DATE})" --text "Applying Breathe effect" \ - --window-icon=${iconPath} --pulsate --no-cancel --auto-close - g203-led.py lightsync breathe "${color_apply}" - device_error=$? - if [ ${device_error} -eq 0 ] ; then - echo > /dev/null + if [ -z "${color_apply}" ] ; then + color_apply="none" else - zenity --title "zenidrv-g203-lightsync ${VERSION} ($M_DATE)" --error --window-icon=${iconPath} --width=280 \ - --text "Device not found or connected" + sleep 2 | zenity --progress --title "zenidrv-g203-lightsync ${VERSION} (${M_DATE})" --text "Applying Breathe effect" \ + --window-icon=${iconPath} --pulsate --no-cancel --auto-close + g203-led.py lightsync breathe "${color_apply}" + device_error=$? + if [ ${device_error} -eq 0 ] ; then + echo > /dev/null + else + zenity --title "zenidrv-g203-lightsync ${VERSION} ($M_DATE)" --error --window-icon=${iconPath} --width=280 \ + --text "Device not found or connected" + fi + color_apply="none" fi - color_apply="none" else color_apply="none" fi diff --git a/zenidrv-g203-prodigy b/zenidrv-g203-prodigy index 07208a4..0e95ef4 100755 --- a/zenidrv-g203-prodigy +++ b/zenidrv-g203-prodigy @@ -44,7 +44,7 @@ while [ ${showMenu} -eq 0 ] ; do ${imagesPath}/light-off.png "Light off" ${imagesPath}/exit.png "Exit") if [ "${opcion}" == "${imagesPath}/solid.png" ] ; then color_selected=$(zenity --list --width=260 --height=570 --title "zenidrv-g203-prodigy ${VERSION} ($M_DATE)" \ - --window-icon=${iconPath} --imagelist --column "Color" --column "Name color" ${imagesPath}/black.png Black \ + --window-icon=${iconPath} --imagelist --column "Color" --column "Name color" ${imagesPath}/custom.png Custom \ ${imagesPath}/white.png White ${imagesPath}/red.png Red ${imagesPath}/lime.png Lime ${imagesPath}/blue.png Blue \ ${imagesPath}/yellow.png Yellow ${imagesPath}/cyan.png Cyan ${imagesPath}/magenta.png Magenta \ ${imagesPath}/silver.png Silver ${imagesPath}/gray.png Gray ${imagesPath}/maroon.png Maroon \ @@ -52,8 +52,84 @@ while [ ${showMenu} -eq 0 ] ; do ${imagesPath}/navy.png Navy) canceled=$? if [ ${canceled} -eq 0 ] ; then - if [ "${color_selected}" == "${imagesPath}/black.png" ] ; then - color_apply="000000" + if [ "${color_selected}" == "${imagesPath}/custom.png" ] ; then + custom_color=$(zenity --color-selection) + # Crop numbers from rgb system + first_value=$(echo ${custom_color} | cut -d "(" -f 2 | cut -d "," -f 1) + second_value=$(echo ${custom_color} | cut -d "(" -f 2 | cut -d "," -f 2) + third_value_prev=$(echo ${custom_color} | cut -d "(" -f 2 | cut -d "," -f 3) + third_value=$(echo ${third_value_prev} | cut -d ")" -f 1) + # Convert rgb numbers to hex + first_hex=$(echo "obase=16; ${first_value}" | bc) + second_hex=$(echo "obase=16; ${second_value}" | bc) + third_hex=$(echo "obase=16; ${third_value}" | bc) + # Apply number 0 after if have only one number + if [ ${first_hex} == "0" ] ; then + first_hex="00" + elif [ ${first_hex} == "1" ] ; then + first_hex="01" + elif [ ${first_hex} == "2" ] ; then + first_hex="02" + elif [ ${first_hex} == "3" ] ; then + first_hex="03" + elif [ ${first_hex} == "4" ] ; then + first_hex="04" + elif [ ${first_hex} == "5" ] ; then + first_hex="05" + elif [ ${first_hex} == "6" ] ; then + first_hex="06" + elif [ ${first_hex} == "7" ] ; then + first_hex="07" + elif [ ${first_hex} == "8" ] ; then + first_hex="08" + elif [ ${first_hex} == "9" ] ; then + first_hex="09" + fi + if [ ${second_hex} == "0" ] ; then + second_hex="00" + elif [ ${second_hex} == "1" ] ; then + second_hex="01" + elif [ ${second_hex} == "2" ] ; then + second_hex="02" + elif [ ${second_hex} == "3" ] ; then + second_hex="03" + elif [ ${second_hex} == "4" ] ; then + second_hex="04" + elif [ ${second_hex} == "5" ] ; then + second_hex="05" + elif [ ${second_hex} == "6" ] ; then + second_hex="06" + elif [ ${second_hex} == "7" ] ; then + second_hex="07" + elif [ ${second_hex} == "8" ] ; then + second_hex="08" + elif [ ${second_hex} == "9" ] ; then + second_hex="09" + fi + if [ ${third_hex} == "0" ] ; then + third_hex="00" + elif [ ${third_hex} == "1" ] ; then + third_hex="01" + elif [ ${third_hex} == "2" ] ; then + third_hex="02" + elif [ ${third_hex} == "3" ] ; then + third_hex="03" + elif [ ${third_hex} == "4" ] ; then + third_hex="04" + elif [ ${third_hex} == "5" ] ; then + third_hex="05" + elif [ ${third_hex} == "6" ] ; then + third_hex="06" + elif [ ${third_hex} == "7" ] ; then + third_hex="07" + elif [ ${third_hex} == "8" ] ; then + third_hex="08" + elif [ ${third_hex} == "9" ] ; then + third_hex="09" + fi + # Custom color in hex + color_custom=$(echo ${first_hex}${second_hex}${third_hex}) + color_apply="${color_custom}" elif [ "${color_selected}" == "${imagesPath}/white.png" ] ; then color_apply="FFFFFF" elif [ "${color_selected}" == "${imagesPath}/red.png" ] ; then @@ -85,17 +161,21 @@ while [ ${showMenu} -eq 0 ] ; do elif [ "${color_selected}" == "${imagesPath}/navy.png" ] ; then color_apply="000080" fi - sleep 2 | zenity --progress --title "zenidrv-g203-prodigy ${VERSION} (${M_DATE})" --text "Applying Solid effect" \ - --window-icon=${iconPath} --pulsate --no-cancel --auto-close - g203-led.py solid "${color_apply}" - device_error=$? - if [ ${device_error} -eq 0 ] ; then - echo > /dev/null + if [ -z "${color_apply}" ] ; then + color_apply="none" else - zenity --title "zenidrv-g203-prodigy ${VERSION} ($M_DATE)" --error --window-icon=${iconPath} --width=280 \ - --text "Device not found or connected" + sleep 2 | zenity --progress --title "zenidrv-g203-prodigy ${VERSION} (${M_DATE})" --text "Applying Solid effect" \ + --window-icon=${iconPath} --pulsate --no-cancel --auto-close + g203-led.py solid "${color_apply}" + device_error=$? + if [ ${device_error} -eq 0 ] ; then + echo > /dev/null + else + zenity --title "zenidrv-g203-prodigy ${VERSION} ($M_DATE)" --error --window-icon=${iconPath} --width=280 \ + --text "Device not found or connected" + fi + color_apply="none" fi - color_apply="none" else color_apply="none" fi @@ -112,7 +192,7 @@ while [ ${showMenu} -eq 0 ] ; do fi elif [ "${opcion}" == "${imagesPath}/breathe.png" ] ; then color_selected=$(zenity --list --width=260 --height=565 --title "zenidrv-g203-prodigy ${VERSION} ($M_DATE)" \ - --window-icon=${iconPath} --imagelist --column "Color" --column "Name color" ${imagesPath}/black.png Black \ + --window-icon=${iconPath} --imagelist --column "Color" --column "Name color" ${imagesPath}/custom.png Custom \ ${imagesPath}/white.png White ${imagesPath}/red.png Red ${imagesPath}/lime.png Lime ${imagesPath}/blue.png Blue \ ${imagesPath}/yellow.png Yellow ${imagesPath}/cyan.png Cyan ${imagesPath}/magenta.png Magenta \ ${imagesPath}/silver.png Silver ${imagesPath}/gray.png Gray ${imagesPath}/maroon.png Maroon \ @@ -120,8 +200,84 @@ while [ ${showMenu} -eq 0 ] ; do ${imagesPath}/navy.png Navy) canceled=$? if [ ${canceled} -eq 0 ] ; then - if [ "${color_selected}" == "${imagesPath}/black.png" ] ; then - color_apply="000000" + if [ "${color_selected}" == "${imagesPath}/custom.png" ] ; then + custom_color=$(zenity --color-selection) + # Crop numbers from rgb system + first_value=$(echo ${custom_color} | cut -d "(" -f 2 | cut -d "," -f 1) + second_value=$(echo ${custom_color} | cut -d "(" -f 2 | cut -d "," -f 2) + third_value_prev=$(echo ${custom_color} | cut -d "(" -f 2 | cut -d "," -f 3) + third_value=$(echo ${third_value_prev} | cut -d ")" -f 1) + # Convert rgb numbers to hex + first_hex=$(echo "obase=16; ${first_value}" | bc) + second_hex=$(echo "obase=16; ${second_value}" | bc) + third_hex=$(echo "obase=16; ${third_value}" | bc) + # Apply number 0 after if have only one number + if [ ${first_hex} == "0" ] ; then + first_hex="00" + elif [ ${first_hex} == "1" ] ; then + first_hex="01" + elif [ ${first_hex} == "2" ] ; then + first_hex="02" + elif [ ${first_hex} == "3" ] ; then + first_hex="03" + elif [ ${first_hex} == "4" ] ; then + first_hex="04" + elif [ ${first_hex} == "5" ] ; then + first_hex="05" + elif [ ${first_hex} == "6" ] ; then + first_hex="06" + elif [ ${first_hex} == "7" ] ; then + first_hex="07" + elif [ ${first_hex} == "8" ] ; then + first_hex="08" + elif [ ${first_hex} == "9" ] ; then + first_hex="09" + fi + if [ ${second_hex} == "0" ] ; then + second_hex="00" + elif [ ${second_hex} == "1" ] ; then + second_hex="01" + elif [ ${second_hex} == "2" ] ; then + second_hex="02" + elif [ ${second_hex} == "3" ] ; then + second_hex="03" + elif [ ${second_hex} == "4" ] ; then + second_hex="04" + elif [ ${second_hex} == "5" ] ; then + second_hex="05" + elif [ ${second_hex} == "6" ] ; then + second_hex="06" + elif [ ${second_hex} == "7" ] ; then + second_hex="07" + elif [ ${second_hex} == "8" ] ; then + second_hex="08" + elif [ ${second_hex} == "9" ] ; then + second_hex="09" + fi + if [ ${third_hex} == "0" ] ; then + third_hex="00" + elif [ ${third_hex} == "1" ] ; then + third_hex="01" + elif [ ${third_hex} == "2" ] ; then + third_hex="02" + elif [ ${third_hex} == "3" ] ; then + third_hex="03" + elif [ ${third_hex} == "4" ] ; then + third_hex="04" + elif [ ${third_hex} == "5" ] ; then + third_hex="05" + elif [ ${third_hex} == "6" ] ; then + third_hex="06" + elif [ ${third_hex} == "7" ] ; then + third_hex="07" + elif [ ${third_hex} == "8" ] ; then + third_hex="08" + elif [ ${third_hex} == "9" ] ; then + third_hex="09" + fi + # Custom color in hex + color_custom=$(echo ${first_hex}${second_hex}${third_hex}) + color_apply="${color_custom}" elif [ "${color_selected}" == "${imagesPath}/white.png" ] ; then color_apply="FFFFFF" elif [ "${color_selected}" == "${imagesPath}/red.png" ] ; then @@ -153,17 +309,21 @@ while [ ${showMenu} -eq 0 ] ; do elif [ "${color_selected}" == "${imagesPath}/navy.png" ] ; then color_apply="000080" fi - sleep 2 | zenity --progress --title "zenidrv-g203-prodigy ${VERSION} (${M_DATE})" --text "Applying Breathe effect" \ - --window-icon=${iconPath} --pulsate --no-cancel --auto-close - g203-led.py breathe "${color_apply}" - device_error=$? - if [ ${device_error} -eq 0 ] ; then - echo > /dev/null + if [ -z "${color_apply}" ] ; then + color_apply="none" else - zenity --title "zenidrv-g203-prodigy ${VERSION} ($M_DATE)" --error --window-icon=${iconPath} --width=280 \ - --text "Device not found or connected" + sleep 2 | zenity --progress --title "zenidrv-g203-prodigy ${VERSION} (${M_DATE})" --text "Applying Breathe effect" \ + --window-icon=${iconPath} --pulsate --no-cancel --auto-close + g203-led.py breathe "${color_apply}" + device_error=$? + if [ ${device_error} -eq 0 ] ; then + echo > /dev/null + else + zenity --title "zenidrv-g203-prodigy ${VERSION} ($M_DATE)" --error --window-icon=${iconPath} --width=280 \ + --text "Device not found or connected" + fi + color_apply="none" fi - color_apply="none" else color_apply="none" fi