From f771c3bbc3c96557ee5f3d87923c6a5a65f40da1 Mon Sep 17 00:00:00 2001 From: q3aql Date: Wed, 7 Jul 2021 11:32:26 +0200 Subject: [PATCH] Added error checking --- zenidrv-g203-lightsync | 69 ++++++++++++++++++++++++++++++++++++++++-- zenidrv-g203-prodigy | 49 ++++++++++++++++++++++++++++++ 2 files changed, 116 insertions(+), 2 deletions(-) diff --git a/zenidrv-g203-lightsync b/zenidrv-g203-lightsync index 4a9767f..cd008f4 100755 --- a/zenidrv-g203-lightsync +++ b/zenidrv-g203-lightsync @@ -20,7 +20,8 @@ function rootMessage() { if [ ${administrador} -eq 0 ] ; then rm -rf /etc/root 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 "* zenidrv-g203-lightsync ${VERSION} (${M_DATE}) (GPL v2.0)" 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" \ --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" elif [ "${opcion}" == "Cycle" ] ; then sleep 2 | zenity --progress --title "zenidrv-g203-lightsync ${VERSION} (${M_DATE})" --text "Applying Cycle effect" \ --window-icon=${iconPath} --pulsate --no-cancel --auto-close 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 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" \ @@ -124,35 +139,85 @@ while [ ${showMenu} -eq 0 ] ; do 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" elif [ "${opcion}" == "Wave" ] ; then sleep 2 | zenity --progress --title "zenidrv-g203-lightsync ${VERSION} (${M_DATE})" --text "Applying Wave effect" \ --window-icon=${iconPath} --pulsate --no-cancel --auto-close 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 sleep 2 | zenity --progress --title "zenidrv-g203-lightsync ${VERSION} (${M_DATE})" --text "Applying Blend effect" \ --window-icon=${iconPath} --pulsate --no-cancel --auto-close 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 sleep 2 | zenity --progress --title "zenidrv-g203-lightsync ${VERSION} (${M_DATE})" --text "Enabling startup effect" \ --window-icon=${iconPath} --pulsate --no-cancel --auto-close 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 sleep 2 | zenity --progress --title "zenidrv-g203-lightsync ${VERSION} (${M_DATE})" --text "Disabling startup effect" \ --window-icon=${iconPath} --pulsate --no-cancel --auto-close 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 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}" \ --window-icon=${iconPath} --pulsate --no-cancel --auto-close 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 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 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 showMenu=1 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 done diff --git a/zenidrv-g203-prodigy b/zenidrv-g203-prodigy index 537f6d4..11d9456 100755 --- a/zenidrv-g203-prodigy +++ b/zenidrv-g203-prodigy @@ -79,11 +79,25 @@ while [ ${showMenu} -eq 0 ] ; do 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" elif [ "${opcion}" == "Cycle" ] ; then sleep 2 | zenity --progress --title "zenidrv-g203-prodigy ${VERSION} (${M_DATE})" --text "Applying Cycle effect" \ --window-icon=${iconPath} --pulsate --no-cancel --auto-close 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 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" \ @@ -124,24 +138,59 @@ while [ ${showMenu} -eq 0 ] ; do 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" elif [ "${opcion}" == "Intro (On)" ] ; then sleep 2 | zenity --progress --title "zenidrv-g203-prodigy ${VERSION} (${M_DATE})" --text "Enabling startup effect" \ --window-icon=${iconPath} --pulsate --no-cancel --auto-close 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 sleep 2 | zenity --progress --title "zenidrv-g203-prodigy ${VERSION} (${M_DATE})" --text "Disabling startup effect" \ --window-icon=${iconPath} --pulsate --no-cancel --auto-close 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 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}" \ --window-icon=${iconPath} --pulsate --no-cancel --auto-close 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 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 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 showMenu=1 else