Add zenity bash scripts for GUI

This commit is contained in:
q3aql 2021-07-06 12:52:33 +02:00
parent 1dc2121869
commit dd32014fb9
5 changed files with 416 additions and 0 deletions

29
Makefile Normal file
View File

@ -0,0 +1,29 @@
#################################
# Install zenidrv-g203 (q3aql) #
#################################
PREFIX=/usr
install:
mkdir -p /usr/share/icons/logitech/
cp -rf icon/logitech-black.png $(PREFIX)/share/icons/logitech/
cp -rf icon/zenidrv-203.desktop $(PREFIX)/share/applications/
cp -rf g203-led.py $(PREFIX)/bin
cp -rf zenidrv-g203 $(PREFIX)/bin
cp -rf zenidrv-g203-admin $(PREFIX)/bin
cp -rf zenidrv-g203-prodigy $(PREFIX)/bin
cp -rf zenidrv-g203-lightsync $(PREFIX)/bin
chmod 755 $(PREFIX)/bin/g203-led.py
chmod 755 $(PREFIX)/bin/zenidrv-g203
chmod 755 $(PREFIX)/bin/zenidrv-g203-admin
chmod 755 $(PREFIX)/bin/zenidrv-g203-prodigy
chmod 755 $(PREFIX)/bin/zenidrv-g203-lightsync
uninstall:
rm -rf $(PREFIX)/bin/g203-led.py
rm -rf $(PREFIX)/bin/zenidrv-g203
rm -rf $(PREFIX)/bin/zenidrv-g203-admin
rm -rf $(PREFIX)/bin/zenidrv-g203-prodigy
rm -rf $(PREFIX)/bin/zenidrv-g203-lightsync
rm -rf $(PREFIX)/share/icons/logitech/logitech-black.png
rm -rf $(PREFIX)/share/applications/zenidrv-203.desktop

41
zenidrv-g203 Executable file
View File

@ -0,0 +1,41 @@
#!/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"
# Function to check admin rights
function rootMessage() {
mkdir -p /etc/root &> /dev/null
administrador=$?
if [ ${administrador} -eq 0 ] ; then
rm -rf /etc/root
else
zenity --title "zenidrv-g203 v${VERSION} (${M_DATE})" --warning --width=340 --text "Administrator permissions are required"
echo ""
echo "* zenidrv-g203 v${VERSION} (${M_DATE}) (GPL v2.0)"
echo ""
echo "* Administrator permissions are required"
echo ""
exit
fi
}
rootMessage
zenity --question --title "zenidrv-g203 ${VERSION} (${M_DATE})" --cancel-label="Prodigy 1r Gen (Default)" --ok-label="Lightsync 2nd Gen" --width=530 \
--text "Choose the version of your Logitech G203 (Prodigy 1r Gen or Lightsync 2nd Gen)"
createLink=$?
if [ ${createLink} -eq 1 ] ; then
zenidrv-g203-prodigy
else
zenidrv-g203-lightsync
fi

75
zenidrv-g203-admin Executable file
View File

@ -0,0 +1,75 @@
#!/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"
# Link with gksudo,gksu o bessu
function showRootMessage() {
if [ -f /usr/bin/gksudo ] ; then
gksudo /usr/bin/zenidrv-g203
exit
elif [ -f /bin/gksudo ] ; then
gksudo /usr/bin/zenidrv-g203
exit
elif [ -f /usr/bin/gksu ] ; then
gksu /usr/bin/zenidrv-g203
exit
elif [ -f /bin/gksu ] ; then
gksu /usr/bin/zenidrv-g203
exit
elif [ -f /usr/bin/beesu ] ; then
beesu /usr/bin/zenidrv-g203
exit
elif [ -f /bin/beesu ] ; then
beesu /usr/bin/zenidrv-g203
exit
elif [ -f /bin/sudo ] ; then
xterm -T "zenidrv-g203 ${VERSION} (${M_DATE})" -fa Monospace -fs 10 -bg white -fg black -e "sudo zenidrv-g203"
exit
elif [ -f /usr/bin/sudo ] ; then
xterm -T "zenidrv-g203 ${VERSION} (${M_DATE})" -fa Monospace -fs 10 -bg white -fg black -e "sudo zenidrv-g203"
exit
elif [ -f /usr/bin/su ] ; then
xterm -T "zenidrv-g203 ${VERSION} (${M_DATE})" -fa Monospace -fs 10 -bg white -fg black -e "su -c 'zenidrv-g203'"
exit
elif [ -f /bin/su ] ; then
xterm -T "zenidrv-g203 ${VERSION} (${M_DATE})" -fa Monospace -fs 10 -bg white -fg black -e "su -c 'zenidrv-g203'"
exit
else
zenity -h &> /dev/null
output=$?
if [ ${output} -eq 0 ] ; then
zenity --title "zenidrv-g203 ${VERSION} (${M_DATE})" --info \
--text "The 'zenidrv-g203' program could not be run as administrator\n\nPlease run the command 'zenidrv-g203' as root user in terminal"
else
xterm -T "zenidrv-g203 ${VERSION} (${M_DATE})" -fa Monospace -fs 10 -bg white -fg black -e "zenidrv-g203-admin --error"
fi
fi
}
# Function to show error message
function errorMessage() {
echo ""
echo "* ATTENTION!:"
echo ""
echo "* The 'zenidrv-g203' program could not be run as administrator"
echo ""
echo "* Please run the command 'zenidrv-g203' as root user in terminal"
echo ""
echo -n "* Press ENTER to exit... " ; read continue
exit
}
# Inicio del script
if [ "${1}" == "--error" ] ; then
errorMessage
else
showRootMessage
fi

