From 077dcb0dd3a8a67126d2d1adef615fd99348ca28 Mon Sep 17 00:00:00 2001
From: Ruben Rodriguez <ruben@trisquel.info>
Date: Fri, 10 Apr 2020 14:23:30 -0400
Subject: [PATCH] Improvements to compton setup

---
 helpers/DATA/compton/compton-launcher         |   9 --
 helpers/DATA/compton/compton.conf             |  14 +--
 .../DATA/compton/trisquel-compton-switcher    | 113 ------------------
 helpers/make-compton                          |  50 +-------
 helpers/make-mate-tweak                       |  12 +-
 5 files changed, 21 insertions(+), 177 deletions(-)
 delete mode 100644 helpers/DATA/compton/compton-launcher
 delete mode 100644 helpers/DATA/compton/trisquel-compton-switcher

diff --git a/helpers/DATA/compton/compton-launcher b/helpers/DATA/compton/compton-launcher
deleted file mode 100644
index 59a9a033..00000000
--- a/helpers/DATA/compton/compton-launcher
+++ /dev/null
@@ -1,9 +0,0 @@
-#!/bin/sh
-
-[ $DESKTOP_SESSION = "trisquel-session" ] || exit 0
-[ -f $HOME/.config/disable-compton ] && exit 0
-
-FILE=/etc/compton.conf
-[ -f $HOME/.config/compton.conf ] && FILE="$HOME/.config/compton.conf"
-
-[ 0 != $(glxinfo |grep "renderer string:" |grep -v llvmpipe | wc -c) ]  && exec compton --config $FILE &
diff --git a/helpers/DATA/compton/compton.conf b/helpers/DATA/compton/compton.conf
index af829b9d..de804984 100644
--- a/helpers/DATA/compton/compton.conf
+++ b/helpers/DATA/compton/compton.conf
@@ -62,11 +62,11 @@ no-dock-shadow = true;
 # Zero the part of the shadow's mask behind the window. Fix some weirdness with ARGB windows.
 clear-shadow = true;
 # The blur radius for shadows. (default 12)
-shadow-radius = 5;
+shadow-radius = 6;
 # The left offset for shadows. (default -15)
-shadow-offset-x = -8;
+shadow-offset-x = -9;
 # The top offset for shadows. (default -15)
-shadow-offset-y = -8;
+shadow-offset-y = -9;
 # The translucency for shadows. (default .75)
 shadow-opacity = 0.6;
 
@@ -79,8 +79,8 @@ shadow-opacity = 0.6;
 # (most applications are fine, only apps that do weird things with xshapes or argb are affected).
 # This list includes all the affected apps I found in my testing. The "! name~=''" part excludes shadows on any "Unknown" windows, this prevents a visual glitch with the XFWM alt tab switcher.
 shadow-exclude = [
-    "argb",
-    #"! name~=''",
+    "argb && ! window_type *= 'menu'",
+    "! name~=''",
     "name = 'Notification'",
     "name = 'Plank'",
     "name = 'Docky'",
@@ -112,7 +112,7 @@ shadow-ignore-shaped = false;
 #
 #################################
 
-menu-opacity = 0.95;
+menu-opacity = 1;
 inactive-opacity = 1;
 active-opacity = 1;
 frame-opacity = 1;
@@ -229,7 +229,7 @@ wintypes:
         # shadow: Give those windows shadow
         shadow = false;
         # opacity: Default opacity for the type of windows.
-        opacity = 0.85;
+        opacity = 1;
         # focus: Whether to always consider windows of this type focused.
         focus = true;
     };
