Enhancing the behaviour of the script
This commit is contained in:
parent
558784cc49
commit
494e507599
1 changed files with 113 additions and 113 deletions
|
|
@ -1,113 +1,113 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
|
|
||||||
DONT_SUPPORT_3D="Your machine does not support 3D acceleration"
|
DONT_SUPPORT_3D="Your machine does not support 3D acceleration"
|
||||||
|
|
||||||
if [ $LANG = es_ES.UTF-8 ]; then
|
if [ $LANG = es_ES.UTF-8 ]; then
|
||||||
DONT_SUPPORT_3D="Su equipo no soporta aceleración 3D"
|
DONT_SUPPORT_3D="Su equipo no soporta aceleración 3D"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# First, check if the computer
|
# First, check if the computer
|
||||||
# supports 3D acceleration. If not, it
|
# supports 3D acceleration. If not, it
|
||||||
# it informs the user and then exits.
|
# it informs the user and then exits.
|
||||||
[ 0 = $(glxinfo |grep "renderer string:" |grep -v llvmpipe | wc -c) ] && zenity \
|
[ 0 = $(glxinfo |grep "renderer string:" |grep -v llvmpipe | wc -c) ] && zenity \
|
||||||
--info --text="$DONT_SUPPORT_3D" && exit 0
|
--info --text="$DONT_SUPPORT_3D" && exit 0
|
||||||
|
|
||||||
# Check if compton is currently running.
|
# Check if compton is currently running.
|
||||||
case "$(pgrep -u $USER compton | wc -w)" in
|
case "$(pgrep -u $USER compton | wc -w)" in
|
||||||
|
|
||||||
0) COMPTON_RUNNING=false
|
0) COMPTON_RUNNING=false
|
||||||
;;
|
;;
|
||||||
1) COMPTON_RUNNING=true
|
1) COMPTON_RUNNING=true
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
|
|
||||||
if $COMPTON_RUNNING; then
|
if $COMPTON_RUNNING; then
|
||||||
COMPTON=true
|
COMPTON=true
|
||||||
DISCOMPTON=false
|
DISCOMPTON=false
|
||||||
|
|
||||||
elif ! $COMPTON_RUNNING; then
|
elif ! $COMPTON_RUNNING; then
|
||||||
COMPTON=false
|
COMPTON=false
|
||||||
DISCOMPTON=true
|
DISCOMPTON=true
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# The text that will be showed to the user.
|
# The text that will be showed to the user.
|
||||||
TEXT="Use Compton compositor if 3d acceleration available"
|
TEXT="Use Compton compositor if 3d acceleration available"
|
||||||
TITLE="Choose between enabling or disabling Compton"
|
TITLE="Choose between enabling or disabling Compton"
|
||||||
COMPTON_ENABLED="Compton enabled"
|
COMPTON_ENABLED="Compton enabled"
|
||||||
COMPTON_DISABLED="Compton disabled"
|
COMPTON_DISABLED="Compton disabled"
|
||||||
INFO="Compton is already running"
|
INFO="Compton is already running"
|
||||||
|
|
||||||
|
|
||||||
#Checks the languange of the system (more can be added in the future) and displays the text corresponding to the language selected.
|
#Checks the languange of the system (more can be added in the future) and displays the text corresponding to the language selected.
|
||||||
if [ $LANG = es_ES.UTF-8 ]; then
|
if [ $LANG = es_ES.UTF-8 ]; then
|
||||||
TEXT="Usar el compositor Compton si el equipo soporta aceleración 3D"
|
TEXT="Usar el compositor Compton si el equipo soporta aceleración 3D"
|
||||||
TITLE="Seleccionar entre habilitar o deshabilitar los efectos de Compton"
|
TITLE="Seleccionar entre habilitar o deshabilitar los efectos de Compton"
|
||||||
COMPTON_ENABLED="Compton habilitado"
|
COMPTON_ENABLED="Compton habilitado"
|
||||||
COMPTON_DISABLED="Compton deshabilitado"
|
COMPTON_DISABLED="Compton deshabilitado"
|
||||||
INFO="Compton ya se encuentra en ejecución"
|
INFO="Compton ya se encuentra en ejecución"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Zenity is summoned to interact with the user.
|
# Zenity is summoned to interact with the user.
|
||||||
# The XOR with the "exit 0" means that the script
|
# The XOR with the "exit 0" means that the script
|
||||||
# will exit with no error if zenity is "canceled"
|
# will exit with no error if zenity is "canceled"
|
||||||
# (user clicking on the "cancel" button, for
|
# (user clicking on the "cancel" button, for
|
||||||
# instance).
|
# instance).
|
||||||
ans=$(zenity --list --hide-header\
|
ans=$(zenity --list --hide-header\
|
||||||
--title "$TITLE"\
|
--title "$TITLE"\
|
||||||
--text "$TEXT"\
|
--text "$TEXT"\
|
||||||
--radiolist\
|
--radiolist\
|
||||||
--column "" --column ""\
|
--column "" --column ""\
|
||||||
$COMPTON "$COMPTON_ENABLED"\
|
$COMPTON "$COMPTON_ENABLED"\
|
||||||
$DISCOMPTON "$COMPTON_DISABLED" || exit 0)
|
$DISCOMPTON "$COMPTON_DISABLED" || exit 0)
|
||||||
|
|
||||||
# Evaluate if compton is runnning or not, if it does,
|
# Evaluate if compton is runnning or not, if it does,
|
||||||
# warn the user if he/she tries to run compton again
|
# warn the user if he/she tries to run compton again
|
||||||
# or disable the compositor if he/she select to disable
|
# or disable the compositor if he/she select to disable
|
||||||
# it. If compton is not running, run and enable it if
|
# it. If compton is not running, run and enable it if
|
||||||
# the user selects to do so:
|
# the user selects to do so:
|
||||||
# .-----------------.
|
# .-----------------.
|
||||||
# | |
|
# | |
|
||||||
# | |
|
# | |
|
||||||
# | Compton running |
|
# | Compton running |
|
||||||
# | |
|
# | |
|
||||||
# | |
|
# | |
|
||||||
# '-----------------'
|
# '-----------------'
|
||||||
# |
|
# |
|
||||||
# | .-----------------. .-----------------.
|
# | .-----------------. .-----------------.
|
||||||
# |-->| User selects no |-->| Disable compton |
|
# |-->| User selects no |-->| Disable compton |
|
||||||
# | '-----------------' '-----------------'
|
# | '-----------------' '-----------------'
|
||||||
# | .------------------. .-----------------.
|
# | .------------------. .-----------------.
|
||||||
# '-->| User selects yes |->| Inform the user |
|
# '-->| User selects yes |->| Inform the user |
|
||||||
# '------------------' '-----------------'
|
# '------------------' '-----------------'
|
||||||
# .---------------------.
|
# .---------------------.
|
||||||
# | |
|
# | |
|
||||||
# | |
|
# | |
|
||||||
# | Compton not running |
|
# | Compton not running |
|
||||||
# | |
|
# | |
|
||||||
# | |
|
# | |
|
||||||
# '---------------------'
|
# '---------------------'
|
||||||
# |
|
# |
|
||||||
# | .-----------------. .------------.
|
# | .-----------------. .------------.
|
||||||
# |-->| User selects no |-->| Do nothing |
|
# |-->| User selects no |-->| Do nothing |
|
||||||
# | '-----------------' '------------'
|
# | '-----------------' '------------'
|
||||||
# | .------------------. .-----------------.
|
# | .------------------. .-----------------.
|
||||||
# '-->| User selects yes |-->| Enable compton |
|
# '-->| User selects yes |-->| Enable compton |
|
||||||
# '------------------' '-----------------'
|
# '------------------' '-----------------'
|
||||||
if $COMPTON_RUNNING # Compton running
|
if $COMPTON_RUNNING # Compton running
|
||||||
then
|
then
|
||||||
if [[ $ans == $COMPTON_DISABLED ]]; then
|
if [[ $ans == $COMPTON_DISABLED ]]; then
|
||||||
touch $HOME/.config/disable-compton
|
touch $HOME/.config/disable-compton
|
||||||
killall compton
|
killall compton
|
||||||
elif [[ $ans == $COMPTON_ENABLED ]]; then
|
elif [[ $ans == $COMPTON_ENABLED ]]; then
|
||||||
zenity --info --text="Compton is already running"
|
zenity --info --text="$INFO"
|
||||||
fi
|
fi
|
||||||
else # Compton not running
|
else # Compton not running
|
||||||
if [[ $ans == $COMPTON_ENABLED ]]; then
|
if [[ $ans == $COMPTON_ENABLED ]]; then
|
||||||
rm -f $HOME/.config/disable-compton
|
rm -f $HOME/.config/disable-compton
|
||||||
compton-launcher
|
compton-launcher
|
||||||
else
|
else
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
Loading…
Add table
Add a link
Reference in a new issue