2021-07-06 12:52:33 +02:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
#############################################################
|
|
|
|
# Zenity interface for G203 (Prodigy & Ligthsync) driver #
|
|
|
|
# Last change: 28-03-2021 #
|
|
|
|
# Author: q3aql #
|
|
|
|
# Contact: q3aql@protonmail.ch #
|
|
|
|
# License: GPL v2.0 #
|
|
|
|
#############################################################
|
|
|
|
VERSION="1.0"
|
|
|
|
M_DATE="060721"
|
|
|
|
|
2021-07-07 10:20:07 +02:00
|
|
|
# Variables
|
|
|
|
iconPath="/usr/share/icons/logitech/logitech-black.png"
|
2021-07-06 12:52:33 +02:00
|
|
|
|
|
|
|
# Function to check admin rights.
|
|
|
|
function rootMessage() {
|
|
|
|
mkdir -p /etc/root &> /dev/null
|
|
|
|
administrador=$?
|
|
|
|
if [ ${administrador} -eq 0 ] ; then
|
|
|
|
rm -rf /etc/root
|
|
|
|
else
|
2021-07-07 11:32:26 +02:00
|
|
|
zenity --title "zenidrv-g203-lightsync ${VERSION} (${M_DATE})" --window-icon=${iconPath} --warning \
|
|
|
|
--width=340 --text "Administrator permissions are required"
|
2021-07-06 12:52:33 +02:00
|
|
|
echo ""
|
|
|
|
echo "* zenidrv-g203-lightsync ${VERSION} (${M_DATE}) (GPL v2.0)"
|
|
|
|
echo ""
|
|
|
|
echo "* Administrator permissions are required"
|
|
|
|
echo ""
|
|
|
|
exit
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
# Show menu with options.
|
|
|
|
showMenu=0
|
|
|
|
rootMessage
|
|
|
|
while [ ${showMenu} -eq 0 ] ; do
|
|
|
|
clear
|
|
|
|
opcion=$(zenity --width=280 --height=380 --list --title "zenidrv-g203-lightsync ${VERSION} ($M_DATE)" \
|
2021-07-07 10:20:07 +02:00
|
|
|
--window-icon=${iconPath} --column "Select effect or option :" "Solid" "Cycle" "Breathe" "Wave" "Blend" \
|
2021-07-06 12:52:33 +02:00
|
|
|
"Intro (On)" "Intro (Off)" "Set DPI" \
|
|
|
|
"Light off" "Exit")
|
|
|
|
if [ "${opcion}" == "Solid" ] ; then
|
|
|
|
color_selected=$(zenity --width=260 --height=520 --list --title "zenidrv-g203-lightsync ${VERSION} ($M_DATE)" \
|
2021-07-07 10:20:07 +02:00
|
|
|
--window-icon=${iconPath} --column "Select color from list :" "Black" "White" "Red" "Lime" "Blue" "Yellow" "Cyan" "Magenta" \
|
2021-07-06 12:52:33 +02:00
|
|
|
"Silver" "Gray" "Maroon" "Olive" "Green" "Purple" "Teal" "Navy" )
|
2021-07-07 12:14:26 +02:00
|
|
|
canceled=$?
|
|
|
|
if [ ${canceled} -eq 0 ] ; then
|
|
|
|
if [ "${color_selected}" == "Black" ] ; then
|
|
|
|
color_apply="000000"
|
|
|
|
elif [ "${color_selected}" == "White" ] ; then
|
|
|
|
color_apply="FFFFFF"
|
|
|
|
elif [ "${color_selected}" == "Red" ] ; then
|
|
|
|
color_apply="FF0000"
|
|
|
|
elif [ "${color_selected}" == "Lime" ] ; then
|
|
|
|
color_apply="00FF00"
|
|
|
|
elif [ "${color_selected}" == "Blue" ] ; then
|
|
|
|
color_apply="0000FF"
|
|
|
|
elif [ "${color_selected}" == "Yellow" ] ; then
|
|
|
|
color_apply="FFFF00"
|
|
|
|
elif [ "${color_selected}" == "Cyan" ] ; then
|
|
|
|
color_apply="00FFFF"
|
|
|
|
elif [ "${color_selected}" == "Magenta" ] ; then
|
|
|
|
color_apply="FF00FF"
|
|
|
|
elif [ "${color_selected}" == "Silver" ] ; then
|
|
|
|
color_apply="C0C0C0"
|
|
|
|
elif [ "${color_selected}" == "Gray" ] ; then
|
|
|
|
color_apply="808080"
|
|
|
|
elif [ "${color_selected}" == "Maroon" ] ; then
|
|
|
|
color_apply="800000"
|
|
|
|
elif [ "${color_selected}" == "Olive" ] ; then
|
|
|
|
color_apply="808000"
|
|
|
|
elif [ "${color_selected}" == "Green" ] ; then
|
|
|
|
color_apply="008000"
|
|
|
|
elif [ "${color_selected}" == "Purple" ] ; then
|
|
|
|
color_apply="800080"
|
|
|
|
elif [ "${color_selected}" == "Teal" ] ; then
|
|
|
|
color_apply="008080"
|
|
|
|
elif [ "${color_selected}" == "Navy" ] ; 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
|
|
|
|
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"
|
2021-07-07 11:32:26 +02:00
|
|
|
else
|
2021-07-07 12:14:26 +02:00
|
|
|
color_apply="none"
|
2021-07-07 11:32:26 +02:00
|
|
|
fi
|
2021-07-06 12:52:33 +02:00
|
|
|
elif [ "${opcion}" == "Cycle" ] ; then
|
2021-07-07 11:14:16 +02:00
|
|
|
sleep 2 | zenity --progress --title "zenidrv-g203-lightsync ${VERSION} (${M_DATE})" --text "Applying Cycle effect" \
|
|
|
|
--window-icon=${iconPath} --pulsate --no-cancel --auto-close
|
2021-07-06 12:52:33 +02:00
|
|
|
g203-led.py lightsync cycle
|
2021-07-07 11:32:26 +02:00
|
|
|
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
|
2021-07-06 12:52:33 +02:00
|
|
|
elif [ "${opcion}" == "Breathe" ] ; then
|
|
|
|
color_selected=$(zenity --width=260 --height=520 --list --title "zenidrv-g203-lightsync ${VERSION} ($M_DATE)" \
|
2021-07-07 10:20:07 +02:00
|
|
|
--window-icon=${iconPath} --column "Select color from list :" "Black" "White" "Red" "Lime" "Blue" "Yellow" "Cyan" "Magenta" \
|
2021-07-06 12:52:33 +02:00
|
|
|
"Silver" "Gray" "Maroon" "Olive" "Green" "Purple" "Teal" "Navy" )
|
2021-07-07 12:14:26 +02:00
|
|
|
canceled=$?
|
|
|
|
if [ ${canceled} -eq 0 ] ; then
|
|
|
|
if [ "${color_selected}" == "Black" ] ; then
|
|
|
|
color_apply="000000"
|
|
|
|
elif [ "${color_selected}" == "White" ] ; then
|
|
|
|
color_apply="FFFFFF"
|
|
|
|
elif [ "${color_selected}" == "Red" ] ; then
|
|
|
|
color_apply="FF0000"
|
|
|
|
elif [ "${color_selected}" == "Lime" ] ; then
|
|
|
|
color_apply="00FF00"
|
|
|
|
elif [ "${color_selected}" == "Blue" ] ; then
|
|
|
|
color_apply="0000FF"
|
|
|
|
elif [ "${color_selected}" == "Yellow" ] ; then
|
|
|
|
color_apply="FFFF00"
|
|
|
|
elif [ "${color_selected}" == "Cyan" ] ; then
|
|
|
|
color_apply="00FFFF"
|
|
|
|
elif [ "${color_selected}" == "Magenta" ] ; then
|
|
|
|
color_apply="FF00FF"
|
|
|
|
elif [ "${color_selected}" == "Silver" ] ; then
|
|
|
|
color_apply="C0C0C0"
|
|
|
|
elif [ "${color_selected}" == "Gray" ] ; then
|
|
|
|
color_apply="808080"
|
|
|
|
elif [ "${color_selected}" == "Maroon" ] ; then
|
|
|
|
color_apply="800000"
|
|
|
|
elif [ "${color_selected}" == "Olive" ] ; then
|
|
|
|
color_apply="808000"
|
|
|
|
elif [ "${color_selected}" == "Green" ] ; then
|
|
|
|
color_apply="008000"
|
|
|
|
elif [ "${color_selected}" == "Purple" ] ; then
|
|
|
|
color_apply="800080"
|
|
|
|
elif [ "${color_selected}" == "Teal" ] ; then
|
|
|
|
color_apply="008080"
|
|
|
|
elif [ "${color_selected}" == "Navy" ] ; 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
|
|
|
|
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"
|
2021-07-07 11:32:26 +02:00
|
|
|
else
|
2021-07-07 12:14:26 +02:00
|
|
|
color_apply="none"
|
2021-07-07 11:32:26 +02:00
|
|
|
fi
|
2021-07-06 12:52:33 +02:00
|
|
|
elif [ "${opcion}" == "Wave" ] ; then
|
2021-07-07 11:14:16 +02:00
|
|
|
sleep 2 | zenity --progress --title "zenidrv-g203-lightsync ${VERSION} (${M_DATE})" --text "Applying Wave effect" \
|
|
|
|
--window-icon=${iconPath} --pulsate --no-cancel --auto-close
|
2021-07-06 12:52:33 +02:00
|
|
|
g203-led.py lightsync wave
|
2021-07-07 11:32:26 +02:00
|
|
|
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
|
2021-07-06 12:52:33 +02:00
|
|
|
elif [ "${opcion}" == "Blend" ] ; then
|
2021-07-07 11:14:16 +02:00
|
|
|
sleep 2 | zenity --progress --title "zenidrv-g203-lightsync ${VERSION} (${M_DATE})" --text "Applying Blend effect" \
|
|
|
|
--window-icon=${iconPath} --pulsate --no-cancel --auto-close
|
2021-07-06 12:52:33 +02:00
|
|
|
g203-led.py lightsync blend
|
2021-07-07 11:32:26 +02:00
|
|
|
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
|
2021-07-06 12:52:33 +02:00
|
|
|
elif [ "${opcion}" == "Intro (On)" ] ; then
|
2021-07-07 11:14:16 +02:00
|
|
|
sleep 2 | zenity --progress --title "zenidrv-g203-lightsync ${VERSION} (${M_DATE})" --text "Enabling startup effect" \
|
|
|
|
--window-icon=${iconPath} --pulsate --no-cancel --auto-close
|
2021-07-06 12:52:33 +02:00
|
|
|
g203-led.py lightsync intro on
|
2021-07-07 11:32:26 +02:00
|
|
|
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
|
2021-07-06 12:52:33 +02:00
|
|
|
elif [ "${opcion}" == "Intro (Off)" ] ; then
|
2021-07-07 11:14:16 +02:00
|
|
|
sleep 2 | zenity --progress --title "zenidrv-g203-lightsync ${VERSION} (${M_DATE})" --text "Disabling startup effect" \
|
|
|
|
--window-icon=${iconPath} --pulsate --no-cancel --auto-close
|
2021-07-06 12:52:33 +02:00
|
|
|
g203-led.py lightsync intro off
|
2021-07-07 11:32:26 +02:00
|
|
|
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
|
2021-07-06 12:52:33 +02:00
|
|
|
elif [ "${opcion}" == "Set DPI" ] ; then
|
2021-07-07 10:20:07 +02:00
|
|
|
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")
|
2021-07-07 11:14:16 +02:00
|
|
|
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
|
2021-07-06 12:52:33 +02:00
|
|
|
g203-led.py lightsync dpi ${dpi_number}
|
2021-07-07 11:32:26 +02:00
|
|
|
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
|
2021-07-06 12:52:33 +02:00
|
|
|
elif [ "${opcion}" == "Light off" ] ; then
|
2021-07-07 11:14:16 +02:00
|
|
|
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
|
2021-07-06 12:52:33 +02:00
|
|
|
g203-led.py lightsync breathe 00FFFF 1000 0
|
2021-07-07 11:32:26 +02:00
|
|
|
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
|
2021-07-06 12:52:33 +02:00
|
|
|
elif [ "${opcion}" == "Exit" ] ; then
|
|
|
|
showMenu=1
|
|
|
|
else
|
2021-07-07 11:32:26 +02:00
|
|
|
zenity --title "zenidrv-g203-lightsync ${VERSION} (${M_DATE})" --window-icon=${iconPath} --warning \
|
|
|
|
--width=300 --text "Choose one of the menu options"
|
2021-07-06 12:52:33 +02:00
|
|
|
fi
|
|
|
|
done
|