diff --git a/helpers/DATA/compton/trisquel-compton-switcher b/helpers/DATA/compton/trisquel-compton-switcher
deleted file mode 100644
index 36baabe7..00000000
--- a/helpers/DATA/compton/trisquel-compton-switcher
+++ /dev/null
@@ -1,113 +0,0 @@
-#!/bin/bash
-
-
-DONT_SUPPORT_3D="Your machine does not support 3D acceleration"
-
-if [ $LANG = es_ES.UTF-8 ]; then
-    DONT_SUPPORT_3D="Su equipo no soporta aceleración 3D"
-fi
-
-# First, check if the computer
-# supports 3D acceleration. If not, it 
-# it informs the user and then exits.
-[ 0 = $(glxinfo |grep "renderer string:" |grep -v llvmpipe | wc -c) ] && zenity \
-    --info --text="$DONT_SUPPORT_3D" && exit 0
-
-# Check if compton is currently running.
-case "$(pgrep -u $USER compton | wc -w)" in
-
-    0)  COMPTON_RUNNING=false
-	;;
-    1)  COMPTON_RUNNING=true
-	;;
-esac
-
-
-if $COMPTON_RUNNING; then
-    COMPTON=true
-    DISCOMPTON=false
-
-elif ! $COMPTON_RUNNING; then
-    COMPTON=false
-    DISCOMPTON=true
-fi
-
-# The text that will be showed to the user.
-TEXT="Use Compton compositor if 3d acceleration available"
-TITLE="Choose between enabling or disabling Compton"
-COMPTON_ENABLED="Compton enabled"
-COMPTON_DISABLED="Compton disabled"
-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.
-if [ $LANG = es_ES.UTF-8 ]; then
-    TEXT="Usar el compositor Compton si el equipo soporta aceleración 3D"
-    TITLE="Seleccionar entre habilitar o deshabilitar los efectos de Compton"
-    COMPTON_ENABLED="Compton habilitado"
-    COMPTON_DISABLED="Compton deshabilitado"
-    INFO="Compton ya se encuentra en ejecución"
-fi
-
-# Zenity is summoned to interact with the user.
-# The XOR with the "exit 0" means that the script
-# will exit with no error if zenity is "canceled"
-# (user clicking on the "cancel" button, for
-# instance).
-ans=$(zenity --list --hide-header\
-    --title "$TITLE"\
-    --text "$TEXT"\
-    --radiolist\
-    --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
\ No newline at end of file
diff --git a/helpers/make-compton b/helpers/make-compton
index 3dd37d6b..4f37ae29 100644
--- a/helpers/make-compton
+++ b/helpers/make-compton
@@ -1,6 +1,6 @@
 #!/bin/sh
 #
-#    Copyright (C) 2011  Rubén Rodríguez <ruben@trisquel.info>
+#    Copyright (C) 2011-2020  Ruben Rodriguez <ruben@trisquel.info>
 #    Copyright (C) 2015  Francisco Javier Parra <franparpe@openmailbox.org>
 #
 #    This program is free software; you can redistribute it and/or modify
@@ -18,61 +18,17 @@
 #    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
 #
 
-VERSION=7
+VERSION=8
 
 . ./config
 
-rm debian/examples compton.sample.conf
-
 cat << EOF >> debian/install
-compton.conf /etc
-compton-autostart.desktop /etc/xdg/autostart
-compton-launcher /usr/bin
-trisquel-compton-switcher /usr/bin
-trisquel-compton-switcher.desktop /usr/share/applications
+compton.conf /etc/xdg
 EOF
 
 
 cp $DATA/compton.conf .
-cp $DATA/compton-launcher .
-cp $DATA/trisquel-compton-switcher .
-
-cat << EOF > compton-autostart.desktop
-[Desktop Entry]
-Type=Application
-Name=Compton composition manager
-Exec=compton-launcher
-NoDisplay=true
-X-GNOME-AutoRestart=true
-X-GNOME-Autostart-Phase=Initialization
-OnlyShowIn=GNOME;
-EOF
-
-cat << EOF > trisquel-compton-switcher.desktop
-[Desktop Entry]
-Name=Compton compositor switcher
-Comment=Allows to enable or disable Compton
-Exec=trisquel-compton-switcher
-Icon=checkbox
-Terminal=false
-Type=Application
-StartupNotify=true
-Categories=GNOME;Settings;DesktopSettings;
-OnlyShowIn=GNOME;
-Keywords=Compton;Compositing;Window manager;
-X-Ubuntu-Gettext-Domain=trisquel-compton-switcher
-
-Name[es]=Gestor del compositor Compton
-Comment[es]=Permite activar o desactivar Compton
-EOF
-
-sed 's/^Depends:/Depends: mesa-utils, /' debian/control* -i
-sed 's/^Depends:/Depends: zenity, /' debian/control* -i
-
-chmod 755 compton-launcher
-chmod 755 trisquel-compton-switcher
 
 changelog "Customized for Trisquel"
 
 compile
-
diff --git a/helpers/make-mate-tweak b/helpers/make-mate-tweak
index 828de02a..2ede639c 100644
--- a/helpers/make-mate-tweak
+++ b/helpers/make-mate-tweak
@@ -17,13 +17,23 @@
 #    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
 #
 
-VERSION=1
+VERSION=2
 
 . ./config
 
 sed -i 's/manjaro/trisquel/g' mate-tweak
 sed -i 's/Manjaro/Trisquel/g' mate-tweak
 
+# Disable composition on llvm
+sed '2a # Do not run without 3D acceleration\nglxinfo | grep "renderer string:" | grep -q llvmpipe && exit 0\n' -i marco-compton
+
+# Allow loading global compton config file
+sed '/config \/dev\/null/d' -i marco-compton
+
+# Shadow config
+sed 's/-r 10 -o 0.225 -l -12 -t -12/-r 6 -o 0.6 -l -9 -t -9/' -i marco-compton
+sed "s/_GTK_FRAME_EXTENTS@:c/argb \&\& ! window_type *= 'menu'/" -i marco-compton
+
 changelog "Add Trisquel as panel layout option"
 
 compile
-- 
GitLab