SHARE
TWEET

unlockme-main

a guest Apr 23rd, 2018 48 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #!/bin/bash
  2. #
  3. # UnlockMe: Customize, tweak and clean your system
  4. # https://github.com/ralphys/unlockme/
  5. #
  6. # Created by Ralphy Rhdez <rafaelrhd3z@gmail.com>
  7. # Website - https://unlockforus.com
  8. #
  9. # This program is free software; you can redistribute it and/or modify it under
  10. # the terms of the GNU General Public License as published by the Free Software
  11. # Foundation; either version 2, or (at your option) any later version.
  12. #
  13. # This program is distributed in the hope that it will be useful, but WITHOUT ANY
  14. # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
  15. # PARTICULAR PURPOSE.  See the GNU General Public License for more details.
  16. #
  17. # You should have received a copy of the GNU General Public License with your
  18. # system, in /usr/share/common-licenses/GPL-2.  If not, see
  19. # <http://www.gnu.org/licenses/>.
  20.  
  21. # UnlockMe version - none :)
  22. # Script name: unlockme-main
  23.  
  24. # locale
  25. export LANG=C
  26. export LANG=C.UTF-8
  27. export NO_AT_BRIDGE=1
  28.  
  29. # check for additional instances
  30. if pidof -o %PPID -x "unlockme-main" >/dev/null; then
  31.         zenity --info --title="Unclockme" --text="\nAnother Unlockme instance is already running." 2>/dev/null
  32.         exit 0
  33. fi
  34.  
  35. if [[ -f /tmp/unlockme-apps.lock || -f /tmp/unlockme-admin.lock ]];then
  36.   zenity --info --title="Unclockme" --text="\nAnother Unlockme instance is already running." 2>/dev/null
  37.   exit 0
  38. fi
  39.  
  40. # variable edition
  41. mintinfo="/etc/linuxmint/info"
  42. liteinfo="/etc/llver"
  43. ppminfo=$mintinfo
  44.  
  45. # desktop environment file
  46. unlockds="/tmp/.unlockds"
  47.  
  48. # desktop environment
  49. # linuxmint
  50. LMDENV=$(test -f "$mintinfo" && grep -F 'EDITION' "$mintinfo" | cut -d\" -f2 | awk '{print $1}')
  51. # linuxlite
  52. LLDENV=$(test -f "$liteinfo" && grep -F 'Lite' "$liteinfo" | awk '{print $2}')
  53. # peppermint
  54. PPMDENV=$(test -f "$ppminfo" && grep -F 'DESCRIPTION' "$ppminfo" | cut -d\" -f2)
  55.  
  56. # desktop users
  57. ALLUSERS=$(grep "/bin/bash" < /etc/passwd | grep "[1][0-9][0-9][0-9]" | cut -d: -f1)
  58.  
  59. # check requirements
  60. if [[ -z  "$(dpkg -l | grep -E '^ii' | grep '\syad\s')" ]] ||
  61.    [[ -z  "$(dpkg -l | grep -E '^ii' | grep '\sgit\s')" ]] ||
  62.    [[ -z  "$(dpkg -l | grep -E '^ii' | grep '\sapt-transport-https\s')" ]]; then
  63.  
  64.    zenity --question --icon-name="info" --window-icon="info" --width=340 --height=120 \
  65.           --ok-label="Proceed" --cancel-label="Cancel" --title=" Requirements Install" \
  66.           --text="\nThe following requirements will be downloaded and installed as needed:\n
  67. • apt-transport-https
  68. • autoconf
  69. • automake
  70. • curl
  71. • git
  72. • pkg-config
  73. • yad" 2>/dev/null
  74.  
  75. if [[ "$?" != "0" ]]; then exit 0; else :; fi
  76.   bash unlock-req-install
  77.   if [[ "$?" != "0" ]]; then exit 0; else :; fi
  78. fi
  79.  
  80. # start splash
  81. yad --width="340" --height="110" --info --center --skip-taskbar --undecorated --no-buttons --timeout="1" --text-align=center \
  82.                   --text='\n\n\n<span font="14">Getting Ready</span>\n<span font="11"> \n  please wait...\n</span>' &
  83.  
  84. # linuxlite specific | failsafe not to use default linuxlite yad package
  85. if [[ "$LLDENV" == "Lite" ]]; then grep -q "yad" < /etc/apt/preferences
  86.    
  87.     if [[ "$?" != "0" ]]; then
  88.      bash unlock-req-install
  89.     fi
  90. fi
  91.  
  92. # function - clean up common files
  93. _CLEANUP() {
  94.   [[ -e "$TMPUSRFL" ]] && rm -f "$TMPUSRFL"
  95.   [[ -e "$unlockds" ]] && rm -f "$unlockds"         # desktop session file
  96. }
  97.  
  98. # function - remove browser profile
  99. removeBrowserProfile() {
  100.  
  101.   echo "#• Removing ${_BROWSERNAME} browser profile..." ; sleep .2
  102.   zenity --question --width="360" --window-icon="warning" --icon-name="gtk-dialog-warning" \
  103.          --title="Browser profile removal" \
  104.          --text="\nAre you sure you want to remove ${_BROWSERNAME} profile?\n\nThis action cannot be reverted." 2>/dev/null;
  105.  
  106.   if [[ "$?" = "0" ]]; then
  107.     rm -rf "$_BROWSERPROFILE"
  108.    
  109.     if [[ "${PIPESTATUS[0]}" != "0" ]]; then
  110.       echo "# Error..." ; sleep 1
  111.  
  112.       zenity --error --width="260" --height="80" --title=" Error" \
  113.              --text="\nAn error occurred while removing ${_BROWSERNAME} browser profile!" 2>/dev/null; return
  114.     fi
  115.     echo "#✔ ${_BROWSERNAME} browser profile removed." ; sleep 1.5
  116.   else
  117.     continue
  118.   fi
  119. }
  120.  
  121. # function - remove browser cache
  122. removeBrowserCache() {
  123.  
  124.   echo "#• Removing ${_BROWSERNAME} browser cache..." ; sleep 1
  125.     rm -rf "${_BROWSERCACHEDIR}"/*
  126.  
  127.     if [ "${PIPESTATUS[0]}" -ne "0" ]; then echo "# Error..." && sleep 1
  128.       zenity --error --width="260" --height="80" --title=" Error" \
  129.              --text="\nAn error occurred while removing ${_BROWSERNAME} browser cache!" 2>/dev/null; return
  130.     fi
  131.   echo "#✔ ${_BROWSERNAME} browser cache cleared." ; sleep 1
  132. }
  133.  
  134. # Autoclean module check
  135. _DRYAPT="${HOME}/.local/share/.dryapt"
  136. _NOWDT=$(date "+%Y-%m-%d %H")
  137. _CHKMD=$(stat "$_DRYAPT" 2>/dev/null | grep 'Change' | awk '{print $2,$3}' | cut -c 1-13)
  138. _CHKMDAPT=$(tail -n+2 < ${_DRYAPT})
  139. if [[ -f "$_DRYAPT" ]] && [[ "$(head -n+1 < ${_DRYAPT})" > 0 ]]; then :
  140. elif [[ -f "$_DRYAPT" ]] && [[ "$(head -n+1 < ${_DRYAPT})" = 0 ]]; then
  141.   if [[ "$_CHKMD" == "$_CHKMDAPT" ]]; then :; fi
  142.   if [[ "$_CHKMDAPT" != "$_NOWDT" ]]; then bash -c "/usr/local/sbin/dryapt" & fi
  143. else bash -c "/usr/local/sbin/dryapt" &
  144. fi
  145.  
  146. BLOCKHOSTS() {
  147.   echo "# Blacklist Generator..."
  148.   bash blockhosts
  149. }
  150.  
  151. # compton compositor
  152. COMPTONWC() {
  153.  
  154. export _FNAME="Compton Compositor"
  155. AUTOSTART="/home/${_SOFTUSR}/.config/autostart/compton.desktop"
  156. echo "#• Getting ${_FNAME} status..." ; sleep .5
  157.  
  158. # dialog icon
  159. ICON="${THEME:1:-1}wmtweaks"
  160. export ICONSAVE="${THEME:1:-1}gtk-save"
  161. export ICONREST="${THEME:1:-1}reload"
  162. # set app icon variable
  163. export THEME=$(xfconf-query -c xsettings -p /Net/IconThemeName)
  164.  
  165.         showActProgress() {
  166.  
  167.         yad --text-align="center" --borders="10" --no-buttons --undecorated \
  168.             --fixed --progress --pulsate --auto-close --auto-kill \
  169.             --skip-taskbar --center --width="340" --height="110" \
  170.             --text="\n<span font='13'>UnlockMe</span>"
  171.         }
  172.  
  173.         export -f showActProgress
  174.  
  175.         componentInstall() {
  176.  
  177.         if zenity --question --width="320" --height="110" --title="Missing component" \
  178.                   --text="\nCompton Compositor is already installed but the Settings Editor component is missing.\n\n\
  179. Would you like to install it now?" 2>/dev/null; then
  180.  
  181.           # elevate for compton-conf installation
  182.           bash -c "pkexec unlockme-admin COMPTONCONFINST"
  183.      
  184.           if [[ "${PIPESTATUS[@]}" = "126" ]]; then
  185.             break
  186.           else
  187.             if [[ "$?" = "1" ]]; then
  188.               if [[ -z  "$(dpkg -l | grep -E '^ii' | grep -F ' compton-conf ')" ]]; then
  189.                 zenity --warning --width="320" --height="110" --title="Missing component" \
  190.                        --text="\nCompton Settings Editor component is missing. You will not be able \
  191. to edit compton configuration from UI." 2>/dev/null
  192.                 :
  193.               fi
  194.             fi
  195.           fi
  196.         fi
  197.         }
  198.  
  199.         export -f componentInstall
  200.  
  201.         # function save configuration
  202.         saveConfig() {
  203.  
  204.           szSavePath=$(zenity --file-selection --title=" Save ${_FNAME} configuration" --width="550" --height="380" \
  205.                               --filename="${HOME}/compton.conf" --window-icon="$ICONSAVE" --file-filter='*.conf' \
  206.                               --file-filter='All files | *' --save --confirm-overwrite)
  207.           if [[ "$?" = "0" ]]; then
  208.             cp "${HOME}/.config/compton.conf" "$szSavePath"
  209.           fi
  210.         }
  211.  
  212.         export -f saveConfig
  213.  
  214.         # function restore configuration
  215.         restoreConfig() {
  216.  
  217.           szSavePath=$(zenity --file-selection --title=" Restore Compton configuration" --width="550" --height="380" \
  218.                               --filename="${HOME}/compton.conf" --window-icon="$_ICON" --file-filter='*.conf' \
  219.                               --file-filter='All files | *')
  220.           if [[ "$?" = "0" ]]; then
  221.             ( echo "# Importing configuration..."
  222.             cp -f "$szSavePath" "${HOME}/.config/compton.conf" ; sleep 2
  223.             echo "# Restarting ${_FNAME}..." ; sleep 1
  224.             killall -9 compton ; sleep 1
  225.             compton -b ; sleep 1 )| showActProgress
  226.           fi
  227.         }
  228.  
  229.         export -f restoreConfig
  230.  
  231.         # function restore configuration
  232.         defaultConfig() {
  233.  
  234.           ( echo "# Loading UnlockMe configuration..."
  235.             cp -f "/usr/share/unlockme/tools/compton.conf" "${HOME}/.config/compton.conf" ; sleep 2
  236.             echo "# Restarting ${_FNAME}..." ; sleep 1
  237.             killall -9 compton ; sleep 1
  238.             compton -b ; sleep 1 )| showActProgress
  239.         }
  240.  
  241.         export -f defaultConfig
  242.  
  243.         editComConfig() {
  244.  
  245.           if [[ -z "$(dpkg -l | grep -E '^ii' | grep -F ' compton-conf ')" ]]; then
  246.              componentInstall
  247.           fi
  248.  
  249.           origen="/home/${USER}/.config/compton.conf"
  250.           testmode="/tmp/.comptontestmode"
  251.           touch "$origen" "$testmode"
  252.  
  253.           compton-conf && wait
  254.  
  255.           if [[ "$origen" -nt "$testmode" ]]; then
  256.             killall -9 compton
  257.             compton -b
  258.           fi
  259.         }
  260.  
  261.         export -f editComConfig
  262.  
  263.         configOptions() {
  264.  
  265.         yad --form --width="140" --text-align="center" --window-icon="$ICON" --buttons-layout="center" --undecorated --skip-taskbar \
  266.             --image-on-top --title="$_FNAME" --text="<span font='12'>Compton Configuration</span>\n" --button="Close":1 --borders="20" \
  267.             --field=" Backup configuration        !"gtk-save":FBTN" "bash -c saveConfig" \
  268.             --field=" Restore from backup         !"gtk-open":FBTN" "bash -c restoreConfig" \
  269.             --field="  Use UnlockMe defaults    !"gtk-refresh":FBTN" "bash -c defaultConfig" \
  270.             --field=" Push current to all users!"gtk-copy":FBTN" 'bash -c "pkexec unlockme-admin COMPTONWCPUSH"' \
  271.             --field=" :LBL" ""
  272.         if [[ "$?" = "1" || "$?" = "252" ]]; then exit 0; fi
  273.  
  274.         }
  275.  
  276.         export -f configOptions
  277.  
  278. # the loop
  279. while (true); do
  280. echo "#• ${_FNAME}..."
  281.  
  282. XFWM4PROCESS4=$(xfconf-query -c xfwm4 -p /general/use_compositing -t bool)
  283.  
  284. # check if compton compositor is installed
  285. if [[ -z  "$(dpkg -l | grep -E '^ii' | grep -F ' compton ')" ]]; then
  286.  
  287.   # if not installed, prompt user for installation
  288.   if zenity --question --width="340" --height="80" --title=" $_APPNAME" \
  289.             --text="\nCompton is not available in your system.\nWould you like to install ${_FNAME}?" 2>/dev/null; then
  290.  
  291.     echo "#• Installing ${_FNAME}..." ; sleep 1
  292.  
  293.     # elevate for compton installation
  294.     bash -c "pkexec unlockme-admin COMPTONWCINST"
  295.       if [[ "${PIPESTATUS[@]}" = "126" ]]; then
  296.         break
  297.       else
  298.         if [[ "$?" = "1" ]]; then
  299.           if [[ -n  "$(dpkg -l | grep -E '^ii' | grep 'compton')" ]]; then
  300.             :
  301.           else
  302.             if [[ "$XFWM4PROCESS4" = "false" ]]; then
  303.               echo "#• Enabling xfwm4 compositing..."
  304.               xfconf-query -c xfwm4 -p /general/use_compositing -t bool -s true ; sleep 2
  305.             fi
  306.             break
  307.           fi
  308.         fi
  309.       fi
  310.  
  311.     sed -i 's/Hidden=.*/Hidden=false/' "$AUTOSTART"
  312.  
  313.     # disable xfwm4 compositing if enabled
  314.     if [[ "$XFWM4PROCESS4" = "true" ]]; then  
  315.       echo "#• Disabling xfwm4 compositing..." ; sleep 1
  316.       xfconf-query -c xfwm4 -p /general/use_compositing -t bool -s false ; sleep 1
  317.     fi
  318.     echo "#• Starting ${_FNAME}..." ; sleep 1 ; compton -b ; sleep .5
  319.   else
  320.       break
  321.   fi # exit on cancel
  322. else
  323.  
  324.   # ensure compton-conf is installed
  325.   if [[ -z "$(dpkg -l | grep -E '^ii' | grep -F ' compton-conf ')" ]]; then
  326.    
  327.     componentInstall
  328.   fi
  329.  
  330.   # if a compton.conf file doesn't exist, add it
  331.   [[ ! -f "/home/${USER}/.config/compton.conf" ]] && cp -f /usr/share/unlockme/tools/compton.conf "/home/${USER}/.config/"
  332.  
  333.   # check if compton is running and assign variables
  334.   [[ $(pgrep -f 'compton -b') ]] && _status="Enabled" COMPTONPROCESS="1" || _status="Disabled" COMPTONPROCESS=""
  335.   grep -qFx 'Hidden=false' "$AUTOSTART" && LOGONAUTO="will" || LOGONAUTO="<b>will not</b>"
  336.  
  337.   # compton Status
  338.   echo "# ${_FNAME}..."
  339.  
  340.   if [[ "$_status" = "Enabled" ]]; then
  341.  
  342.     MDTXT="\n<span font='Bold 10'>          Compton Status</span>: <span foreground='green'>${_status}</span>\n\n\
  343. *<span font='9'> ${_FNAME} is running\n\
  344. * ${_FNAME} ${LOGONAUTO} autostart on logon</span>\n\n\
  345. <b>Important</b>: No other display compositor must be enable while Compton is running. To enable the default display compositing in \
  346. <i>Settings >> Window Manager Tweaks >> Compositor | Enable display compositing</i>, you should first disable or uninstall Compton to prevent \
  347. display compositing conflicts.\n"
  348.     YBTN="Disable compton"
  349.     DLGSIZE="--width=480 --height=150"
  350.     COMPTON=$(yad ${DLGSIZE} --window-icon="$ICON" --image="$ICON" \
  351.                            --title="$_FNAME" --text="$MDTXT" --borders="8" \
  352.                            --button="Uninstall":2 \
  353.                            --button="...":'bash -c "configOptions"' \
  354.                            --button="Config!gtk-edit":'bash -c "editComConfig"' \
  355.                            --button="$YBTN"\!gtk-apply:0 ; echo $?)
  356.   else
  357.     MDTXT="\n<span font='Bold 10'>          Compton Status</span>: <span foreground='red'>${_status}</span>\n\n\
  358. *<span font='9'> ${_FNAME} is disabled\n\
  359. * ${_FNAME} ${LOGONAUTO} autostart on logon</span>\n"
  360.     YBTN="Enable compton"
  361.     DLGSIZE="--width=370 --height=150"
  362.     COMPTON=$(yad ${DLGSIZE} --window-icon="$ICON" --image="$ICON" --buttons-layout="center" \
  363.                            --title="$_FNAME" --text="$MDTXT" --borders="8" \
  364.                            --button="Uninstall":2 \
  365.                            --button="$YBTN"\!gtk-apply:0 ; echo $?)
  366.   fi
  367.  
  368.   # compton Main dialog
  369.  
  370.   case $COMPTON in
  371.     0)  if [[ "$_status" = "Enabled" ]]; then
  372.  
  373.             # stop compton
  374.             echo "#• Stopping ${_FNAME}..." ; sleep 1 ; killall -9 compton ; sleep .5
  375.  
  376.             # ensure compton autostart exists
  377.             [[ ! -f "$AUTOSTART" ]] && cp -f /usr/share/unlockme/tools/compton.desktop "$AUTOSTART"
  378.  
  379.             # disable compton autostart
  380.             sed -i 's/Hidden=.*/Hidden=true/' "$AUTOSTART"
  381.           else
  382.             echo "#• Starting ${_FNAME}..." ; sleep 1
  383.  
  384.             if [[ $(xfconf-query -c xfwm4 -p /general/use_compositing -t bool) = "true" ]]; then
  385.               echo "#• Disabling xfwm4 compositing..."
  386.               xfconf-query -c xfwm4 -p /general/use_compositing -t bool -s false ; sleep 2
  387.               echo "#• Enabling ${_FNAME}..." ; sleep 1
  388.             fi
  389.  
  390.             # start compton
  391.             compton -b ; sleep .5
  392.  
  393.             # ensure compton autostart exists
  394.             [[ ! -f "$AUTOSTART" ]] && cp -f /usr/share/unlockme/tools/compton.desktop "$AUTOSTART"
  395.  
  396.             # enable compton autostart
  397.             sed -i 's/Hidden=.*/Hidden=false/' "$AUTOSTART"
  398.         fi
  399.         ;;
  400.     #1)  return
  401.     #    ;;
  402.     2)  # Remove compton
  403.         if zenity --question --width="300" --title=" $_APPNAME" \
  404.                   --text="\nAre you sure you want to remove ${_FNAME}?" 2>/dev/null; then
  405.  
  406.           echo "#• Uninstalling ${_FNAME}..."
  407.  
  408.           # elevate for compton removal
  409.           bash -c "pkexec unlockme-admin COMPTONWCINST"
  410.             if [[ "${PIPESTATUS[@]}" = "126" ]]; then
  411.               continue
  412.             else
  413.               if [[ "$?" = "1" ]]; then
  414.                 if [[ -n  "$(dpkg -l | grep -E '^ii' | grep 'compton')" ]]; then
  415.                   continue
  416.                 else
  417.                   if [[ "$XFWM4PROCESS4" = "false" ]]; then
  418.                     echo "#• Enabling xfwm4 compositing..."
  419.                     xfconf-query -c xfwm4 -p /general/use_compositing -t bool -s true ; sleep 2
  420.                   fi
  421.                   break
  422.                 fi
  423.               fi
  424.             fi
  425.         else
  426.           continue
  427.         fi
  428.         ;;
  429.     *)  return ;;
  430.   esac
  431. fi
  432. done
  433. }
  434.  
  435. # function remove Chrome cache
  436. CHROMECACHE() {
  437.   _BROWSERNAME="Google Chrome" _BROWSERCACHEDIR="${HOME}/.cache/google-chrome/" ; removeBrowserCache
  438. }
  439.  
  440. # function remove Chrome profile
  441. CHROMEPROFILE() {
  442.   _BROWSERNAME="Google Chrome" _BROWSERPROFILE="${HOME}/.config/google-chrome/" ; removeBrowserProfile
  443. }
  444.  
  445. # function remove Chromium Cache
  446. CHROMIUMCACHE() {
  447.   _BROWSERNAME="Chromium" _BROWSERCACHEDIR="${HOME}/.cache/chromium/" ; removeBrowserCache
  448. }
  449.  
  450. # function remove Chromium profile
  451. CHROMIUMPROFILE() {
  452.   _BROWSERNAME="Chromium" _BROWSERPROFILE="${HOME}/.config/chromium/" ; removeBrowserProfile
  453. }
  454.  
  455. # function remove Firefox Cache
  456. FIREFOXCACHE() {
  457.  
  458.   _BROWSERNAME="Firefox"
  459.   echo "#• Looking up ${_BROWSERNAME} browser profiles..." ; sleep 1
  460.  
  461.   cd "${HOME}/.mozilla/firefox" && FFPRODIRS=$(grep 'Path' profiles.ini | cut -d\= -f2)
  462.  
  463.   for DIR in ${FFPRODIRS[@]}; do
  464.     FFCACHEDIR=$(grep 'browser.cache.disk.parent_directory' "${DIR}/prefs.js" | awk '{print $2}' | cut -d\" -f2 -)
  465.     if [[ -n  "$FFCACHEDIR" ]]; then
  466.       rm -rf "$FFCACHEDIR"/*
  467.       rm -rf "$DIR"/cache2/*
  468.     else
  469.       rm -rf "$DIR"/cache2/*
  470.     fi
  471.  done
  472.  
  473.   _BROWSERCACHEDIR="${HOME}/.cache/mozilla/firefox/" ; removeBrowserCache
  474. }
  475.  
  476. # function remove Firefox profile
  477. FFOXPROFILE() {
  478.   _BROWSERNAME="Firefox" _BROWSERPROFILE="${HOME}/.mozilla/firefox/" ; removeBrowserProfile
  479. }
  480.  
  481. # function fix dropbox | cinnamon
  482. FIXDBCIN() {
  483.   _LGFILE="/home/${_SOFTUSR}/.local/share/.fixdbcin"
  484.   _ASTF="/home/${_SOFTUSR}/.config/autostart/unlockme-dropbox.desktop"
  485.  
  486.   if [[ ! -f "$_LGFILE" ]]; then
  487.    # Fix dropbox autostart
  488.     echo "#• Updating Dropbox autostart..." && sleep 2
  489.     cp -f /usr/share/unlockme/tools/unlockme-dropbox.desktop "$_ASTF"
  490.     bash /usr/share/unlockme/tools/unlockme-dropbox.sh
  491.     touch "$_LGFILE" && echo "#✔ Dropbox autostart updated." && sleep 1.5
  492.   else
  493.     echo "#• Removing UnlockMe Dropbox autostart..." && sleep 2
  494.     rm -f "$_ASTF" "$_LGFILE"
  495.     echo "#✔ UnlockMe Dropbox autostart removed." && sleep 1.5
  496.   fi
  497. }
  498.  
  499. # function fix dropbox | xfce - budgie
  500. FIXDBXFCE() {
  501.  
  502.   stop_dropbox() {
  503.     dropbox stop ; [[ -n "$(pgrep dropbox)" ]] && killall -9 dropbox
  504.   }
  505.  
  506.   echo "#• Terminating dropbox instances..." && sleep 1 ; stop_dropbox
  507.  
  508.   # Fix dropbox autostart
  509.   echo "#• Fixing application autostart..." && sleep 1
  510.     _DBATFL="/home/${_SOFTUSR}/.config/autostart/dropbox.desktop"
  511.  
  512.   if [[ -f "$_DBATFL" ]]; then
  513.     sed -i 's/Exec=.*/Exec=dbus-launch dropbox start -i/g' "$_DBATFL"
  514.   else
  515.     echo "# Starting dropbox..." && sleep 1 ; stop_dropbox
  516.   fi
  517.  
  518.   echo "# ready..."
  519.   # Elevate privileges for required fix
  520.   FIXDPADM="FIXDBXFCE2" ; export FIXDPADM && pkexec unlockme-admin "$FIXDPADM"
  521.  
  522.   if [[ "${PIPESTATUS[0]}" != "0" ]]; then
  523.     echo "#• User aborted..." && sleep 1 ; continue
  524.   fi
  525.  
  526.   # Finally start dropbox
  527.   echo "#• Starting Dropbox..." && sleep 1
  528.   dbus-launch dropbox start -i
  529. }
  530.  
  531. # icon theme installer
  532. ICONTHEMESERIK() {
  533.   echo "# Icon Theme Installer"
  534.   bash icon-themes-erikdubois
  535. }
  536.  
  537. # function remove Midori Cache
  538. MIDORICACHE() {
  539.   _BROWSERNAME="Midori" _BROWSERCACHEDIR="${HOME}/.cache/midori/" ; removeBrowserCache
  540. }
  541.  
  542. # function remove Midori profile
  543. MIDORIPROFILE() {
  544.   _BROWSERNAME="Midori" _BROWSERPROFILE="${HOME}/.config/midori/" ; removeBrowserProfile
  545. }
  546.  
  547. # function remove Opera cache
  548. OPERACACHE() {
  549.   _BROWSERNAME="Opera" _BROWSERCACHEDIR="${HOME}/.cache/opera/Cache/" ; removeBrowserCache
  550. }
  551.  
  552. # function remove Opera profile
  553. OPERAPROFILE() {
  554.   _BROWSERNAME="Opera" _BROWSERPROFILE="${HOME}/.config/opera/" ; removeBrowserProfile
  555. }
  556.  
  557. # function remove Pale Moon cache
  558. PALEMOONCACHE() {
  559.   _BROWSERNAME="Pale Moon" _BROWSERCACHEDIR="${HOME}/.cache/moonchild productions/pale moon/" ; removeBrowserCache
  560. }
  561.  
  562. # function remove Pale Moon profile
  563. PALEMOONPROFILE() {
  564.   _BROWSERNAME="Pale Moon" _BROWSERPROFILE="${HOME}/.moonchild productions/" ; removeBrowserProfile
  565. }
  566.  
  567. # function remove SeaMonkey cache
  568. SEAMONKEYCACHE() {
  569.   _BROWSERNAME="SeaMonkey" _BROWSERCACHEDIR="${HOME}/.cache/mozilla/seamonkey/" ; removeBrowserCache
  570. }
  571.  
  572. # function remove SeaMonkey profile
  573. SEAMONKEYPROFILE() {
  574.   _BROWSERNAME="SeaMonkey" _BROWSERPROFILE="${HOME}/.mozilla/seamonkey/" ; removeBrowserProfile
  575. }
  576.  
  577. # function delete thumbnail cache
  578. THUMBNAILS() {
  579.   echo "#• Deleting Thumbnail Cache..." && sleep 1
  580.     rm -rf ${HOME}/.cache/thumbnails/*
  581.  
  582.     if [[ "${PIPESTATUS[0]}" != "0" ]]; then
  583.       echo "# Error..." && sleep 1
  584.       zenity --error --width="260" --height="80" --title=" Error" \
  585.              --text="\nAn error occurred while deleting Thumbnail Cache!" 2>/dev/null; return
  586.     fi
  587.   echo "#✔ Thumbnail Cache cleared." && sleep 1
  588. }
  589.  
  590. # function empty trash bin
  591. TRASHBIN() {
  592.   echo "#• Emptying the Trash bin..." && sleep 1
  593.     rm -rf ${HOME}/.local/share/Trash/files/*
  594.  
  595.     if [[ "${PIPESTATUS[0]}" != "0" ]]; then
  596.       echo "# Error..." && sleep 1
  597.      
  598.       zenity --error --width="260" --height="80" --title=" Error" \
  599.              --text="\nAn error occurred while emptying the Trash bin!" 2>/dev/null; return
  600.     fi
  601.   echo "#✔ Trash bin emptied." && sleep 1
  602. }
  603.  
  604. # function remove Vivaldi Cache
  605. VIVALDICACHE() {
  606.   _BROWSERNAME="Vivaldi" _BROWSERCACHEDIR="${HOME}/.cache/vivaldi/" ; removeBrowserCache
  607. }
  608.  
  609. # function remove Vivaldi profile
  610. VIVALDIPROFILE() {
  611.   _BROWSERNAME="Vivaldi" _BROWSERPROFILE="${HOME}/.config/vivaldi/" ; removeBrowserProfile
  612. }
  613.  
  614. # function remove Waterfox Cache
  615. WATERFOXCACHE() {
  616.   _BROWSERNAME="Waterfox" _BROWSERCACHEDIR="${HOME}/.cache/waterfox/" ; removeBrowserCache
  617. }
  618.  
  619. # function remove Waterfox profile
  620. WATERFOXPROFILE() {
  621.   _BROWSERNAME="Waterfox" _BROWSERPROFILE="${HOME}/.waterfox/" ; removeBrowserProfile
  622. }
  623.  
  624. # function whisker menu restore | linuxlite
  625. WHISKERMREST() {
  626.   _APPNAME="Whisker Menu Restore"
  627.   APP_ICON="${THEME:1:-1}xfce4-whiskermenu"
  628.   THEME=$(xfconf-query -c xsettings -p /Net/IconThemeName)
  629.   echo "# $_APPNAME..." & sleep .5
  630.  
  631.   copy_files() {
  632.    
  633.     # restore Linux Lite Custom menu
  634.     echo "#• Restoring Whisker menu files..." & sleep .8
  635.       cp -f /etc/skel/.config/menus/xfce-applications.menu ${HOME}/.config/menus/
  636.     echo "#✔ Whisker menu files restored." & sleep .5
  637.    
  638.     # restore Linux Lite Default application shortcuts
  639.     echo "#• Restoring Lite default application shortcuts..." & sleep .8
  640.       cp -rf /etc/skel/.local/share/applications/* ${HOME}/.local/share/applications/
  641.     echo "#✔ Lite default applications shortcuts restored." & sleep .5
  642.  
  643.     # restore whiskermenu
  644.     echo "#• Restoring Whisker menu..." & sleep .8
  645.       cp -f /etc/skel/.config/xfce4/panel/whiskermenu-1.rc ${HOME}/.config/xfce4/panel/
  646.     echo "#✔ Whisker menu restored." & sleep .5
  647.    
  648.     # allow removing items from the whisker menu
  649.     echo "#• Fixing Items removal from Whisker menu..." & sleep .8
  650.       sed -i 's!/etc/skel!~!g' ${HOME}/.config/menus/xfce-applications.menu
  651.     echo "#✔ Remove Items from Whisker menu fixed." & sleep .5
  652.   }
  653.  
  654.   restart_panel() {
  655.     echo "# Restarting the panel..." & sleep .8
  656.       dbus-send --print-reply --dest=org.xfce.Panel /org/xfce/Panel org.xfce.Panel.Terminate boolean:true >/dev/null 2>&1 && sleep 1
  657.     echo "#✔ Whisker Menu successfully restored." & sleep .8
  658.     continue
  659.   }
  660.  
  661.   # read Favorites items
  662.   _WMFILE="${HOME}/.config/xfce4/panel/whiskermenu-1.rc"
  663.   echo "#• Reading Favorites items..." & sleep .1
  664.   USER_FAVORITES=$(grep -F 'favorites=' $_WMFILE | head -n+1)
  665.  
  666.   # read Recent items
  667.   echo "#• Reading Recently Used items..." & sleep .1
  668.   USER_RECENT=$(grep -F 'recent=' $_WMFILE | head -n+1)
  669.  
  670.   # read Menu icon
  671.   echo "#• Reading Menu icon..." & sleep .1
  672.   USER_MICON=$(grep -F 'button-icon=' $_WMFILE | head -n+1)
  673.  
  674.   # read Menu title
  675.   echo "#• Reading Menu title..." & sleep .1
  676.   USER_MTITLE=$(grep -F 'button-title=' $_WMFILE | head -n+1)
  677.  
  678.   # read Menu item icon size
  679.   echo "#• Reading Item icon size..." & sleep .1
  680.   USER_MICSIZE=$(grep -F 'item-icon-size=' $_WMFILE | head -n+1)
  681.  
  682.   # read Menu categry icon size
  683.   echo "#• Reading Category icon size..." & sleep .1
  684.   USER_MCATSIZE=$(grep -F 'category-icon-size=' $_WMFILE | head -n+1)
  685.  
  686.   # read Menu hierarchy
  687.   echo "#• Reading menu hierarchy..." & sleep .1
  688.   USER_MHIERARCHY=$(grep -F 'load-hierarchy=' $_WMFILE)
  689.  
  690.   # read Menu opacity
  691.   echo "#• Reading menu opacity..." & sleep .1
  692.   USER_MOPACITY=$(grep -F 'menu-opacity=' $_WMFILE)
  693.  
  694.   # read Menu width and height
  695.   echo "#• Reading menu width and height..." & sleep .1
  696.   USER_MWIDTH=$(grep -F 'menu-width' $_WMFILE)
  697.   USER_MHEIGHT=$(grep -F 'menu-height' $_WMFILE)
  698.  
  699.  
  700.   echo "# $_APPNAME..."
  701.  
  702.   # read and save selections
  703.   if [[ ! -d "${HOME}/.config/UnlockMe" ]]; then
  704.     mkdir -p "${HOME}/.config/UnlockMe"
  705.   else :
  706.   fi
  707.  
  708.   LWMRFILE="${HOME}/.config/UnlockMe/LWMR"
  709.  
  710.   # Defaults FALSE
  711.   DEF_FALSE=(keep_favorites keep_recent keep_micsize keep_mcatsize keep_menu_icon keep_menu_title)
  712.  
  713.   for def_false in "${DEF_FALSE[@]}"; do
  714.     eval $def_false='"FALSE"'
  715.   done
  716.  
  717.   # Defaults TRUE
  718.   if [[ ! -f "$LWMRFILE" ]]; then
  719.  
  720.     DEF_TRUE=(keep_mhierarchy keep_opacity keep_wxhy)
  721.     for def_true in "${DEF_TRUE[@]}"; do
  722.       eval $def_true='"TRUE"'
  723.     done
  724.   fi
  725.   # Remember user selection
  726.   if [ -s "$LWMRFILE" ]; then cp -f "$LWMRFILE" "$LWMRFILE".bak; LWMR_EVAL=$(cat "$LWMRFILE" | sed 's/|/ /g')
  727.     for ksaved in $LWMR_EVAL; do eval $ksaved='"TRUE"'; done
  728.   fi
  729.  
  730.   # main dialog
  731.   OPT=$(yad --list --checklist --fixed --width="640" --height="440" --title="$_APPNAME" \
  732.             --window-icon=$APP_ICON --image=/usr/share/pixmaps/unlockme-wm.png --image-on-top \
  733.             --button="Cancel"\!gtk-cancel:1 --button="Proceed"\!gtk-apply:0 \
  734.             --text="<span font='11'>\n    Choose reset preferences from the options below:</span>\n" \
  735.             --column="Pick" --column="OPTS" --column="Items" --column="Description" \
  736.             --dclick-action= --no-selection --hide-column="2" --print-column="2" --wrap-width=370 \
  737.             "${keep_favorites}" "keep_favorites" "Favorites" "Help Manual and Install Updates will be restored. \
  738. All other items in your Favorites will be kept when this option is selected." \
  739.             "${keep_recent}" "keep_recent" "Recently Used" "Keep your current Recently Used items" \
  740.             "${keep_opacity}" "keep_opacity" "Background Opacity" "Keep your current Background Opacity preference" \
  741.             "${keep_mcatsize}" "keep_mcatsize" "Category icon size" "Keep your current Category icon size preference" \
  742.             "${keep_micsize}" "keep_micsize" "Item icon size" "Keep your current Item icon size preference" \
  743.             "${keep_mhierarchy}" "keep_mhierarchy" "Menu hierarchy" "Keep your current menu hierarchy preference" \
  744.             "${keep_menu_icon}" "keep_menu_icon" "Menu icon" "Keep your current Whisker menu icon" \
  745.             "${keep_menu_title}" "keep_menu_title" "Menu title" "Keep your current Whisker menu title" \
  746.             "${keep_wxhy}" "keep_wxhy" "Width and height" "Keep the menu's current width and height")
  747.  
  748.   if [[ "$?" -eq "1" || "$?" -eq "252" ]]; then
  749.     mv "$LWMRFILE".bak "$LWMRFILE"
  750.     echo "# User aborted..." ; sleep .5
  751.     return
  752.   fi
  753.  
  754.   # begin restore
  755.   echo "#• Restoring Whisker Menu files..."
  756.   copy_files
  757.  
  758.   # preserve favorites items
  759.   if [[ "$OPT" =~ "keep_favorites" ]]; then
  760.     echo "#✔ Updating user's Favorites items..." ; sleep .8
  761.     sed -i '1 c\'$USER_FAVORITES'' "$_WMFILE"
  762.   fi
  763.  
  764.   # preserve recently used items if selected
  765.   if [[ "$OPT" =~ "keep_recent" ]]; then
  766.     echo "#✔ Updating user's Recently Used items..." ; sleep .8
  767.     sed -i '2 c\'$USER_RECENT'' "$_WMFILE"
  768.   else
  769.     sed -i '2 c\recent=' "$_WMFILE"
  770.   fi
  771.  
  772.   # preserve current menu title if selected
  773.   if [[ "$OPT" =~ "keep_menu_title" ]]; then
  774.     sed -i "3 c\\$USER_MTITLE" "$_WMFILE"
  775.   fi
  776.  
  777.   # preserve menu icon if selected
  778.   if [[ "$OPT" =~ "keep_menu_icon" ]]; then
  779.     sed -i '4 c\'$USER_MICON'' "$_WMFILE"
  780.   fi
  781.  
  782.   # preserve item icon size if selected
  783.   if [[ "$OPT" =~ "keep_micsize" ]]; then
  784.     sed -i 's/item-icon-size=.*/'$USER_MICSIZE'/' "$_WMFILE"
  785.   fi
  786.  
  787.   # preserve category icon size if selected
  788.   if [[ "$OPT" =~ "keep_mcatsize" ]]; then
  789.     sed -i 's/category-icon-size=.*/'$USER_MCATSIZE'/' "$_WMFILE"
  790.   fi
  791.  
  792.   # Defaults
  793.   # menu hierarchy
  794.   if [[ "$OPT" =~ "keep_mhierarchy" ]]; then
  795.     sed -i 's/load-hierarchy=.*/'$USER_MHIERARCHY'/' "$_WMFILE"
  796.   fi
  797.  
  798.   # menu opacity
  799.   if [[ "$OPT" =~ "keep_opacity" ]]; then
  800.     sed -i 's/menu-opacity=.*/'$USER_MOPACITY'/' "$_WMFILE"
  801.   fi
  802.  
  803.   # menu width and height
  804.   if [[ "$OPT" =~ "keep_wxhy" ]]; then
  805.     sed -i 's/menu-width=.*/'$USER_MWIDTH'/' "$_WMFILE"
  806.     sed -i 's/menu-height=.*/'$USER_MHEIGHT'/' "$_WMFILE"
  807.   fi
  808.  
  809.   # do not keep anything
  810.   if [[ -z "$OPT" ]]; then
  811.     sed -i '2 c\recent=' "$_WMFILE"
  812.   fi
  813.   echo "$OPT" > "$LWMRFILE"
  814.   # restart panel for changes to take effect
  815.   restart_panel
  816. }
  817.  
  818. ICON="/usr/share/pixmaps/unlockme.png" # dialog window icon
  819.  
  820. ARRAYS() {
  821.  
  822. # Invoke arrays
  823. ARRAYA=()    # Array for non-admin tasks
  824. ARRAYB=()    # Array for admin tasks
  825.  
  826. # array A definitions
  827. ARRAYADEF=(BLOCKHOSTS CHROMECACHE CHROMEPROFILE CHROMIUMCACHE CHROMIUMPROFILE COMPTONWC FIREFOXCACHE FFOXPROFILE FIXDBCIN \
  828.            FIXDBXFCE ICONTHEMESERIK MIDORICACHE MIDORIPROFILE OPERACACHE OPERAPROFILE PALEMOONCACHE PALEMOONPROFILE \
  829.            PRELOAD SEAMONKEYCACHE SEAMONKEYPROFILE SYSSWAP THUMBNAILS TRASHBIN VIVALDICACHE \
  830.            VIVALDIPROFILE WATERFOXCACHE WATERFOXPROFILE WHISKERMREST ZRAM ZSWAP NULL)
  831.  
  832. # array B definitions
  833. ARRAYBDEF=(AUTOREMOVE BYPASSPSWADMPKEXEC DNSCACHE IPV6 MGMTSAVESESSION OPENASROOT_THUNAR OPENTERM_HERE THEMING SOFTINST LITECCMODS \
  834.            LOGARCHIVES LXTERMWINSIZE CHNAMEHOST PACKAGECACHE RESIDCONFIG SYSCACHEPR SAMBASVR NULL)
  835.  
  836. # Read selection into array
  837. readarray selection <$selection_temp
  838.  
  839.  SELECTRUN=${#selection[@]}
  840.  
  841. # construct arrays from user selection
  842. for (( i=0; i<${SELECTRUN}; i++ ))
  843.  do
  844.   grep -q "${selection[${i}]}" <<< "${ARRAYADEF[@]}" && ARRAYA+=("${selection[${i}]}")
  845.   grep -q "${selection[${i}]}" <<< "${ARRAYBDEF[@]}" && ARRAYB+=("${selection[${i}]}")
  846.  
  847.   # remove selections
  848.   # remove preload from array
  849.   if grep -q 'PRELOAD' <<< "${selection[${i}]}"; then
  850.  
  851.       # if kernel swappiness is set in /etc/sysctl.conf display info  
  852.       if [[ -n "$(grep -F 'vm.swappiness' /etc/sysctl.conf)" ]]; then
  853.  
  854.       # remove
  855.       REMOVE="PRELOAD"
  856.       ARRAYB=( "${ARRAYB[@]/$REMOVE}" )
  857.  
  858.         zenity --warning --width="380" --window-icon="info" --icon-name="info" \
  859.                --title="Custom kernel swappiness detected" \
  860.                --text="\nYou must reset Kernel Swappiness to defaults before enabling Preload. \
  861. \n\nPreload is an adaptive readahead daemon that prefetches files mapped by applications from the disk to reduce their startup time. \
  862. It already favors and makes use of the kernel page cache. \
  863. \n\nContrary to common online tweakguides advises, there should not be a custom vm.swappiness set in the system while also using Preload. \
  864. \n\nYou can reset Kernel Swappiness using UnlockMe App Kernel Swappiness tweak.\n" 2>/dev/null
  865.       else
  866.         ARRAYB+=('PRELOAD')
  867.       fi
  868.   fi
  869.  
  870.   # remove kernel swappiness from array
  871.   if grep -q 'SYSSWAP' <<< "${selection[${i}]}"; then
  872.    
  873.       # if preload is installed display info
  874.       if [[ -n "$(dpkg -l | grep -E '^ii' | grep '\spreload\s\s')" ]]; then
  875.  
  876.       # remove
  877.       REMOVE="SYSSWAP"
  878.       ARRAYB=( "${ARRAYB[@]/$REMOVE}" )
  879.  
  880.         zenity --warning --width="420" --title="preload daemon detected" --window-icon="info" --icon-name="info" \
  881.                --text="\nYou must remove Preload from the system before manually adjusting kernel swappiness. \
  882. \n\nPreload is an adaptive readahead daemon that prefetches files mapped by applications from the disk to reduce their startup time. \
  883. It already favors and makes use of the kernel page cache. \
  884. \n\nContrary to common online tweakguides advises, there should not be a custom vm.swappiness defined while also running Preload. \
  885. \nYou can remove Preload using UnlockMe App or by executing the following command from Terminal: \
  886. \n\n~$ <b>sudo apt-get remove preload -y</b> \n" 2>/dev/null
  887.       else
  888.         ARRAYB+=('SYSSWAP')  
  889.       fi
  890.   fi
  891.  
  892.   # remove zram from array
  893.   if grep -q 'ZRAM' <<< "${selection[${i}]}"; then
  894.    
  895.       # if zswap is installed display info
  896.       if [[ "$VARZSWAP" == "Y" || -n "$(grep 'zswap.enabled=1' /etc/default/grub)" ]]; then
  897.  
  898.         # remove
  899.         REMOVE="ZRAM"
  900.         ARRAYB=( "${ARRAYB[@]/$REMOVE}" )
  901.  
  902.         zenity --warning --width="340" --height="80" --title=" zSWAP detected" --window-icon="info" --icon-name="info" \
  903.                --text="\nZSWAP is currently enabled in your system. ZSWAP and ZRAM must not be enabled at the same time. \
  904. \n\nPlease disable ZSWAP before enabling ZRAM." 2>/dev/null
  905.       else
  906.         ARRAYB+=('ZRAM')
  907.       fi
  908.   fi
  909.  
  910.   # remove zswap from array
  911.   if grep -q 'ZSWAP' <<< "${selection[${i}]}"; then
  912.    
  913.     # check for pending restart
  914.     if [[ "$VARZSWAP" == "Y" && -z "$(grep 'zswap.enabled=1' /etc/default/grub)" ]] || [[ "$VARZSWAP" == "N" && -n "$(grep 'zswap.enabled=1' /etc/default/grub)" ]]; then
  915.      
  916.       # display restart pending message
  917.       zenity --question --width="360" --height="120" --title=" Pending Restart" \
  918.              --text="\nThe computer must be restarted for changes to take effect.\n\nWould you like to reboot now?" 2>/dev/null
  919.  
  920.       # restart if acknowledged  
  921.         if [[ "$?" = "0" ]]; then
  922.           systemctl reboot
  923.         else
  924.           continue
  925.         fi
  926.     fi
  927.  
  928.     # if zram is installed display info
  929.     if [[ "$VARZRAM" == "ii" ]]; then
  930.  
  931.       # remove
  932.       REMOVE="ZSWAP"
  933.       ARRAYB=( "${ARRAYB[@]/$REMOVE}" )
  934.  
  935.       zenity --warning --width="360" --height="80" --title=" zRAM detected" --window-icon="info" --icon-name="info" \
  936.              --text="\nzRAM is currently enabled in your system. zRAM and zSWAP must not be enabled at the same time.\n\n\
  937. Please disable zRAM before enabling zSWAP." 2>/dev/null
  938.     else
  939.       ARRAYB+=('ZSWAP')
  940.     fi
  941.   fi
  942. done
  943. }
  944.  
  945. RUN() {
  946. # Check if ARRAYA is empty. If empty, skip the execution
  947.  
  948. if [[ "${#ARRAYA[@]}" != "0" ]]; then
  949.  
  950.   printf '%s \n' "${ARRAYA[@]}"|
  951.   while read line; do
  952.     "$line" 2>/dev/null    # Execute functions one at a time
  953.     if [[ "$?" = "1" ]]; then
  954.       zenity --error --width="260" --title="UnlockMe" --text="An error occurred while executing:\n\n ${line}" 2>/dev/null
  955.       exit 1
  956.     fi
  957.     done | yad --width="340" --height="110" --text-align="center" --borders="10" --no-buttons --undecorated \
  958.                --fixed --center --skip-taskbar --progress --pulsate --auto-close --auto-kill \
  959.                --text="\n<span font='13'>UnlockMe</span>"        
  960. fi
  961.  
  962. # Check whether ARRAYB is empty and skip execution if so
  963. if [[ "${#ARRAYB[@]}" != "0" ]]; then
  964.    case $? in
  965.     0) pkexec unlockme-admin "${ARRAYB[@]}"
  966.   ;;
  967.     1) return
  968.   ;;
  969.   esac
  970. fi
  971. }
  972.  
  973. # Execute checks
  974. CHECK() {
  975.  
  976. VARZSWAP="$(< /sys/module/zswap/parameters/enabled)"                    # zswap variable
  977. VARZRAM="$(dpkg -l | grep -E '^ii' | grep zram-config | cut -d' ' -f1)" # zram variable
  978. FILEPKEXEC="/home/${_SOFTUSR}/.local/share/unlockme/ACTPKEXEC"          # pkexec.pkla file
  979. _CAFILE="${HOME}/.config/Thunar/uca.xml"                                # Custom Action file - xfce
  980.  
  981. # Manage Save Session
  982. if [[ "$LMDENV" =~ "Xfce" ]] || [[ "$LLDENV" =~ "Lite" ]]; then
  983.      _mgmtsavesession=(FALSE "MGMTSAVESESSION" "Manage Save Session" "Management" "System" "Enable or disable users ability of saving their session on logout")
  984. else _mgmtsavesession=()
  985. fi
  986.  
  987. # Check Autoremove packages
  988. if [[ -f "$_DRYAPT" ]] && [[ "$(head -n+1 < "$_DRYAPT")" -gt 0 ]]; then
  989.      _DRYAPTVAL=$(head -n+1 < "$_DRYAPT")
  990.      _autoremove=(FALSE "AUTOREMOVE" "Autoremove Packages" "Cleanup" "System" "You can remove ${_DRYAPTVAL} packages that are no longer necessary")
  991. else _autoremove=()
  992. fi
  993.  
  994. # Check for blockhosts
  995. if [[ -s /etc/NetworkManager/dnsmasq.d/blacklist ]]; then
  996.       blocked_count=$(wc -l /etc/NetworkManager/dnsmasq.d/blacklist | cut -d\/ -f1)
  997.      _blockhosts=(FALSE "BLOCKHOSTS" "Blacklist Generator" "Management" "System" "<span foreground='green'>${blocked_count} undesirable hosts blacklisted - (select to modify)</span>")
  998. else _blockhosts=(FALSE "BLOCKHOSTS" "Blacklist Generator" "Management" "System" "Block ads, adware, malware and tracking domains")
  999. fi
  1000.  
  1001. # Check for bypass pkexec password prompt
  1002. if [[ ! -f "/usr/share/unlockme/set/ACTPKEXEC" && ! -f "$FILEPKEXEC" ]]; then
  1003.      _bypasspswadmpkexec=(FALSE "BYPASSPSWADMPKEXEC" "pkexec Password Prompt" "Management" "System" "Bypass pkexec password prompt for admin accounts")
  1004. else _bypasspswadmpkexec=(FALSE "BYPASSPSWADMPKEXEC" "pkexec Password Prompt" "Management" "System" "<span foreground='green'>Bypass pkexec prompt for admins - (select to remove)</span>")
  1005. fi
  1006.  
  1007. # Check if the google-chrome browser cache exists
  1008. if [[ -d "${HOME}/.cache/google-chrome/" ]]; then
  1009.      GCCACHESIZE=$(du -sh "${HOME}/.cache/google-chrome/" | awk '{print $1"B"}')
  1010.      chromecache=(FALSE "CHROMECACHE" "Chrome Cache" "Cleanup" "User" "You can remove $GCCACHESIZE from your Chrome browser cache")
  1011. else chromecache=()
  1012. fi
  1013.  
  1014. # Check if google-chrome browser profile exists
  1015. if [[ -d "${HOME}/.config/google-chrome" ]]; then
  1016.      _chromeprofile=(FALSE "CHROMEPROFILE" " -- Chrome Profile" "Cleanup" "User" "<span foreground='chocolate'>Remove Chrome browser profile</span>")
  1017. else _chromeprofile=()
  1018. fi
  1019.  
  1020. # Check for chromium browser cache
  1021. if [[ -d "${HOME}/.cache/chromium/" && $(du -sb "${HOME}/.cache/chromium/" | cut -f1) -ge 1048576 ]]; then
  1022.      CHRCACHESIZE=$(du -sh "${HOME}/.cache/chromium/" | awk '{print $1"B"}')
  1023.      chromiumcache=(FALSE "CHROMIUMCACHE" "Chromium Cache" "Cleanup" "User" "You can remove $CHRCACHESIZE from your Chromium browser cache")
  1024. else chromiumcache=()
  1025. fi
  1026.  
  1027. # Check if chromium browser profile exists
  1028. if [[ -d "${HOME}/.config/chromium/" ]]; then
  1029.      _chromiumprofile=(FALSE "CHROMIUMPROFILE" " -- Chromium Profile" "Cleanup" "User" "<span foreground='chocolate'>Remove Chromium browser profile</span>")
  1030. else _chromiumprofile=()
  1031. fi
  1032.  
  1033. # check for compton compositor
  1034. if [[ "$LMDENV" = "Xfce" || "$LLDENV" = "Lite" || "$PPMDENV" =~ "PeppermintOS" ]]; then
  1035.   if [[ -z $(dpkg -l | grep -E '^ii' | grep 'compton') ]]; then
  1036.        _comptonwc=(FALSE "COMPTONWC" "Compton Compositor" "Compositing" "User" "Compton Compositor for beautiful tear free compositing")
  1037.   else _comptonwc=(FALSE "COMPTONWC" "Compton Compositor" "Compositing" "User" "<span foreground='green'>Compton Compositor is currently installed - (select to modify)</span>")
  1038.   fi
  1039. else  _comptonwc=()
  1040. fi
  1041.  
  1042. # Check for dns cache tweak
  1043. if [[ ! -f "/etc/NetworkManager/dnsmasq.d/cache" ]]; then
  1044.      _dnscache=(FALSE "DNSCACHE" "Enable DNS Cache" "Management" "System" "Enable DNS Cache")
  1045. else _dnscache=(FALSE "DNSCACHE" "DNS Cache" "Management" "System" "<span foreground='green'>DNS Cache Enabled - (select to modify)</span>")
  1046. fi
  1047.  
  1048. # check for dropbox Cinnamon Fix
  1049. if [[ "$LMDENV" =~ "Cinnamon" ]]; then
  1050.   if [[ -z "$(dpkg -l | grep -E '^ii' | grep '\s\sdropbox\s')" ]]; then _fixdpcin=()
  1051.   else
  1052.     if [[ ! -f "/home/$_SOFTUSR/.local/share/.fixdbcin" ]]; then
  1053.       _fixdpcin=(FALSE "FIXDBCIN" "Dropbox Startup Fix" "Repair" "User" "Fix Dropbox Autostart in Cinnamon")
  1054.       else _fixdpcin=(FALSE "FIXDBCIN" "Dropbox Startup Fix" "Repair" "User" "<span foreground='green'>Applied - (select to remove)</span>")
  1055.     fi
  1056.   fi
  1057. fi
  1058.  
  1059. # check for dropbox - Xfce|Budgie Fix
  1060. if [[ "$LMDENV" =~ "Xfce" ]] || [[ "$DESKTOP_SESSION" = "budgie-desktop" ]]; then
  1061.   if [[ "$LMDENV" =~ "Xfce" ]]; then
  1062.       applyfix="Xfce"
  1063.   else
  1064.     if [[ $(lsb_release -sc) = "xenial" ]] && [[ "$DESKTOP_SESSION" = "budgie-desktop" ]]; then
  1065.       applyfix="Budgie"
  1066.     fi
  1067.   fi  
  1068.   if [ -z  "$(dpkg -l | grep -E '^ii' | grep '\(\sdropbox\s\|nautilus-dropbox\)')" ]; then
  1069.       _fixdbxfce=()
  1070.   else
  1071.     if [ "$(grep -F 'Exec=dbus-launch' /usr/share/applications/dropbox.desktop)" ] && \
  1072.        [ "$(grep -F 'Exec=dbus-launch' /home/$_SOFTUSR/.config/autostart/dropbox.desktop)" ]; then
  1073.       _fixdbxfce=()
  1074.     else
  1075.       _fixdpxfce=(FALSE "FIXDBXFCE" "Dropbox Systray Fix" "Repair" "User" "Fix Dropbox System tray icon and menu - $applyfix ")
  1076.     fi
  1077.   fi
  1078. fi
  1079.  
  1080. # check for firefox browser cache
  1081. if [[ -d "${HOME}/.cache/mozilla/firefox" && $(du -sb "${HOME}/.cache/mozilla/firefox" | cut -f1) -ge 1048576 ]]; then
  1082.      FFCACHESIZE=$(du -sh "${HOME}/.cache/mozilla/firefox/" 2>&1 | awk '{print $1"B"}')
  1083.      firefoxcache=(FALSE "FIREFOXCACHE" "Firefox Cache" "Cleanup" "User" "You can remove $FFCACHESIZE from your Firefox browser cache")
  1084. else firefoxcache=()
  1085. fi
  1086.  
  1087. # Check if firefox browser profile exists
  1088. if [[ -d "${HOME}/.mozilla/firefox/" ]]; then
  1089.      _ffoxprofile=(FALSE "FFOXPROFILE" " -- Firefox Profile" "Cleanup" "User" "<span foreground='chocolate'>Remove Firefox browser profile</span>")
  1090. else _ffoxprofile=()
  1091. fi
  1092.  
  1093. # Check enable / disable IPv6 tweak
  1094. if [[ $(< /proc/sys/net/ipv6/conf/all/disable_ipv6) = "1" ]]; then
  1095.      _ipv6=(FALSE "IPV6" "Enable IPv6" "Management" "System" "<span foreground='green'>IPv6 has been disabled - Select to Enable IPv6</span>")
  1096. else _ipv6=(FALSE "IPV6" "Disable IPv6" "Management" "System" "Disable IPv6")
  1097. fi
  1098.  
  1099. # check for kernel cache pressure
  1100. if [[ $(< /proc/sys/vm/vfs_cache_pressure) != "100" ]]; then
  1101.      _syscachepr=(FALSE "SYSCACHEPR" "Kernel Cache Pressure" "Performance" "System" "<span foreground='green'>Custom kernel cache pressure applied - (select to modify)</span>")
  1102. else _syscachepr=(FALSE "SYSCACHEPR" "Kernel Cache Pressure" "Performance" "System" "Controls how the kernel reclaims memory used for caching")
  1103. fi
  1104.  
  1105. # check for kernel swappiness
  1106. if [[ $(< /proc/sys/vm/swappiness) = "60" ]]; then
  1107.   if which preload > /dev/null; then
  1108.        _sysswap=(FALSE "SYSSWAP" "Kernel Swappiness ¡¡" "" "" "Kernel setting that controls how often the swap file is used")
  1109.   else _sysswap=(FALSE "SYSSWAP" "Kernel Swappiness" "Performance" "System" "Kernel setting that controls how often the swap file is used")
  1110.   fi
  1111. else
  1112.        _sysswap=(FALSE "SYSSWAP" "Kernel Swappiness" "Performance" "System" "<span foreground='green'>Custom kernel swappiness applied - (select to modify)</span>")
  1113. fi
  1114.  
  1115. # check for lite-controlcenter modules
  1116. if [[ "$LLDENV" = "Lite" && -n "$(dpkg -l | grep -E '^ii' | grep '\s\slite-controlcenter\s')" ]] && \
  1117.    [[ -d /usr/share/litecc/modules/disabled && "$(ls -A /usr/share/litecc/modules/disabled)" ]]; then
  1118.        _liteccmodules=(FALSE "LITECCMODS" "Control Center modules" "Management" "System" "Enable UnlockMe modules in Linux Lite Control Center")
  1119.   else _liteccmodules=()
  1120. fi
  1121.  
  1122. # lxterminal geometry size | linuxlite specific
  1123. if [[ "$LLDENV" = "Lite" ]]; then
  1124.        _lxtermwinsize=(FALSE "LXTERMWINSIZE" "LXTerminal Geometry" "Management" "System" "Change default LXTerminal geometry in Linux Lite (system-wide)")
  1125.   else _lxtermwinsize=()
  1126. fi
  1127.  
  1128. # Check if  midori browser cache exists
  1129. if [[ -d  "${HOME}/.cache/midori/" ]]; then
  1130.      MDCACHESIZE=$(du -sh "${HOME}/.cache/midori/" | awk '{print $1"B"}')
  1131.      _midoricache=(FALSE "MIDORICACHE" "Midori Cache" "Cleanup" "User" "You can remove $MDCACHESIZE from your Midori browser cache")
  1132. else _midoricache=()
  1133. fi
  1134.  
  1135. # Check if midori browser profile exists
  1136. if [[ -d "${HOME}/.config/midori/" ]]; then
  1137.      _midoriprofile=(FALSE "MIDORIPROFILE" " -- Midori Profile" "Cleanup" "User" "<span foreground='chocolate'>Remove Midori browser profile</span>")
  1138. else _midoriprofile=()
  1139. fi
  1140.  
  1141. # Check if  opera browser cache exists
  1142. if [[ -d "${HOME}/.cache/opera/Cache/" ]]; then
  1143.      OPCACHESIZE=$(du -sh "${HOME}/.cache/opera/Cache/" | awk '{print $1"B"}')
  1144.      _operacache=(FALSE "OPERACACHE" "Opera Cache" "Cleanup" "User" "You can remove $OPCACHESIZE from your Opera browser cache")
  1145. else _operacache=()
  1146. fi
  1147.  
  1148. # Check if opera browser profile exists
  1149. if [[ -d "${HOME}/.config/opera/" ]]; then
  1150.      _operaprofile=(FALSE "OPERAPROFILE" " -- Opera Profile" "Cleanup" "User" "<span foreground='chocolate'>Remove Opera browser profile</span>")
  1151. else _operaprofile=()
  1152. fi
  1153.  
  1154. # Check if  Pale Moon browser cache exists
  1155. if [[ -d "${HOME}/.cache/moonchild productions/pale moon/" ]]; then
  1156.      PMCACHESIZE=$(du -sh "${HOME}/.cache/moonchild productions/pale moon/" | awk '{print $1"B"}')
  1157.      _palemooncache=(FALSE "PALEMOONCACHE" "Pale Moon Cache" "Cleanup" "User" "You can remove $PMCACHESIZE from your Pale Moon browser cache")
  1158. else _palemooncache=()
  1159. fi
  1160.  
  1161. # Check if Pale Moon browser profile exists
  1162. if [[ -d "${HOME}/.moonchild productions/" ]]; then
  1163.      _palemoonprofile=(FALSE "PALEMOONPROFILE" " -- Pale Moon Profile" "Cleanup" "User" "<span foreground='chocolate'>Remove Pale Moon browser profile</span>")
  1164. else _palemoonprofile=()
  1165. fi
  1166.  
  1167. # Check for Change Hostname
  1168. if [[ "$LMDENV" =~ "Cinnamon" ]]; then
  1169.      _chnamehost=(FALSE "CHNAMEHOST" "Hostname" "Change Hostname" "System" "Change the computer hostname. (Logout required)")
  1170. elif [[ "$LMDENV" =~ "Xfce" ]] || [[ "$LMDENV" =~ "MATE" ]] || [[ "$LLDENV" =~ "Lite" ]] ||
  1171.      [[ "$PPMDENV" =~ "PeppermintOS" ]] || [[ $DESKTOP_SESSION = 'budgie-desktop' ]]; then
  1172.      _chnamehost=(FALSE "CHNAMEHOST" "Hostname" "Change Hostname" "System" "Change the computer hostname. (no restart required)")
  1173. else _chnamehost=()
  1174. fi
  1175.  
  1176. # Check logs archives
  1177. if [[ "$(find /var/log -type f \( -iname \*.gz -o -iname \*.0 -o -iname \*.1 \) 2>/dev/null -maxdepth 100 -size +1k)" ]]; then
  1178.      LOGARCHIVESIZE=$(find /var/log -type f \( -iname \*.gz -o -iname \*.0 -o -iname \*.1 \) 2>/dev/null -exec du -csh '{}' + | tail -1 | awk '{print $1"B"}')
  1179.      _logarchives=(FALSE "LOGARCHIVES" "Log Archives" "Cleanup" "System" "You can remove $LOGARCHIVESIZE worth of archived logs")
  1180. else _logarchives=()
  1181. fi
  1182.  
  1183. # Check if any thumbnails exist
  1184. if [[ $(du -sk "${HOME}/.cache/thumbnails/" | awk '{print $1}') > 100 ]]; then
  1185.      THUMBCACHESIZE=$(du -sh "${HOME}"/.cache/thumbnails/ | awk '{print $1"B"}')
  1186.      _thumbn=(FALSE "THUMBNAILS" "Thumbnail Cache" "Cleanup" "User" "You can remove $THUMBCACHESIZE from your thumbnail cache")
  1187. else _thumbn=()
  1188. fi
  1189.  
  1190. # check for open as root - Thunar custom action
  1191. if which Thunar > /dev/null; then
  1192.   if [[ -n $(grep '<name>Open as' "$_CAFILE") && -n $(grep 'pkexec Thunar %F' "${_CAFILE}") ]]; then
  1193.     _openasroot_thunar=(FALSE "OPENASROOT_THUNAR" "pkexec Open as Root" "Custom Action" "User" "<span foreground='green'>Using pkexec to open folders in Thunar as Root (select to revert)</span>")
  1194.   else
  1195.     _openasroot_thunar=(FALSE "OPENASROOT_THUNAR" "pkexec Open as Root" "Custom Action" "User" "Use pkexec PolicyKit to open folders as Root in Thunar")
  1196.   fi
  1197. fi
  1198.  
  1199. # check for Open terminal Here - linuxlite specific
  1200. if [[ "$LLDENV" = "Lite" ]]; then
  1201.   _CHKFILE="/etc/skel/.config/Thunar/uca.xml"
  1202.   _CHKNEWL="<command>x-terminal-emulator -t &quot;Command Line&quot; --working-directory=%f"
  1203.   if [[ -n $(grep -F "$_CHKNEWL" "$_CHKFILE") && -n $(grep 'Open Terminal Here' "${_CHKFILE}") ]]; then
  1204.     _openterm_here=(FALSE "OPENTERM_HERE" "Open Terminal Here" "Custom Action" "User" "<span foreground='green'>Terminal opens in the selected folder (select to revert)</span>")
  1205.   else
  1206.     _openterm_here=(FALSE "OPENTERM_HERE" "Open Terminal Here" "Custom Action" "User" "Fixes custom action so that LXTerminal opens in the selected folder")
  1207.   fi
  1208. fi
  1209.  
  1210. # Check package cache
  1211. if [[ "$(find /var/cache/apt/archives/ -maxdepth 1 -size +100k)" ]]; then
  1212.      APTCACHESIZE=$(du -sh /var/cache/apt/archives/ 2>/dev/null | awk '{print $1"B"}')
  1213.      _packagecache=(FALSE "PACKAGECACHE" "Packages Cache" "Cleanup" "System" "You can remove $APTCACHESIZE worth of files from the packages cache")
  1214. else _packagecache=()
  1215. fi
  1216.  
  1217. # Check if preload is installed
  1218. if [[ -z "$(dpkg -l | grep -E '^ii' | grep '\spreload\s')" ]]; then
  1219.   if [[ -z "$(grep -F 'vm.swappiness' /etc/sysctl.conf)" ]];then
  1220.      _preload=(FALSE "PRELOAD" "Preload Apps" "Performance" "System" "Fetch commonly used apps into RAM for faster startup times")
  1221.    else
  1222.      _preload=(FALSE "PRELOAD" "Preload Apps ¡¡" "" "" "Fetch commonly used apps into RAM for faster startup times")
  1223.    fi
  1224. else _preload=(FALSE "PRELOAD" "Preload Apps" "Performance" "System" "<span foreground='green'>Preload is currently installed - (select to modify)</span>")
  1225. fi
  1226.  
  1227. # Check residual configuration files
  1228. if [[ -n "$(dpkg -l | grep '^rc')" ]]; then
  1229.      RESCONFIGQTY=$(dpkg -l | grep '^rc' | awk '{print $2}'| wc -w)
  1230.      _resconfig=(FALSE "RESIDCONFIG" "Residual Config Files" "Cleanup" "System" "There are $RESCONFIGQTY residual configuration files that can be removed")
  1231. else _resconfig=()
  1232. fi
  1233.  
  1234. # Check if the seamonkey browser cache exists
  1235. if [[ -d "${HOME}/.cache/mozilla/seamonkey/" ]]; then
  1236.      SMCACHESIZE=$(du -sh "${HOME}/.cache/mozilla/seamonkey/" | awk '{print $1"B"}')
  1237.      _seamonkeycache=(FALSE "SEAMONKEYCACHE" "SeaMonkey Cache" "Cleanup" "User" "You can remove $SMCACHESIZE from your SeaMonkey browser cache")
  1238. else _seamonkeycache=()
  1239. fi
  1240.  
  1241. # Check if seamonkey browser profile exists
  1242. if [[ -d "${HOME}/.mozilla/seamonkey/" ]]; then
  1243.      _seamonkeyprofile=(FALSE "SEAMONKEYPROFILE" " -- SeaMonkey Profile" "Cleanup" "User" "<span foreground='chocolate'>Remove SeaMonkey browser profile</span>")
  1244. else _seamonkeyprofile=()
  1245. fi
  1246.  
  1247. # Check the Trash
  1248. if [[ "$(ls -A "${HOME}/.local/share/Trash/files/")" ]]; then
  1249.      TRASHCACHESIZE=$(du -sh "${HOME}/.local/share/Trash/" | awk '{print $1"B"}')
  1250.      _trashbin=(FALSE "TRASHBIN" "Trash Bin" "Cleanup" "User" "You can remove $TRASHCACHESIZE from the Trash bin")
  1251. else _trashbin=()
  1252. fi
  1253.  
  1254. # Check vivaldi-stable cache
  1255. if [[ -d "${HOME}/.cache/vivaldi/" ]]; then
  1256.      VCSIZE=$(du -sh "${HOME}/.cache/vivaldi/" | awk '{print $1"B"}')
  1257.      _vivaldicache=(FALSE "VIVALDICACHE" "Vivaldi Cache" "Cleanup" "User" "You can remove $VCSIZE from your Vivaldi browser cache")
  1258. else _vivaldicache=()
  1259. fi
  1260.  
  1261. # Check if vivaldi browser profile exists
  1262. if [[ -d "${HOME}/.config/vivaldi" ]]; then
  1263.      _vivaldiprofile=(FALSE "VIVALDIPROFILE" " -- Vivaldi Profile" "Cleanup" "User" "<span foreground='chocolate'>Remove Vivaldi browser profile</span>")
  1264. else _vivaldiprofile=()
  1265. fi
  1266.  
  1267. # Check for zram
  1268. if [[ -z "$VARZRAM" ]]; then
  1269.   if [[ "$VARZSWAP" == "Y" ]] || [[ -n "$(grep 'zswap.enabled=1' /etc/default/grub)" ]]; then
  1270.      _zram=(FALSE "ZRAM" "zRAM ¡¡" "" "" "Compressed RAM based block device for faster I/O")
  1271.    else
  1272.      _zram=(FALSE "ZRAM" "zRAM" "Performance" "System" "Compressed RAM based block device for faster I/O")
  1273.    fi
  1274. else _zram=(FALSE "ZRAM" "zRAM" "Performance" "System" "<span foreground='green'>zRAM is currently installed - (select to modify)</span>")
  1275. fi
  1276.  
  1277. # Check for zswap
  1278. # check kernel for zswap
  1279. if [[ $(cat /boot/config-$(uname -r) | grep -i zswap | cut -d= -f2) == "y" ]]; then
  1280.   # if zswap is not enabled
  1281.   if [[ "$VARZSWAP" == "N" ]]; then
  1282.     # if zram is installed
  1283.     if [[ -n "$VARZRAM" ]]; then
  1284.        _zswap=(FALSE "ZSWAP" "zSWAP ¡¡" "" "" "Efficient use of RAM and disk based swap. Minimizes Disk I/O")
  1285.     else
  1286.         # if zswap is not enabled but grub value exists
  1287.         if [[ "$VARZSWAP" == "N" ]] && [[ -n "$(grep 'zswap.enabled=1' /etc/default/grub)" ]]; then
  1288.             _zswap=(FALSE "ZSWAP" "zSWAP <span foreground='red'>(Pending restart) ¡¡</span>" "" "" "Efficient use of RAM and disk based swap. Minimizes Disk I/O")
  1289.         else
  1290.           # zswap default
  1291.           _zswap=(FALSE "ZSWAP" "zSWAP" "Performance" "System" "Efficient use of RAM and disk based swap. Minimizes Disk I/O")
  1292.         fi
  1293.     fi
  1294.   else
  1295.       if [[ "$VARZSWAP" == "Y" ]] && [[ -z "$(grep 'zswap.enabled=1' /etc/default/grub)" ]]; then
  1296.        # pending reboot for removal
  1297.         _zswap=(FALSE "ZSWAP" "zSWAP <span foreground='red'>(Pending restart) ¡¡</span>" "Performance" "System" "<span foreground='green'>zSWAP is currently enabled - (select to modify)</span>")
  1298.       else
  1299.        # zswap installed
  1300.        _zswap=(FALSE "ZSWAP" "zSWAP" "Performance" "System" "<span foreground='green'>zSWAP is currently enabled - (select to modify)</span>")
  1301.      fi
  1302.   fi
  1303. fi
  1304.  
  1305. # Check if waterfox browser cache exists
  1306. if [[ -d "${HOME}/.cache/waterfox/" ]]; then
  1307.      WFCACHESIZE=$(du -sh "${HOME}/.cache/waterfox/"| awk '{print $1"B"}')
  1308.      _waterfoxcache=(FALSE "WATERFOXCACHE" "Waterfox Cache" "Cleanup" "User" "You can remove $WFCACHESIZE from your Waterfox browser cache")
  1309. else _waterfoxcache=()
  1310. fi
  1311.  
  1312. # Check if waterfox browser profile exists
  1313. if [[ -d "${HOME}/.waterfox" ]]; then
  1314.      _waterfoxprofile=(FALSE "WATERFOXPROFILE" " -- Waterfox Profile" "Cleanup" "User" "<span foreground='chocolate'>Remove Waterfox browser profile</span>")
  1315. else _waterfoxprofile=()
  1316. fi
  1317.  
  1318. # Whisker Menu Restore if Linux Lite
  1319. if [[ "$LLDENV" =~ "Lite" ]]; then
  1320.      _whiskermrest=(FALSE "WHISKERMREST" "Whisker Menu Restore" "Fix" "User" "Restore Linux Lite Whisker Menu defaults")
  1321. else _whiskermrest=()
  1322. fi
  1323.  
  1324. # Check for samba service -Linux Lite
  1325. if [[ "$LLDENV" = "Lite" ]]; then
  1326.   if [[ -n $(pgrep -f 'smbd') ]]; then
  1327.      _sambasrv=(FALSE "SAMBASVR" " -- Service: samba" "Performance" "System" "If not using this PC as a file server, this service can safely disabled")
  1328.   else _sambasrv=(FALSE "SAMBASVR" " -- Service: samba" "Performance" "System" "<span foreground='green'>Samba is disabled (select to enable samba)</span>")
  1329.   fi
  1330. fi
  1331. }
  1332.  
  1333. # Function that displays additional info in the second paned tab
  1334. function display_info() {
  1335.   # Formfeed character \f clears text info diaolg
  1336.   echo -e "\f" >$info_pipe
  1337.   case $2 in
  1338.    THEMING) echo "Install ralphy's selection of themes" >$info_pipe ;;
  1339.    SOFTINSTALL) echo "Install ralphy's selection of software" >$info_pipe ;;
  1340.    BLOCKHOSTS) echo "Block hosts" >$info_pipe ;;
  1341.    CHROMIUMCACHE) echo "Install ralphy's selection of software" >$info_pipe ;;
  1342.    *) echo "$2" >$info_pipe ;;
  1343.   esac
  1344.  
  1345.  
  1346. }
  1347. export -f display_info
  1348.  
  1349. # Main loop
  1350. while (true); do
  1351.  
  1352. _APPNAME="UnlockMe"
  1353. _SOFTUSR=$(whoami)
  1354. TMPUSRFL="/tmp/.unlockusr"
  1355.  
  1356. echo "$DESKTOP_SESSION" > "$unlockds" ; chmod 600 "$unlockds"
  1357. if [[ ! -f "$TMPUSRFL" ]]; then
  1358.   echo "$_SOFTUSR" > "$TMPUSRFL"
  1359.   chmod 600 "$TMPUSRFL"
  1360. else :
  1361. fi
  1362.  
  1363. # first run the checks
  1364. CHECK
  1365.  
  1366. # Main dialog os version
  1367. BITS=$(getconf LONG_BIT)
  1368.  
  1369. if [[ -f "$mintinfo" ]]; then
  1370.     # check if peppermint
  1371.     if [[ "$PPMDENV" =~ "PeppermintOS" ]]; then
  1372.       DISTRO="${PPMDENV} ${BITS}-bit"
  1373.     else
  1374.       # assume linuxmint
  1375.       DISTRO="$(grep -F 'GRUB' "$mintinfo" | cut -d\= -f2)"
  1376.     fi
  1377.  
  1378. # check if linuxlite
  1379. elif [[ -f "$liteinfo" ]]; then
  1380.   DISTRO="$(< "$liteinfo") ${BITS}-bit"
  1381.  
  1382. # check if ubuntu-budgie
  1383. elif grep -q 'Ubuntu' /etc/issue && [[ $DESKTOP_SESSION = 'budgie-desktop' ]]; then
  1384.   DISTRO="Ubuntu Budgie $(awk '{print $2,$3}' < /etc/issue | head -n1) ${BITS}-bit"
  1385.  
  1386. # check if ubuntu-mate
  1387. elif [[ $(uname -a | grep -F "ubuntu-mate" | awk '{print $2}') == 'ubuntu-mate' ]]; then
  1388.   DISTRO="Ubuntu MATE $(awk '{print $2,$3}' < /etc/issue | head -n1) ${BITS}-bit"
  1389.  
  1390. # others
  1391. else DISTRO="$(cut -d\\ -f1 < /etc/issue)"
  1392. fi
  1393.  
  1394. # Create a key for the plug dialog
  1395. unlockme_key="$(($RANDOM * $$))"
  1396.  
  1397. export info_pipe="$(mktemp -u /tmp/UnLockmE_XXXXX).$RANDOM-$$"
  1398. mkfifo -m 0600 "$info_pipe"
  1399.  
  1400. # temp file to export selection
  1401. export selection_temp="$(mktemp  /tmp/SeleXXXion_XXXXX_UnlockMe)"
  1402.  
  1403. # Trap to remove temp files
  1404. trap "rm -f $info_pipe $selection_temp" EXIT
  1405.  
  1406. exec 3<> $info_pipe
  1407.  
  1408. # main dialog
  1409. yad --plug="$unlockme_key" --tabnum=1 --list --checklist  --separator=" " \
  1410.                 --search-column="3" --image-on-top \
  1411.                 --column="Select" --column="SELECTION" --column="Name" --column="Task" \
  1412.                 --column="Category" --column="Description" --hide-column="2" --print-column=2 \
  1413.                 --select-action='bash -c "display_info %s"' \
  1414.                 --text="<span font='9'>${DISTRO}\n</span>
  1415. <span font='9'>Select the task(s) you wish to perform, then click the Begin button. Sort by clicking on the columns header.
  1416. You can select multiple tasks for sequential execution (Administrative privileges are required for some tasks).</span>" \
  1417. "FALSE" "THEMING" "Appearance" "Install or Remove" "System" "A selection of popular desktop themes, icons and cursors" \
  1418. "FALSE" "SOFTINST" "Application Software" "Install or Remove" "System" "Install and remove selected commonly used applications" \
  1419. "${_autoremove[@]}" \
  1420. "${_blockhosts[@]}" \
  1421. "${chromecache[@]}" \
  1422. "${chromiumcache[@]}" \
  1423. "${_comptonwc[@]}" \
  1424. "${_liteccmodules[@]}" \
  1425. "${_dnscache[@]}" \
  1426. "${_fixdpcin[@]}" \
  1427. "${_fixdpxfce[@]}" \
  1428. "${_ipv6[@]}" \
  1429. "${firefoxcache[@]}" \
  1430. "${_chnamehost[@]}" \
  1431. "FALSE" "ICONTHEMESERIK" "Icon Themes" "Install or Remove" "User" "Colorful icon themes collection for linux desktops by Erik Dubois" \
  1432. "${_syscachepr[@]}" \
  1433. "${_sysswap[@]}" \
  1434. "${_logarchives[@]}" \
  1435. "${_lxtermwinsize[@]}" \
  1436. "${_mgmtsavesession[@]}" \
  1437. "${_midoricache[@]}" \
  1438. "${_operacache[@]}" \
  1439. "${_palemooncache[@]}" \
  1440. "${_packagecache[@]}" \
  1441. "${_openasroot_thunar[@]}" \
  1442. "${_openterm_here[@]}" \
  1443. "${_bypasspswadmpkexec[@]}" \
  1444. "${_preload[@]}" \
  1445. "${_resconfig[@]}" \
  1446. "${_seamonkeycache[@]}" \
  1447. "${_thumbn[@]}" \
  1448. "${_trashbin[@]}" \
  1449. "${_vivaldicache[@]}" \
  1450. "${_waterfoxcache[@]}" \
  1451. "${_whiskermrest[@]}" \
  1452. "${_zram[@]}" \
  1453. "${_zswap[@]}" \
  1454. "${_chromeprofile[@]}" \
  1455. "${_chromiumprofile[@]}" \
  1456. "${_ffoxprofile[@]}" \
  1457. "${_midoriprofile[@]}" \
  1458. "${_operaprofile[@]}" \
  1459. "${_palemoonprofile[@]}" \
  1460. "${_seamonkeyprofile[@]}" \
  1461. "${_vivaldiprofile[@]}" \
  1462. "${_waterfoxprofile[@]}" \
  1463. "${_sambasrv[@]}" >$selection_temp &
  1464.  
  1465. yad --plug="$unlockme_key" --tabnum=2 --text "Info tab" --text-info <&3  &
  1466.  
  1467. yad --center --paned --key="$unlockme_key" --button="gtk-quit:1" --button=" Begin"\!gtk-apply:0 --width="880" --height="600" \
  1468.     --window-icon="$ICON" --image="$ICON" --title=" $_APPNAME" --orient=vert --splitter=450
  1469.  
  1470. if [[ "$?" = "1" || "$?" = "252" ]]; then _CLEANUP; exit 0 ; fi # If Quit or (X) is clicked then exit
  1471.  
  1472. grep -q '[a-zA-Z0-9]' "$selection_temp"
  1473.  
  1474. if [[ "$?" != "0" ]]; then
  1475.   zenity --info --ok-label="Go Back" --width="260" --height="80" --title=" $_APPNAME" \
  1476.          --text="\n<b>No tasks were selected for execution</b> \n\nPlease try again selecting a at least one task." 2>/dev/null
  1477.   continue
  1478. fi
  1479.  
  1480. ARRAYS # Separate selected items into arrays A and B
  1481. RUN
  1482. done
  1483. exit 0
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top