138
zenidrv-g203-lightsync Executable file
View File

@ -0,0 +1,138 @@
#!/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"
# Function to check admin rights.
function rootMessage() {
mkdir -p /etc/root &> /dev/null
administrador=$?
if [ ${administrador} -eq 0 ] ; then
rm -rf /etc/root
else
zenity --title "zenidrv-g203-lightsync ${VERSION} (${M_DATE})" --warning --width=340 --text "Administrator permissions are required"
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)" \
--column "Select effect or option :" "Solid" "Cycle" "Breathe" "Wave" "Blend" \
"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)" \
--column "Select color from list :" "Black" "White" "Red" "Lime" "Blue" "Yellow" "Cyan" "Magenta" \
"Silver" "Gray" "Maroon" "Olive" "Green" "Purple" "Teal" "Navy" )
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
g203-led.py lightsync solid "${color_apply}"
color_apply="none"
elif [ "${opcion}" == "Cycle" ] ; then
g203-led.py lightsync cycle
elif [ "${opcion}" == "Breathe" ] ; then
color_selected=$(zenity --width=260 --height=520 --list --title "zenidrv-g203-lightsync ${VERSION} ($M_DATE)" \
--column "Select color from list :" "Black" "White" "Red" "Lime" "Blue" "Yellow" "Cyan" "Magenta" \
"Silver" "Gray" "Maroon" "Olive" "Green" "Purple" "Teal" "Navy" )
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
g203-led.py lightsync breathe "${color_apply}"
color_apply="none"
elif [ "${opcion}" == "Wave" ] ; then
g203-led.py lightsync wave
elif [ "${opcion}" == "Blend" ] ; then
g203-led.py lightsync blend
elif [ "${opcion}" == "Intro (On)" ] ; then
g203-led.py lightsync intro on
elif [ "${opcion}" == "Intro (Off)" ] ; then
g203-led.py lightsync intro off
elif [ "${opcion}" == "Set DPI" ] ; then
dpi_number=$(zenity --entry --title "Set DPI (from 50 to 8000)" --text "Enter DPI number (from 50 to 8000):" --entry-text "800")
g203-led.py lightsync dpi ${dpi_number}
elif [ "${opcion}" == "Light off" ] ; then
g203-led.py lightsync breathe 00FFFF 1000 0
elif [ "${opcion}" == "Exit" ] ; then
showMenu=1
else
zenity --title "zenidrv-g203-lightsync ${VERSION} (${M_DATE})" --warning --width=300 --text "Choose one of the menu options"
fi
done

133
zenidrv-g203-prodigy Executable file
View File

@ -0,0 +1,133 @@
#!/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"
# Function to check admin rights.
function rootMessage() {
mkdir -p /etc/root &> /dev/null
administrador=$?
if [ ${administrador} -eq 0 ] ; then
rm -rf /etc/root
else
zenity --title "zenidrv-g203-prodigy ${VERSION} (${M_DATE})" --warning --width=340 --text "Administrator permissions are required"
echo ""
echo "* zenidrv-g203-prodigy ${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=330 --list --title "zenidrv-g203-prodigy ${VERSION} ($M_DATE)" \
--column "Select effect or option :" "Solid" "Cycle" "Breathe" "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)" \
--column "Select color from list :" "Black" "White" "Red" "Lime" "Blue" "Yellow" "Cyan" "Magenta" \
"Silver" "Gray" "Maroon" "Olive" "Green" "Purple" "Teal" "Navy" )
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
g203-led.py solid "${color_apply}"
color_apply="none"
elif [ "${opcion}" == "Cycle" ] ; then
g203-led.py cycle
elif [ "${opcion}" == "Breathe" ] ; then
color_selected=$(zenity --width=260 --height=520 --list --title "zenidrv-g203-lightsync ${VERSION} ($M_DATE)" \
--column "Select color from list :" "Black" "White" "Red" "Lime" "Blue" "Yellow" "Cyan" "Magenta" \
"Silver" "Gray" "Maroon" "Olive" "Green" "Purple" "Teal" "Navy" )
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
g203-led.py breathe "${color_apply}"
color_apply="none"
elif [ "${opcion}" == "Intro (On)" ] ; then
g203-led.py intro on
elif [ "${opcion}" == "Intro (Off)" ] ; then
g203-led.py intro off
elif [ "${opcion}" == "Set DPI" ] ; then
dpi_number=$(zenity --entry --title "Set DPI (from 200 to 8000)" --text "Enter DPI number (from 200 to 8000):" --entry-text "800")
g203-led.py dpi ${dpi_number}
elif [ "${opcion}" == "Light off" ] ; then
g203-led.py breathe 00FFFF 1000 0
elif [ "${opcion}" == "Exit" ] ; then
showMenu=1
else
zenity --title "zenidrv-g203-prodigy ${VERSION} (${M_DATE})" --warning --width=300 --text "Choose one of the menu options"
fi
done