zenidrv-g203/zenidrv-g203-prodigy

502 lines
22 KiB
Plaintext
Raw Normal View History

2021-07-06 12:52:33 +02:00
#!/bin/bash
#############################################################
# Zenity interface for G203 (Prodigy & Ligthsync) driver #
2021-08-24 15:12:34 +02:00
# Last change: 24-08-2021 #
2021-07-06 12:52:33 +02:00
# Author: q3aql #
2021-08-24 15:12:34 +02:00
# Contact: q3aql@duck.com #
2021-07-06 12:52:33 +02:00
# License: GPL v2.0 #
#############################################################
2021-08-24 15:12:34 +02:00
VERSION="1.3"
M_DATE="240821"
2021-07-06 12:52:33 +02:00
2021-07-07 10:20:07 +02:00
# Variables
iconPath="/usr/share/icons/logitech/logitech-black.png"
2021-07-07 13:30:26 +02:00
imagesPath="/usr/share/icons/logitech/images"
2021-07-06 12:52:33 +02:00
2021-08-24 12:56:36 +02:00
# Variables DPI & Polling rate
numberDPI=""
numberPolling=""
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:14:16 +02:00
zenity --title "zenidrv-g203-prodigy ${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-prodigy ${VERSION} (${M_DATE}) (GPL v2.0)"
echo ""
echo "* Administrator permissions are required"
echo ""
exit
fi
}
2021-08-24 12:56:36 +02:00
#Function to check ratbag dependence
function checkRatbag(){
dependence="0"
if [ -f "/usr/bin/ratbagctl" ] ; then
dependence="1"
elif [ -f "/bin/ratbagctl" ] ; then
dependence="1"
elif [ -f "/usr/local/bin/ratbagctl" ] ; then
dependence="1"
fi
echo ${dependence}
}
2021-08-24 13:34:02 +02:00
# Function to show about
function aboutZenidrv() {
zenity --title "About" --window-icon=${iconPath} --info --width=330 \
--text "GUI Interface: zenidrv-g203 ${VERSION} (${M_DATE})\nRepo: https://github.com/q3aql/zenidrv-g203\nAuthor: q3aql\nContact: q3aql@duck.com\nLicense: GPL v2.0\n\nBackend: g203-led\nRepo: https://github.com/smasty/g203-led\nAuthor: smasty\nContact: https://smasty.net\nLicense: MIT License\n\nBackend: libratbag\nAuthor: libratbag Team\nRepo: https://github.com/libratbag/libratbag\nLicense: RedHat License"
}
2021-08-24 14:47:03 +02:00
# Function to set polling rate
function setPollingRate(){
checkNumbers=$(checkRatbag)
if [ "${checkNumbers}" == "1" ] ; then
selectedPolling=$(zenity --window-icon=${iconPath} --width=220 --height=265 --list --title "zenidrv-g203-prodigy ${VERSION} (${M_DATE})" \
--window-icon=${iconPath} --column "Select the polling rate:" "100hz" "125hz" "250hz" "500hz" "1000hz")
if [ "${selectedPolling}" == "100hz" ] ; then
sleep 2 | zenity --progress --title "zenidrv-g203-prodigy ${VERSION} (${M_DATE})" --text "Setting polling rate to 100hz" \
--window-icon=${iconPath} --pulsate --no-cancel --auto-close
device_name=$(ratbagctl list | head -1 | cut -d ":" -f 1)
ratbagctl "${device_name}" rate set 100
erroPoll=$?
if [ ${erroPoll} -eq 0 ] ; then
echo > /dev/null
else
zenity --title "zenidrv-g203-prodigy ${VERSION} ($M_DATE)" --error --window-icon=${iconPath} --width=260 \
--text "Error setting the polling rate"
fi
elif [ "${selectedPolling}" == "125hz" ] ; then
sleep 2 | zenity --progress --title "zenidrv-g203-prodigy ${VERSION} (${M_DATE})" --text "Setting polling rate to 125hz" \
--window-icon=${iconPath} --pulsate --no-cancel --auto-close
device_name=$(ratbagctl list | head -1 | cut -d ":" -f 1)
ratbagctl "${device_name}" rate set 125
erroPoll=$?
if [ ${erroPoll} -eq 0 ] ; then
echo > /dev/null
else
zenity --title "zenidrv-g203-prodigy ${VERSION} ($M_DATE)" --error --window-icon=${iconPath} --width=260 \
--text "Error setting the polling rate"
fi
elif [ "${selectedPolling}" == "250hz" ] ; then
sleep 2 | zenity --progress --title "zenidrv-g203-prodigy ${VERSION} (${M_DATE})" --text "Setting polling rate to 250hz" \
--window-icon=${iconPath} --pulsate --no-cancel --auto-close
device_name=$(ratbagctl list | head -1 | cut -d ":" -f 1)
ratbagctl "${device_name}" rate set 250
erroPoll=$?
if [ ${erroPoll} -eq 0 ] ; then
echo > /dev/null
else
zenity --title "zenidrv-g203-prodigy ${VERSION} ($M_DATE)" --error --window-icon=${iconPath} --width=260 \
--text "Error setting the polling rate"
fi
elif [ "${selectedPolling}" == "500hz" ] ; then
sleep 2 | zenity --progress --title "zenidrv-g203-prodigy ${VERSION} (${M_DATE})" --text "Setting polling rate to 500hz" \
--window-icon=${iconPath} --pulsate --no-cancel --auto-close
device_name=$(ratbagctl list | head -1 | cut -d ":" -f 1)
ratbagctl "${device_name}" rate set 500
erroPoll=$?
if [ ${erroPoll} -eq 0 ] ; then
echo > /dev/null
else
zenity --title "zenidrv-g203-prodigy ${VERSION} ($M_DATE)" --error --window-icon=${iconPath} --width=260 \
--text "Error setting the polling rate"
fi
elif [ "${selectedPolling}" == "1000hz" ] ; then
sleep 2 | zenity --progress --title "zenidrv-g203-prodigy ${VERSION} (${M_DATE})" --text "Setting polling rate to 1000hz" \
--window-icon=${iconPath} --pulsate --no-cancel --auto-close
device_name=$(ratbagctl list | head -1 | cut -d ":" -f 1)
ratbagctl "${device_name}" rate set 1000
erroPoll=$?
if [ ${erroPoll} -eq 0 ] ; then
echo > /dev/null
else
zenity --title "zenidrv-g203-prodigy ${VERSION} ($M_DATE)" --error --window-icon=${iconPath} --width=260 \
--text "Error setting the polling rate"
fi
else
echo null > /dev/null
fi
else
zenity --title "zenidrv-g203 ${VERSION} (ratbagd required)" --window-icon=${iconPath} --warning --width=350 \
--text "You cannot configure the polling rate. You need to have the ratbagd (libratbag) package installed.\n\nYou can install it from the repository or by accessing the following link:\nhttps://github.com/libratbag/libratbag"
fi
}
2021-07-06 12:52:33 +02:00
# Show menu with options.
showMenu=0
rootMessage
while [ ${showMenu} -eq 0 ] ; do
clear
2021-08-24 12:56:36 +02:00
# Check dpi & polling rate to show in menu
checkNumbers=$(checkRatbag)
if [ "${checkNumbers}" == "1" ] ; then
device_name=$(ratbagctl list | head -1 | cut -d ":" -f 1)
2021-08-24 14:47:03 +02:00
get_rate=$(ratbagctl "${device_name}" rate get)
get_dpi=$(ratbagctl "${device_name}" dpi get | cut -d "d" -f 1)
2021-08-24 12:56:36 +02:00
numberDPI="(${get_dpi})"
numberPolling="(${get_rate})"
fi
2021-08-24 14:47:03 +02:00
opcion=$(zenity --width=280 --height=410 --list --title "zenidrv-g203-prodigy ${VERSION} ($M_DATE)" \
2021-07-07 17:23:24 +02:00
--window-icon=${iconPath} --imagelist --column "Icon" --column "Effect/Option" ${imagesPath}/solid.png "Solid" \
${imagesPath}/cycle.png "Cycle" ${imagesPath}/breathe.png "Breathe" ${imagesPath}/intro-on.png \
2021-08-24 12:56:36 +02:00
"Intro (On)" ${imagesPath}/intro-off.png "Intro (Off)" ${imagesPath}/mouse-dpi.png "Set DPI ${numberDPI}" \
2021-08-24 14:47:03 +02:00
${imagesPath}/mouse-polling-rate.png "Polling Rate ${numberPolling}" ${imagesPath}/light-off.png "Light off" \
${imagesPath}/about.png "About" ${imagesPath}/exit.png "Exit")
2021-07-07 17:20:32 +02:00
if [ "${opcion}" == "${imagesPath}/solid.png" ] ; then
color_selected=$(zenity --list --width=260 --height=570 --title "zenidrv-g203-prodigy ${VERSION} ($M_DATE)" \
2021-07-09 12:56:32 +02:00
--window-icon=${iconPath} --imagelist --column "Color" --column "Name color" ${imagesPath}/custom.png Custom \
2021-07-07 13:30:26 +02:00
${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 \
${imagesPath}/olive.png Olive ${imagesPath}/green.png Green ${imagesPath}/purple.png Purple ${imagesPath}/teal.png Teal \
${imagesPath}/navy.png Navy)
2021-07-07 12:14:26 +02:00
canceled=$?
if [ ${canceled} -eq 0 ] ; then
2021-07-09 12:56:32 +02:00
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}"
2021-07-07 13:30:26 +02:00
elif [ "${color_selected}" == "${imagesPath}/white.png" ] ; then
2021-07-07 12:14:26 +02:00
color_apply="FFFFFF"
2021-07-07 13:30:26 +02:00
elif [ "${color_selected}" == "${imagesPath}/red.png" ] ; then
2021-07-07 12:14:26 +02:00
color_apply="FF0000"
2021-07-07 13:30:26 +02:00
elif [ "${color_selected}" == "${imagesPath}/lime.png" ] ; then
2021-07-07 12:14:26 +02:00
color_apply="00FF00"
2021-07-07 13:30:26 +02:00
elif [ "${color_selected}" == "${imagesPath}/blue.png" ] ; then
2021-07-07 12:14:26 +02:00
color_apply="0000FF"
2021-07-07 13:30:26 +02:00
elif [ "${color_selected}" == "${imagesPath}/yellow.png" ] ; then
2021-07-07 12:14:26 +02:00
color_apply="FFFF00"
2021-07-07 13:30:26 +02:00
elif [ "${color_selected}" == "${imagesPath}/cyan.png" ] ; then
2021-07-07 12:14:26 +02:00
color_apply="00FFFF"
2021-07-07 13:30:26 +02:00
elif [ "${color_selected}" == "${imagesPath}/magenta.png" ] ; then
2021-07-07 12:14:26 +02:00
color_apply="FF00FF"
2021-07-07 13:30:26 +02:00
elif [ "${color_selected}" == "${imagesPath}/silver.png" ] ; then
2021-07-07 12:14:26 +02:00
color_apply="C0C0C0"
2021-07-07 13:30:26 +02:00
elif [ "${color_selected}" == "${imagesPath}/gray.png" ] ; then
2021-07-07 12:14:26 +02:00
color_apply="808080"
2021-07-07 13:30:26 +02:00
elif [ "${color_selected}" == "${imagesPath}/maroon.png" ] ; then
2021-07-07 12:14:26 +02:00
color_apply="800000"
2021-07-07 13:30:26 +02:00
elif [ "${color_selected}" == "${imagesPath}/olive.png" ] ; then
2021-07-07 12:14:26 +02:00
color_apply="808000"
2021-07-07 13:30:26 +02:00
elif [ "${color_selected}" == "${imagesPath}/green.png" ] ; then
2021-07-07 12:14:26 +02:00
color_apply="008000"
2021-07-07 13:30:26 +02:00
elif [ "${color_selected}" == "${imagesPath}/purple.png" ] ; then
2021-07-07 12:14:26 +02:00
color_apply="800080"
2021-07-07 13:30:26 +02:00
elif [ "${color_selected}" == "${imagesPath}/teal.png" ] ; then
2021-07-07 12:14:26 +02:00
color_apply="008080"
2021-07-07 13:30:26 +02:00
elif [ "${color_selected}" == "${imagesPath}/navy.png" ] ; then
2021-07-07 12:14:26 +02:00
color_apply="000080"
fi
2021-07-09 12:56:32 +02:00
if [ -z "${color_apply}" ] ; then
color_apply="none"
2021-07-07 12:14:26 +02:00
else
2021-07-09 12:56:32 +02:00
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"
2021-07-07 12:14:26 +02:00
fi
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-07 17:20:32 +02:00
elif [ "${opcion}" == "${imagesPath}/cycle.png" ] ; then
2021-07-07 11:14:16 +02:00
sleep 2 | zenity --progress --title "zenidrv-g203-prodigy ${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 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-prodigy ${VERSION} ($M_DATE)" --error --window-icon=${iconPath} --width=280 \
--text "Device not found or connected"
fi
2021-07-07 17:20:32 +02:00
elif [ "${opcion}" == "${imagesPath}/breathe.png" ] ; then
2021-07-07 13:30:26 +02:00
color_selected=$(zenity --list --width=260 --height=565 --title "zenidrv-g203-prodigy ${VERSION} ($M_DATE)" \
2021-07-09 12:56:32 +02:00
--window-icon=${iconPath} --imagelist --column "Color" --column "Name color" ${imagesPath}/custom.png Custom \
2021-07-07 13:30:26 +02:00
${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 \
${imagesPath}/olive.png Olive ${imagesPath}/green.png Green ${imagesPath}/purple.png Purple ${imagesPath}/teal.png Teal \
${imagesPath}/navy.png Navy)
2021-07-07 12:14:26 +02:00
canceled=$?
if [ ${canceled} -eq 0 ] ; then
2021-07-09 12:56:32 +02:00
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}"
2021-07-07 13:30:26 +02:00
elif [ "${color_selected}" == "${imagesPath}/white.png" ] ; then
2021-07-07 12:14:26 +02:00
color_apply="FFFFFF"
2021-07-07 13:30:26 +02:00
elif [ "${color_selected}" == "${imagesPath}/red.png" ] ; then
2021-07-07 12:14:26 +02:00
color_apply="FF0000"
2021-07-07 13:30:26 +02:00
elif [ "${color_selected}" == "${imagesPath}/lime.png" ] ; then
2021-07-07 12:14:26 +02:00
color_apply="00FF00"
2021-07-07 13:30:26 +02:00
elif [ "${color_selected}" == "${imagesPath}/blue.png" ] ; then
2021-07-07 12:14:26 +02:00
color_apply="0000FF"
2021-07-07 13:30:26 +02:00
elif [ "${color_selected}" == "${imagesPath}/yellow.png" ] ; then
2021-07-07 12:14:26 +02:00
color_apply="FFFF00"
2021-07-07 13:30:26 +02:00
elif [ "${color_selected}" == "${imagesPath}/cyan.png" ] ; then
2021-07-07 12:14:26 +02:00
color_apply="00FFFF"
2021-07-07 13:30:26 +02:00
elif [ "${color_selected}" == "${imagesPath}/magenta.png" ] ; then
2021-07-07 12:14:26 +02:00
color_apply="FF00FF"
2021-07-07 13:30:26 +02:00
elif [ "${color_selected}" == "${imagesPath}/silver.png" ] ; then
2021-07-07 12:14:26 +02:00
color_apply="C0C0C0"
2021-07-07 13:30:26 +02:00
elif [ "${color_selected}" == "${imagesPath}/gray.png" ] ; then
2021-07-07 12:14:26 +02:00
color_apply="808080"
2021-07-07 13:30:26 +02:00
elif [ "${color_selected}" == "${imagesPath}/maroon.png" ] ; then
2021-07-07 12:14:26 +02:00
color_apply="800000"
2021-07-07 13:30:26 +02:00
elif [ "${color_selected}" == "${imagesPath}/olive.png" ] ; then
2021-07-07 12:14:26 +02:00
color_apply="808000"
2021-07-07 13:30:26 +02:00
elif [ "${color_selected}" == "${imagesPath}/green.png" ] ; then
2021-07-07 12:14:26 +02:00
color_apply="008000"
2021-07-07 13:30:26 +02:00
elif [ "${color_selected}" == "${imagesPath}/purple.png" ] ; then
2021-07-07 12:14:26 +02:00
color_apply="800080"
2021-07-07 13:30:26 +02:00
elif [ "${color_selected}" == "${imagesPath}/teal.png" ] ; then
2021-07-07 12:14:26 +02:00
color_apply="008080"
2021-07-07 13:30:26 +02:00
elif [ "${color_selected}" == "${imagesPath}/navy.png" ] ; then
2021-07-07 12:14:26 +02:00
color_apply="000080"
fi
2021-07-09 12:56:32 +02:00
if [ -z "${color_apply}" ] ; then
color_apply="none"
2021-07-07 12:14:26 +02:00
else
2021-07-09 12:56:32 +02:00
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"
2021-07-07 12:14:26 +02:00
fi
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-07 17:20:32 +02:00
elif [ "${opcion}" == "${imagesPath}/intro-on.png" ] ; then
2021-07-07 11:14:16 +02:00
sleep 2 | zenity --progress --title "zenidrv-g203-prodigy ${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 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-prodigy ${VERSION} ($M_DATE)" --error --window-icon=${iconPath} --width=280 \
--text "Device not found or connected"
fi
2021-07-07 17:20:32 +02:00
elif [ "${opcion}" == "${imagesPath}/intro-off.png" ] ; then
2021-07-07 11:14:16 +02:00
sleep 2 | zenity --progress --title "zenidrv-g203-prodigy ${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 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-prodigy ${VERSION} ($M_DATE)" --error --window-icon=${iconPath} --width=280 \
--text "Device not found or connected"
fi
2021-07-07 17:20:32 +02:00
elif [ "${opcion}" == "${imagesPath}/mouse-dpi.png" ] ; then
2021-07-07 10:20:07 +02:00
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")
2021-07-09 12:17:11 +02:00
if [ -z ${dpi_number} ] ; then
2021-07-07 11:32:26 +02:00
echo > /dev/null
else
2021-07-09 12:17:11 +02:00
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
2021-08-24 12:56:36 +02:00
checkNumbers=$(checkRatbag)
if [ "${checkNumbers}" == "1" ] ; then
device_name=$(ratbagctl list | head -1 | cut -d ":" -f 1)
2021-08-24 14:47:03 +02:00
ratbagctl "${device_name}" dpi set "${dpi_number}"
2021-08-24 12:56:36 +02:00
fi
2021-07-09 12:17:11 +02:00
else
zenity --title "zenidrv-g203-prodigy ${VERSION} ($M_DATE)" --error --window-icon=${iconPath} --width=280 \
--text "Device not found or connected"
fi
2021-07-07 11:32:26 +02:00
fi
2021-08-24 14:47:03 +02:00
elif [ "${opcion}" == "${imagesPath}/mouse-polling-rate.png" ] ; then
setPollingRate
2021-07-07 17:20:32 +02:00
elif [ "${opcion}" == "${imagesPath}/light-off.png" ] ; then
2021-07-07 11:14:16 +02:00
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
2021-07-09 12:20:04 +02:00
g203-led.py breathe 000000 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-prodigy ${VERSION} ($M_DATE)" --error --window-icon=${iconPath} --width=280 \
--text "Device not found or connected"
fi
2021-08-24 13:34:02 +02:00
elif [ "${opcion}" == "${imagesPath}/about.png" ] ; then
aboutZenidrv
2021-07-07 17:20:32 +02:00
elif [ "${opcion}" == "${imagesPath}/exit.png" ] ; then
2021-07-06 12:52:33 +02:00
showMenu=1
else
2021-07-07 11:14:16 +02:00
zenity --title "zenidrv-g203-prodigy ${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