Skip to content
Snippets Groups Projects
Commit c477472a authored by Ruben Rodriguez's avatar Ruben Rodriguez
Browse files

Merge branch 'belenos' into 'belenos'

Belenos

Greetings, I took the feedback and I changed some things:

1) I added some lines at the beginning to check if the computer handles 3D acceleration: I decided not doing anything at first because I knew that compton-launcher already checks for that but then I realize that If the user is not properly informed, she/he could think it is a bug so I decided to do something about that. Please, could you check the lines 13 and 14? even though I did some tests to make sure it works, I don't have much experience in shell programming to be 100% sure.

2) I decided to take the other way around about treating the user's imput because I felt that it was more intuitive to treat first if compton was running or not and then evaluate the user's action. Don't worry if the user starts or stops compton by their own, the scripts checks if it is running by looking at the computer's processes and I've already took at into account while I was writing it (No complications added, just treat everything normally)

3) I think I went a little bit too far with the comments... But I prefer you to to decide if that was too much.

Thank you for your patience and I hope this is good enough to be included.

See merge request !106
parents a8eb5069 494e5075
No related branches found
No related tags found
No related merge requests found
#!/bin/bash #!/bin/bash
#Check if compton is currently running.
case "$(pgrep -u $USER compton | wc -w)" in DONT_SUPPORT_3D="Your machine does not support 3D acceleration"
0) COMPTON_RUNNING=false if [ $LANG = es_ES.UTF-8 ]; then
;; DONT_SUPPORT_3D="Su equipo no soporta aceleración 3D"
1) COMPTON_RUNNING=true fi
;;
esac # First, check if the computer
# supports 3D acceleration. If not, it
# it informs the user and then exits.
if $COMPTON_RUNNING; then [ 0 = $(glxinfo |grep "renderer string:" |grep -v llvmpipe | wc -c) ] && zenity \
COMPTON=true --info --text="$DONT_SUPPORT_3D" && exit 0
DISCOMPTON=false
# Check if compton is currently running.
elif ! $COMPTON_RUNNING; then case "$(pgrep -u $USER compton | wc -w)" in
COMPTON=false
DISCOMPTON=true 0) COMPTON_RUNNING=false
;;
fi 1) COMPTON_RUNNING=true
;;
#The text that will be showed to the user. esac
TEXT="Use Compton compositor if 3d acceleration available"
TITLE="Choose between enabling or disabling Compton"
COMPTON_ENABLED="Compton enabled" if $COMPTON_RUNNING; then
COMPTON_DISABLED="Compton disabled" COMPTON=true
INFO="Compton is already running" DISCOMPTON=false
elif ! $COMPTON_RUNNING; then
#Checks the languange of the system (more can be added in the future) and displays the text corresponding to the language selected. COMPTON=false
if [ $LANG = es_ES.UTF-8 ]; then DISCOMPTON=true
TEXT="Usar el compositor Compton si el equipo soporta aceleración 3D" fi
TITLE="Seleccionar entre habilitar o deshabilitar los efectos de Compton"
COMPTON_ENABLED="Compton habilitado" # The text that will be showed to the user.
COMPTON_DISABLED="Compton deshabilitado" TEXT="Use Compton compositor if 3d acceleration available"
INFO="Compton ya se encuentra en ejecución" TITLE="Choose between enabling or disabling Compton"
fi COMPTON_ENABLED="Compton enabled"
COMPTON_DISABLED="Compton disabled"
#Zenity is summoned to interact with the user. INFO="Compton is already running"
ans=$(zenity --list --hide-header\
--title "$TITLE"\
--text "$TEXT"\ #Checks the languange of the system (more can be added in the future) and displays the text corresponding to the language selected.
--radiolist\ if [ $LANG = es_ES.UTF-8 ]; then
--column "" --column ""\ TEXT="Usar el compositor Compton si el equipo soporta aceleración 3D"
$COMPTON "$COMPTON_ENABLED"\ TITLE="Seleccionar entre habilitar o deshabilitar los efectos de Compton"
$DISCOMPTON "$COMPTON_DISABLED") COMPTON_ENABLED="Compton habilitado"
COMPTON_DISABLED="Compton deshabilitado"
#The program reacts to the user's decision. INFO="Compton ya se encuentra en ejecución"
if [[ $ans = "$COMPTON_ENABLED" ]] && ! $COMPTON_RUNNING; then fi
rm $HOME/.config/disable-compton
compton-launcher # Zenity is summoned to interact with the user.
# The XOR with the "exit 0" means that the script
#A message is displayed if the user decides to run a program that is already running # will exit with no error if zenity is "canceled"
elif [[ $ans = "$COMPTON_ENABLED" ]] && $COMPTON_RUNNING; then # (user clicking on the "cancel" button, for
zenity --info \ # instance).
--text="$INFO" ans=$(zenity --list --hide-header\
--title "$TITLE"\
else --text "$TEXT"\
killall compton --radiolist\
touch $HOME/.config/disable-compton --column "" --column ""\
$COMPTON "$COMPTON_ENABLED"\
$DISCOMPTON "$COMPTON_DISABLED" || exit 0)
# Evaluate if compton is runnning or not, if it does,
# warn the user if he/she tries to run compton again
# or disable the compositor if he/she select to disable
# it. If compton is not running, run and enable it if
# the user selects to do so:
# .-----------------.
# | |
# | |
# | Compton running |
# | |
# | |
# '-----------------'
# |
# | .-----------------. .-----------------.
# |-->| User selects no |-->| Disable compton |
# | '-----------------' '-----------------'
# | .------------------. .-----------------.
# '-->| User selects yes |->| Inform the user |
# '------------------' '-----------------'
# .---------------------.
# | |
# | |
# | Compton not running |
# | |
# | |
# '---------------------'
# |
# | .-----------------. .------------.
# |-->| User selects no |-->| Do nothing |
# | '-----------------' '------------'
# | .------------------. .-----------------.
# '-->| User selects yes |-->| Enable compton |
# '------------------' '-----------------'
if $COMPTON_RUNNING # Compton running
then
if [[ $ans == $COMPTON_DISABLED ]]; then
touch $HOME/.config/disable-compton
killall compton
elif [[ $ans == $COMPTON_ENABLED ]]; then
zenity --info --text="$INFO"
fi
else # Compton not running
if [[ $ans == $COMPTON_ENABLED ]]; then
rm -f $HOME/.config/disable-compton
compton-launcher
else
exit 0
fi
fi fi
\ No newline at end of file
...@@ -18,7 +18,7 @@ ...@@ -18,7 +18,7 @@
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
# #
VERSION=6 VERSION=7
. ./config . ./config
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment