Added error checking

This commit is contained in:
q3aql 2021-07-07 11:32:26 +02:00
parent a44c00b612
commit f771c3bbc3
2 changed files with 116 additions and 2 deletions

View File

@ -20,7 +20,8 @@ function rootMessage() {
if [ ${administrador} -eq 0 ] ; then if [ ${administrador} -eq 0 ] ; then
rm -rf /etc/root rm -rf /etc/root
else else
zenity --title "zenidrv-g203-lightsync ${VERSION} (${M_DATE})" --window-icon=${iconPath} --warning --width=340 --text "Administrator permissions are required" zenity --title "zenidrv-g203-lightsync ${VERSION} (${M_DATE})" --window-icon=${iconPath} --warning \
--width=340 --text "Administrator permissions are required"
echo "" echo ""
echo "* zenidrv-g203-lightsync ${VERSION} (${M_DATE}) (GPL v2.0)" echo "* zenidrv-g203-lightsync ${VERSION} (${M_DATE}) (GPL v2.0)"
echo "" echo ""
@ -79,11 +80,25 @@ while [ ${showMenu} -eq 0 ] ; do
sleep 2 | zenity --progress --title "zenidrv-g203-lightsync ${VERSION} (${M_DATE})" --text "Applying Solid effect" \ sleep 2 | zenity --progress --title "zenidrv-g203-lightsync ${VERSION} (${M_DATE})" --text "Applying Solid effect" \
--window-icon=${iconPath} --pulsate --no-cancel --auto-close --window-icon=${iconPath} --pulsate --no-cancel --auto-close
g203-led.py lightsync solid "${color_apply}" 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" color_apply="none"
elif [ "${opcion}" == "Cycle" ] ; then elif [ "${opcion}" == "Cycle" ] ; then
sleep 2 | zenity --progress --title "zenidrv-g203-lightsync ${VERSION} (${M_DATE})" --text "Applying Cycle effect" \ sleep 2 | zenity --progress --title "zenidrv-g203-lightsync ${VERSION} (${M_DATE})" --text "Applying Cycle effect" \
--window-icon=${iconPath} --pulsate --no-cancel --auto-close --window-icon=${iconPath} --pulsate --no-cancel --auto-close
g203-led.py lightsync cycle g203-led.py lightsync cycle
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
elif [ "${opcion}" == "Breathe" ] ; then elif [ "${opcion}" == "Breathe" ] ; then
color_selected=$(zenity --width=260 --height=520 --list --title "zenidrv-g203-lightsync ${VERSION} ($M_DATE)" \ color_selected=$(zenity --width=260 --height=520 --list --title "zenidrv-g203-lightsync ${VERSION} ($M_DATE)" \
--window-icon=${iconPath} --column "Select color from list :" "Black" "White" "Red" "Lime" "Blue" "Yellow" "Cyan" "Magenta" \ --window-icon=${iconPath} --column "Select color from list :" "Black" "White" "Red" "Lime" "Blue" "Yellow" "Cyan" "Magenta" \
@ -124,35 +139,85 @@ while [ ${showMenu} -eq 0 ] ; do
sleep 2 | zenity --progress --title "zenidrv-g203-lightsync ${VERSION} (${M_DATE})" --text "Applying Breathe effect" \ sleep 2 | zenity --progress --title "zenidrv-g203-lightsync ${VERSION} (${M_DATE})" --text "Applying Breathe effect" \
--window-icon=${iconPath} --pulsate --no-cancel --auto-close --window-icon=${iconPath} --pulsate --no-cancel --auto-close
g203-led.py lightsync breathe "${color_apply}" 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" color_apply="none"
elif [ "${opcion}" == "Wave" ] ; then elif [ "${opcion}" == "Wave" ] ; then
sleep 2 | zenity --progress --title "zenidrv-g203-lightsync ${VERSION} (${M_DATE})" --text "Applying Wave effect" \ sleep 2 | zenity --progress --title "zenidrv-g203-lightsync ${VERSION} (${M_DATE})" --text "Applying Wave effect" \
--window-icon=${iconPath} --pulsate --no-cancel --auto-close --window-icon=${iconPath} --pulsate --no-cancel --auto-close
g203-led.py lightsync wave g203-led.py lightsync wave
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
elif [ "${opcion}" == "Blend" ] ; then elif [ "${opcion}" == "Blend" ] ; then
sleep 2 | zenity --progress --title "zenidrv-g203-lightsync ${VERSION} (${M_DATE})" --text "Applying Blend effect" \ sleep 2 | zenity --progress --title "zenidrv-g203-lightsync ${VERSION} (${M_DATE})" --text "Applying Blend effect" \
--window-icon=${iconPath} --pulsate --no-cancel --auto-close --window-icon=${iconPath} --pulsate --no-cancel --auto-close
g203-led.py lightsync blend g203-led.py lightsync blend
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
elif [ "${opcion}" == "Intro (On)" ] ; then elif [ "${opcion}" == "Intro (On)" ] ; then
sleep 2 | zenity --progress --title "zenidrv-g203-lightsync ${VERSION} (${M_DATE})" --text "Enabling startup effect" \ sleep 2 | zenity --progress --title "zenidrv-g203-lightsync ${VERSION} (${M_DATE})" --text "Enabling startup effect" \
--window-icon=${iconPath} --pulsate --no-cancel --auto-close --window-icon=${iconPath} --pulsate --no-cancel --auto-close
g203-led.py lightsync intro on g203-led.py lightsync intro on
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
elif [ "${opcion}" == "Intro (Off)" ] ; then elif [ "${opcion}" == "Intro (Off)" ] ; then
sleep 2 | zenity --progress --title "zenidrv-g203-lightsync ${VERSION} (${M_DATE})" --text "Disabling startup effect" \ sleep 2 | zenity --progress --title "zenidrv-g203-lightsync ${VERSION} (${M_DATE})" --text "Disabling startup effect" \
--window-icon=${iconPath} --pulsate --no-cancel --auto-close --window-icon=${iconPath} --pulsate --no-cancel --auto-close
g203-led.py lightsync intro off g203-led.py lightsync intro off
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
elif [ "${opcion}" == "Set DPI" ] ; then elif [ "${opcion}" == "Set DPI" ] ; then
dpi_number=$(zenity --entry --title "Set DPI (from 50 to 8000)" --window-icon=${iconPath} --text "Enter DPI number (from 50 to 8000):" --entry-text "800") dpi_number=$(zenity --entry --title "Set DPI (from 50 to 8000)" --window-icon=${iconPath} --text "Enter DPI number (from 50 to 8000):" --entry-text "800")
sleep 2 | zenity --progress --title "zenidrv-g203-lightsync ${VERSION} (${M_DATE})" --text "Setting DPI to ${dpi_number}" \ sleep 2 | zenity --progress --title "zenidrv-g203-lightsync ${VERSION} (${M_DATE})" --text "Setting DPI to ${dpi_number}" \
--window-icon=${iconPath} --pulsate --no-cancel --auto-close --window-icon=${iconPath} --pulsate --no-cancel --auto-close
g203-led.py lightsync dpi ${dpi_number} g203-led.py lightsync dpi ${dpi_number}
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
elif [ "${opcion}" == "Light off" ] ; then elif [ "${opcion}" == "Light off" ] ; then
sleep 2 | zenity --progress --title "zenidrv-g203-lightsync ${VERSION} (${M_DATE})" --text "Turning off the light on the mouse" \ sleep 2 | zenity --progress --title "zenidrv-g203-lightsync ${VERSION} (${M_DATE})" --text "Turning off the light on the mouse" \
--window-icon=${iconPath} --pulsate --no-cancel --auto-close --window-icon=${iconPath} --pulsate --no-cancel --auto-close
g203-led.py lightsync breathe 00FFFF 1000 0 g203-led.py lightsync breathe 00FFFF 1000 0
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
elif [ "${opcion}" == "Exit" ] ; then elif [ "${opcion}" == "Exit" ] ; then
showMenu=1 showMenu=1
else else
zenity --title "zenidrv-g203-lightsync ${VERSION} (${M_DATE})" --window-icon=${iconPath} --warning --width=300 --text "Choose one of the menu options" zenity --title "zenidrv-g203-lightsync ${VERSION} (${M_DATE})" --window-icon=${iconPath} --warning \
--width=300 --text "Choose one of the menu options"
fi fi
done done

View File

@ -79,11 +79,25 @@ while [ ${showMenu} -eq 0 ] ; do
sleep 2 | zenity --progress --title "zenidrv-g203-prodigy ${VERSION} (${M_DATE})" --text "Applying Solid effect" \ sleep 2 | zenity --progress --title "zenidrv-g203-prodigy ${VERSION} (${M_DATE})" --text "Applying Solid effect" \
--window-icon=${iconPath} --pulsate --no-cancel --auto-close --window-icon=${iconPath} --pulsate --no-cancel --auto-close
g203-led.py solid "${color_apply}" 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" color_apply="none"
elif [ "${opcion}" == "Cycle" ] ; then elif [ "${opcion}" == "Cycle" ] ; then
sleep 2 | zenity --progress --title "zenidrv-g203-prodigy ${VERSION} (${M_DATE})" --text "Applying Cycle effect" \ sleep 2 | zenity --progress --title "zenidrv-g203-prodigy ${VERSION} (${M_DATE})" --text "Applying Cycle effect" \
--window-icon=${iconPath} --pulsate --no-cancel --auto-close --window-icon=${iconPath} --pulsate --no-cancel --auto-close
g203-led.py cycle g203-led.py cycle
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
elif [ "${opcion}" == "Breathe" ] ; then elif [ "${opcion}" == "Breathe" ] ; then
color_selected=$(zenity --width=260 --height=520 --list --title "zenidrv-g203-lightsync ${VERSION} ($M_DATE)" \ color_selected=$(zenity --width=260 --height=520 --list --title "zenidrv-g203-lightsync ${VERSION} ($M_DATE)" \
--window-icon=${iconPath} --column "Select color from list :" "Black" "White" "Red" "Lime" "Blue" "Yellow" "Cyan" "Magenta" \ --window-icon=${iconPath} --column "Select color from list :" "Black" "White" "Red" "Lime" "Blue" "Yellow" "Cyan" "Magenta" \
@ -124,24 +138,59 @@ while [ ${showMenu} -eq 0 ] ; do
sleep 2 | zenity --progress --title "zenidrv-g203-prodigy ${VERSION} (${M_DATE})" --text "Applying Breathe effect" \ sleep 2 | zenity --progress --title "zenidrv-g203-prodigy ${VERSION} (${M_DATE})" --text "Applying Breathe effect" \
--window-icon=${iconPath} --pulsate --no-cancel --auto-close --window-icon=${iconPath} --pulsate --no-cancel --auto-close
g203-led.py breathe "${color_apply}" 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" color_apply="none"
elif [ "${opcion}" == "Intro (On)" ] ; then elif [ "${opcion}" == "Intro (On)" ] ; then
sleep 2 | zenity --progress --title "zenidrv-g203-prodigy ${VERSION} (${M_DATE})" --text "Enabling startup effect" \ sleep 2 | zenity --progress --title "zenidrv-g203-prodigy ${VERSION} (${M_DATE})" --text "Enabling startup effect" \
--window-icon=${iconPath} --pulsate --no-cancel --auto-close --window-icon=${iconPath} --pulsate --no-cancel --auto-close
g203-led.py intro on g203-led.py intro on
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
elif [ "${opcion}" == "Intro (Off)" ] ; then elif [ "${opcion}" == "Intro (Off)" ] ; then
sleep 2 | zenity --progress --title "zenidrv-g203-prodigy ${VERSION} (${M_DATE})" --text "Disabling startup effect" \ sleep 2 | zenity --progress --title "zenidrv-g203-prodigy ${VERSION} (${M_DATE})" --text "Disabling startup effect" \
--window-icon=${iconPath} --pulsate --no-cancel --auto-close --window-icon=${iconPath} --pulsate --no-cancel --auto-close
g203-led.py intro off g203-led.py intro off
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
elif [ "${opcion}" == "Set DPI" ] ; then elif [ "${opcion}" == "Set DPI" ] ; then
dpi_number=$(zenity --entry --title "Set DPI (from 200 to 8000)" --window-icon=${iconPath} --text "Enter DPI number (from 200 to 8000):" --entry-text "800") dpi_number=$(zenity --entry --title "Set DPI (from 200 to 8000)" --window-icon=${iconPath} --text "Enter DPI number (from 200 to 8000):" --entry-text "800")
sleep 2 | zenity --progress --title "zenidrv-g203-prodigy ${VERSION} (${M_DATE})" --text "Setting DPI to ${dpi_number}" \ sleep 2 | zenity --progress --title "zenidrv-g203-prodigy ${VERSION} (${M_DATE})" --text "Setting DPI to ${dpi_number}" \
--window-icon=${iconPath} --pulsate --no-cancel --auto-close --window-icon=${iconPath} --pulsate --no-cancel --auto-close
g203-led.py dpi ${dpi_number} g203-led.py dpi ${dpi_number}
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
elif [ "${opcion}" == "Light off" ] ; then elif [ "${opcion}" == "Light off" ] ; then
sleep 2 | zenity --progress --title "zenidrv-g203-prodigy ${VERSION} (${M_DATE})" --text "Turning off the light on the mouse" \ sleep 2 | zenity --progress --title "zenidrv-g203-prodigy ${VERSION} (${M_DATE})" --text "Turning off the light on the mouse" \
--window-icon=${iconPath} --pulsate --no-cancel --auto-close --window-icon=${iconPath} --pulsate --no-cancel --auto-close
g203-led.py breathe 00FFFF 1000 0 g203-led.py breathe 00FFFF 1000 0
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
elif [ "${opcion}" == "Exit" ] ; then elif [ "${opcion}" == "Exit" ] ; then
showMenu=1 showMenu=1
else else