Show DPI number on menu

This commit is contained in:
q3aql 2021-08-24 12:56:36 +02:00
parent b41ed40cdf
commit 86f4610dcc
4 changed files with 128 additions and 8 deletions

View File

@ -14,6 +14,10 @@ M_DATE="090721"
iconPath="/usr/share/icons/logitech/logitech-black.png" iconPath="/usr/share/icons/logitech/logitech-black.png"
imagesPath="/usr/share/icons/logitech/images" imagesPath="/usr/share/icons/logitech/images"
# Variables DPI & Polling rate
numberDPI=""
numberPolling=""
# Function to check admin rights. # Function to check admin rights.
function rootMessage() { function rootMessage() {
mkdir -p /etc/root &> /dev/null mkdir -p /etc/root &> /dev/null
@ -32,16 +36,38 @@ function rootMessage() {
fi fi
} }
#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}
}
# Show menu with options. # Show menu with options.
showMenu=0 showMenu=0
rootMessage rootMessage
while [ ${showMenu} -eq 0 ] ; do while [ ${showMenu} -eq 0 ] ; do
clear clear
# Check dpi & polling rate to show in menu
checkNumbers=$(checkRatbag)
if [ "${checkNumbers}" == "1" ] ; then
device_name=$(ratbagctl list | head -1 | cut -d ":" -f 1)
get_rate=$(ratbagctl "$device_name" rate get)
get_dpi=$(ratbagctl "$device_name" dpi get | cut -d "d" -f 1)
numberDPI="(${get_dpi})"
numberPolling="(${get_rate})"
fi
opcion=$(zenity --width=280 --height=415 --list --title "zenidrv-g203-lightsync ${VERSION} ($M_DATE)" \ opcion=$(zenity --width=280 --height=415 --list --title "zenidrv-g203-lightsync ${VERSION} ($M_DATE)" \
--window-icon=${iconPath} --imagelist --column "Icono" --column "Efecto/Opcion" ${imagesPath}/solid.png "Solido" \ --window-icon=${iconPath} --imagelist --column "Icono" --column "Efecto/Opcion" ${imagesPath}/solid.png "Solido" \
${imagesPath}/cycle.png "Ciclo" ${imagesPath}/breathe.png "Respiracion" ${imagesPath}/wave.png "Ola" \ ${imagesPath}/cycle.png "Ciclo" ${imagesPath}/breathe.png "Respiracion" ${imagesPath}/wave.png "Ola" \
${imagesPath}/blend.png "Mezcla" ${imagesPath}/intro-on.png "Intro (Activado)" ${imagesPath}/intro-off.png "Intro (Desactivado)" \ ${imagesPath}/blend.png "Mezcla" ${imagesPath}/intro-on.png "Intro (Activado)" ${imagesPath}/intro-off.png "Intro (Desactivado)" \
${imagesPath}/mouse-dpi.png "Establecer DPI" ${imagesPath}/light-off.png "Apagar luz" ${imagesPath}/exit.png "Salir") ${imagesPath}/mouse-dpi.png "Establecer DPI ${numberDPI}" ${imagesPath}/light-off.png "Apagar luz" ${imagesPath}/exit.png "Salir")
if [ "${opcion}" == "${imagesPath}/solid.png" ] ; then if [ "${opcion}" == "${imagesPath}/solid.png" ] ; then
color_selected=$(zenity --list --width=260 --height=570 --title "zenidrv-g203-lightsync ${VERSION} ($M_DATE)" \ color_selected=$(zenity --list --width=260 --height=570 --title "zenidrv-g203-lightsync ${VERSION} ($M_DATE)" \
--window-icon=${iconPath} --imagelist --column "Color" --column "Nombre color" ${imagesPath}/custom.png Personalizado \ --window-icon=${iconPath} --imagelist --column "Color" --column "Nombre color" ${imagesPath}/custom.png Personalizado \
@ -381,7 +407,11 @@ while [ ${showMenu} -eq 0 ] ; do
g203-led.py lightsync dpi ${dpi_number} g203-led.py lightsync dpi ${dpi_number}
device_error=$? device_error=$?
if [ ${device_error} -eq 0 ] ; then if [ ${device_error} -eq 0 ] ; then
echo > /dev/null checkNumbers=$(checkRatbag)
if [ "${checkNumbers}" == "1" ] ; then
device_name=$(ratbagctl list | head -1 | cut -d ":" -f 1)
ratbagctl "$device_name" dpi set "${dpi_number}"
fi
else else
zenity --title "zenidrv-g203-lightsync ${VERSION} ($M_DATE)" --error --window-icon=${iconPath} --width=280 \ zenity --title "zenidrv-g203-lightsync ${VERSION} ($M_DATE)" --error --window-icon=${iconPath} --width=280 \
--text "Dispositivo no encontrado o conectado" --text "Dispositivo no encontrado o conectado"

View File

@ -14,6 +14,10 @@ M_DATE="090721"
iconPath="/usr/share/icons/logitech/logitech-black.png" iconPath="/usr/share/icons/logitech/logitech-black.png"
imagesPath="/usr/share/icons/logitech/images" imagesPath="/usr/share/icons/logitech/images"
# Variables DPI & Polling rate
numberDPI=""
numberPolling=""
# Function to check admin rights. # Function to check admin rights.
function rootMessage() { function rootMessage() {
mkdir -p /etc/root &> /dev/null mkdir -p /etc/root &> /dev/null
@ -32,15 +36,37 @@ function rootMessage() {
fi fi
} }
#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}
}
# Show menu with options. # Show menu with options.
showMenu=0 showMenu=0
rootMessage rootMessage
while [ ${showMenu} -eq 0 ] ; do while [ ${showMenu} -eq 0 ] ; do
clear clear
# Check dpi & polling rate to show in menu
checkNumbers=$(checkRatbag)
if [ "${checkNumbers}" == "1" ] ; then
device_name=$(ratbagctl list | head -1 | cut -d ":" -f 1)
get_rate=$(ratbagctl "$device_name" rate get)
get_dpi=$(ratbagctl "$device_name" dpi get | cut -d "d" -f 1)
numberDPI="(${get_dpi})"
numberPolling="(${get_rate})"
fi
opcion=$(zenity --width=280 --height=365 --list --title "zenidrv-g203-prodigy ${VERSION} ($M_DATE)" \ opcion=$(zenity --width=280 --height=365 --list --title "zenidrv-g203-prodigy ${VERSION} ($M_DATE)" \
--window-icon=${iconPath} --imagelist --column "Icono" --column "Efecto/Opcion" ${imagesPath}/solid.png "Solido" \ --window-icon=${iconPath} --imagelist --column "Icono" --column "Efecto/Opcion" ${imagesPath}/solid.png "Solido" \
${imagesPath}/cycle.png "Ciclo" ${imagesPath}/breathe.png "Respiracion" ${imagesPath}/intro-on.png \ ${imagesPath}/cycle.png "Ciclo" ${imagesPath}/breathe.png "Respiracion" ${imagesPath}/intro-on.png \
"Intro (Activado)" ${imagesPath}/intro-off.png "Intro (Desactivado)" ${imagesPath}/mouse-dpi.png "Establecer DPI" \ "Intro (Activado)" ${imagesPath}/intro-off.png "Intro (Desactivado)" ${imagesPath}/mouse-dpi.png "Establecer DPI ${numberDPI}" \
${imagesPath}/light-off.png "Apagar luz" ${imagesPath}/exit.png "Salir") ${imagesPath}/light-off.png "Apagar luz" ${imagesPath}/exit.png "Salir")
if [ "${opcion}" == "${imagesPath}/solid.png" ] ; then if [ "${opcion}" == "${imagesPath}/solid.png" ] ; then
color_selected=$(zenity --list --width=260 --height=570 --title "zenidrv-g203-prodigy ${VERSION} ($M_DATE)" \ color_selected=$(zenity --list --width=260 --height=570 --title "zenidrv-g203-prodigy ${VERSION} ($M_DATE)" \
@ -359,7 +385,11 @@ while [ ${showMenu} -eq 0 ] ; do
g203-led.py dpi ${dpi_number} g203-led.py dpi ${dpi_number}
device_error=$? device_error=$?
if [ ${device_error} -eq 0 ] ; then if [ ${device_error} -eq 0 ] ; then
echo > /dev/null checkNumbers=$(checkRatbag)
if [ "${checkNumbers}" == "1" ] ; then
device_name=$(ratbagctl list | head -1 | cut -d ":" -f 1)
ratbagctl "$device_name" dpi set "${dpi_number}"
fi
else else
zenity --title "zenidrv-g203-prodigy ${VERSION} ($M_DATE)" --error --window-icon=${iconPath} --width=280 \ zenity --title "zenidrv-g203-prodigy ${VERSION} ($M_DATE)" --error --window-icon=${iconPath} --width=280 \
--text "Dispositivo no encontrado o conectado" --text "Dispositivo no encontrado o conectado"

View File

@ -14,6 +14,10 @@ M_DATE="090721"
iconPath="/usr/share/icons/logitech/logitech-black.png" iconPath="/usr/share/icons/logitech/logitech-black.png"
imagesPath="/usr/share/icons/logitech/images" imagesPath="/usr/share/icons/logitech/images"
# Variables DPI & Polling rate
numberDPI=""
numberPolling=""
# Function to check admin rights. # Function to check admin rights.
function rootMessage() { function rootMessage() {
mkdir -p /etc/root &> /dev/null mkdir -p /etc/root &> /dev/null
@ -32,16 +36,38 @@ function rootMessage() {
fi fi
} }
#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}
}
# Show menu with options. # Show menu with options.
showMenu=0 showMenu=0
rootMessage rootMessage
while [ ${showMenu} -eq 0 ] ; do while [ ${showMenu} -eq 0 ] ; do
clear clear
# Check dpi & polling rate to show in menu
checkNumbers=$(checkRatbag)
if [ "${checkNumbers}" == "1" ] ; then
device_name=$(ratbagctl list | head -1 | cut -d ":" -f 1)
get_rate=$(ratbagctl "$device_name" rate get)
get_dpi=$(ratbagctl "$device_name" dpi get | cut -d "d" -f 1)
numberDPI="(${get_dpi})"
numberPolling="(${get_rate})"
fi
opcion=$(zenity --width=280 --height=415 --list --title "zenidrv-g203-lightsync ${VERSION} ($M_DATE)" \ opcion=$(zenity --width=280 --height=415 --list --title "zenidrv-g203-lightsync ${VERSION} ($M_DATE)" \
--window-icon=${iconPath} --imagelist --column "Icon" --column "Effect/Option" ${imagesPath}/solid.png "Solid" \ --window-icon=${iconPath} --imagelist --column "Icon" --column "Effect/Option" ${imagesPath}/solid.png "Solid" \
${imagesPath}/cycle.png "Cycle" ${imagesPath}/breathe.png "Breathe" ${imagesPath}/wave.png "Wave" \ ${imagesPath}/cycle.png "Cycle" ${imagesPath}/breathe.png "Breathe" ${imagesPath}/wave.png "Wave" \
${imagesPath}/blend.png "Blend" ${imagesPath}/intro-on.png "Intro (On)" ${imagesPath}/intro-off.png "Intro (Off)" \ ${imagesPath}/blend.png "Blend" ${imagesPath}/intro-on.png "Intro (On)" ${imagesPath}/intro-off.png "Intro (Off)" \
${imagesPath}/mouse-dpi.png "Set DPI" ${imagesPath}/light-off.png "Light off" ${imagesPath}/exit.png "Exit") ${imagesPath}/mouse-dpi.png "Set DPI ${numberDPI}" ${imagesPath}/light-off.png "Light off" ${imagesPath}/exit.png "Exit")
if [ "${opcion}" == "${imagesPath}/solid.png" ] ; then if [ "${opcion}" == "${imagesPath}/solid.png" ] ; then
color_selected=$(zenity --list --width=260 --height=570 --title "zenidrv-g203-lightsync ${VERSION} ($M_DATE)" \ 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}/custom.png Custom \ --window-icon=${iconPath} --imagelist --column "Color" --column "Name color" ${imagesPath}/custom.png Custom \
@ -381,7 +407,11 @@ while [ ${showMenu} -eq 0 ] ; do
g203-led.py lightsync dpi ${dpi_number} g203-led.py lightsync dpi ${dpi_number}
device_error=$? device_error=$?
if [ ${device_error} -eq 0 ] ; then if [ ${device_error} -eq 0 ] ; then
echo > /dev/null checkNumbers=$(checkRatbag)
if [ "${checkNumbers}" == "1" ] ; then
device_name=$(ratbagctl list | head -1 | cut -d ":" -f 1)
ratbagctl "$device_name" dpi set "${dpi_number}"
fi
else else
zenity --title "zenidrv-g203-lightsync ${VERSION} ($M_DATE)" --error --window-icon=${iconPath} --width=280 \ zenity --title "zenidrv-g203-lightsync ${VERSION} ($M_DATE)" --error --window-icon=${iconPath} --width=280 \
--text "Device not found or connected" --text "Device not found or connected"

View File

@ -14,6 +14,10 @@ M_DATE="090721"
iconPath="/usr/share/icons/logitech/logitech-black.png" iconPath="/usr/share/icons/logitech/logitech-black.png"
imagesPath="/usr/share/icons/logitech/images" imagesPath="/usr/share/icons/logitech/images"
# Variables DPI & Polling rate
numberDPI=""
numberPolling=""
# Function to check admin rights. # Function to check admin rights.
function rootMessage() { function rootMessage() {
mkdir -p /etc/root &> /dev/null mkdir -p /etc/root &> /dev/null
@ -32,15 +36,37 @@ function rootMessage() {
fi fi
} }
#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}
}
# Show menu with options. # Show menu with options.
showMenu=0 showMenu=0
rootMessage rootMessage
while [ ${showMenu} -eq 0 ] ; do while [ ${showMenu} -eq 0 ] ; do
clear clear
# Check dpi & polling rate to show in menu
checkNumbers=$(checkRatbag)
if [ "${checkNumbers}" == "1" ] ; then
device_name=$(ratbagctl list | head -1 | cut -d ":" -f 1)
get_rate=$(ratbagctl "$device_name" rate get)
get_dpi=$(ratbagctl "$device_name" dpi get | cut -d "d" -f 1)
numberDPI="(${get_dpi})"
numberPolling="(${get_rate})"
fi
opcion=$(zenity --width=280 --height=365 --list --title "zenidrv-g203-prodigy ${VERSION} ($M_DATE)" \ opcion=$(zenity --width=280 --height=365 --list --title "zenidrv-g203-prodigy ${VERSION} ($M_DATE)" \
--window-icon=${iconPath} --imagelist --column "Icon" --column "Effect/Option" ${imagesPath}/solid.png "Solid" \ --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 \ ${imagesPath}/cycle.png "Cycle" ${imagesPath}/breathe.png "Breathe" ${imagesPath}/intro-on.png \
"Intro (On)" ${imagesPath}/intro-off.png "Intro (Off)" ${imagesPath}/mouse-dpi.png "Set DPI" \ "Intro (On)" ${imagesPath}/intro-off.png "Intro (Off)" ${imagesPath}/mouse-dpi.png "Set DPI ${numberDPI}" \
${imagesPath}/light-off.png "Light off" ${imagesPath}/exit.png "Exit") ${imagesPath}/light-off.png "Light off" ${imagesPath}/exit.png "Exit")
if [ "${opcion}" == "${imagesPath}/solid.png" ] ; then if [ "${opcion}" == "${imagesPath}/solid.png" ] ; then
color_selected=$(zenity --list --width=260 --height=570 --title "zenidrv-g203-prodigy ${VERSION} ($M_DATE)" \ color_selected=$(zenity --list --width=260 --height=570 --title "zenidrv-g203-prodigy ${VERSION} ($M_DATE)" \
@ -359,7 +385,11 @@ while [ ${showMenu} -eq 0 ] ; do
g203-led.py dpi ${dpi_number} g203-led.py dpi ${dpi_number}
device_error=$? device_error=$?
if [ ${device_error} -eq 0 ] ; then if [ ${device_error} -eq 0 ] ; then
echo > /dev/null checkNumbers=$(checkRatbag)
if [ "${checkNumbers}" == "1" ] ; then
device_name=$(ratbagctl list | head -1 | cut -d ":" -f 1)
ratbagctl "$device_name" dpi set "${dpi_number}"
fi
else else
zenity --title "zenidrv-g203-prodigy ${VERSION} ($M_DATE)" --error --window-icon=${iconPath} --width=280 \ zenity --title "zenidrv-g203-prodigy ${VERSION} ($M_DATE)" --error --window-icon=${iconPath} --width=280 \
--text "Device not found or connected" --text "Device not found or connected"