Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- #
- # UnlockMe: Customize, tweak and clean your system
- # https://github.com/ralphys/unlockme/
- #
- # Created by Ralphy Rhdez <rafaelrhd3z@gmail.com>
- # Website - https://unlockforus.com
- #
- # This program is free software; you can redistribute it and/or modify it under
- # the terms of the GNU General Public License as published by the Free Software
- # Foundation; either version 2, or (at your option) any later version.
- #
- # This program is distributed in the hope that it will be useful, but WITHOUT ANY
- # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
- # PARTICULAR PURPOSE. See the GNU General Public License for more details.
- #
- # You should have received a copy of the GNU General Public License with your
- # system, in /usr/share/common-licenses/GPL-2. If not, see
- # <http://www.gnu.org/licenses/>.
- # UnlockMe version - none :)
- # Script name: unlockme-main
- # locale
- export LANG=C
- export LANG=C.UTF-8
- export NO_AT_BRIDGE=1
- # check for additional instances
- if pidof -o %PPID -x "unlockme-main" >/dev/null; then
- zenity --info --title="Unclockme" --text="\nAnother Unlockme instance is already running." 2>/dev/null
- exit 0
- fi
- if [[ -f /tmp/unlockme-apps.lock || -f /tmp/unlockme-admin.lock ]];then
- zenity --info --title="Unclockme" --text="\nAnother Unlockme instance is already running." 2>/dev/null
- exit 0
- fi
- # variable edition
- mintinfo="/etc/linuxmint/info"
- liteinfo="/etc/llver"
- ppminfo=$mintinfo
- # desktop environment file
- unlockds="/tmp/.unlockds"
- # desktop environment
- # linuxmint
- LMDENV=$(test -f "$mintinfo" && grep -F 'EDITION' "$mintinfo" | cut -d\" -f2 | awk '{print $1}')
- # linuxlite
- LLDENV=$(test -f "$liteinfo" && grep -F 'Lite' "$liteinfo" | awk '{print $2}')
- # peppermint
- PPMDENV=$(test -f "$ppminfo" && grep -F 'DESCRIPTION' "$ppminfo" | cut -d\" -f2)
- # desktop users
- ALLUSERS=$(grep "/bin/bash" < /etc/passwd | grep "[1][0-9][0-9][0-9]" | cut -d: -f1)
- # check requirements
- if [[ -z "$(dpkg -l | grep -E '^ii' | grep '\syad\s')" ]] ||
- [[ -z "$(dpkg -l | grep -E '^ii' | grep '\sgit\s')" ]] ||
- [[ -z "$(dpkg -l | grep -E '^ii' | grep '\sapt-transport-https\s')" ]]; then
- zenity --question --icon-name="info" --window-icon="info" --width=340 --height=120 \
- --ok-label="Proceed" --cancel-label="Cancel" --title=" Requirements Install" \
- --text="\nThe following requirements will be downloaded and installed as needed:\n
- • apt-transport-https
- • autoconf
- • automake
- • curl
- • git
- • pkg-config
- • yad" 2>/dev/null
- if [[ "$?" != "0" ]]; then exit 0; else :; fi
- bash unlock-req-install
- if [[ "$?" != "0" ]]; then exit 0; else :; fi
- fi
- # start splash
- yad --width="340" --height="110" --info --center --skip-taskbar --undecorated --no-buttons --timeout="1" --text-align=center \
- --text='\n\n\n<span font="14">Getting Ready</span>\n<span font="11"> \n please wait...\n</span>' &
- # linuxlite specific | failsafe not to use default linuxlite yad package
- if [[ "$LLDENV" == "Lite" ]]; then grep -q "yad" < /etc/apt/preferences
- if [[ "$?" != "0" ]]; then
- bash unlock-req-install
- fi
- fi
- # function - clean up common files
- _CLEANUP() {
- [[ -e "$TMPUSRFL" ]] && rm -f "$TMPUSRFL"
- [[ -e "$unlockds" ]] && rm -f "$unlockds" # desktop session file
- }
- # function - remove browser profile
- removeBrowserProfile() {
- echo "#• Removing ${_BROWSERNAME} browser profile..." ; sleep .2
- zenity --question --width="360" --window-icon="warning" --icon-name="gtk-dialog-warning" \
- --title="Browser profile removal" \
- --text="\nAre you sure you want to remove ${_BROWSERNAME} profile?\n\nThis action cannot be reverted." 2>/dev/null;
- if [[ "$?" = "0" ]]; then
- rm -rf "$_BROWSERPROFILE"
- if [[ "${PIPESTATUS[0]}" != "0" ]]; then
- echo "# Error..." ; sleep 1
- zenity --error --width="260" --height="80" --title=" Error" \
- --text="\nAn error occurred while removing ${_BROWSERNAME} browser profile!" 2>/dev/null; return
- fi
- echo "#✔ ${_BROWSERNAME} browser profile removed." ; sleep 1.5
- else
- continue
- fi
- }
- # function - remove browser cache
- removeBrowserCache() {
- echo "#• Removing ${_BROWSERNAME} browser cache..." ; sleep 1
- rm -rf "${_BROWSERCACHEDIR}"/*
- if [ "${PIPESTATUS[0]}" -ne "0" ]; then echo "# Error..." && sleep 1
- zenity --error --width="260" --height="80" --title=" Error" \
- --text="\nAn error occurred while removing ${_BROWSERNAME} browser cache!" 2>/dev/null; return
- fi
- echo "#✔ ${_BROWSERNAME} browser cache cleared." ; sleep 1
- }
- # Autoclean module check
- _DRYAPT="${HOME}/.local/share/.dryapt"
- _NOWDT=$(date "+%Y-%m-%d %H")
- _CHKMD=$(stat "$_DRYAPT" 2>/dev/null | grep 'Change' | awk '{print $2,$3}' | cut -c 1-13)
- _CHKMDAPT=$(tail -n+2 < ${_DRYAPT})
- if [[ -f "$_DRYAPT" ]] && [[ "$(head -n+1 < ${_DRYAPT})" > 0 ]]; then :
- elif [[ -f "$_DRYAPT" ]] && [[ "$(head -n+1 < ${_DRYAPT})" = 0 ]]; then
- if [[ "$_CHKMD" == "$_CHKMDAPT" ]]; then :; fi
- if [[ "$_CHKMDAPT" != "$_NOWDT" ]]; then bash -c "/usr/local/sbin/dryapt" & fi
- else bash -c "/usr/local/sbin/dryapt" &
- fi
- BLOCKHOSTS() {
- echo "# Blacklist Generator..."
- bash blockhosts
- }
- # compton compositor
- COMPTONWC() {
- export _FNAME="Compton Compositor"
- AUTOSTART="/home/${_SOFTUSR}/.config/autostart/compton.desktop"
- echo "#• Getting ${_FNAME} status..." ; sleep .5
- # dialog icon
- ICON="${THEME:1:-1}wmtweaks"
- export ICONSAVE="${THEME:1:-1}gtk-save"
- export ICONREST="${THEME:1:-1}reload"
- # set app icon variable
- export THEME=$(xfconf-query -c xsettings -p /Net/IconThemeName)
- showActProgress() {
- yad --text-align="center" --borders="10" --no-buttons --undecorated \
- --fixed --progress --pulsate --auto-close --auto-kill \
- --skip-taskbar --center --width="340" --height="110" \
- --text="\n<span font='13'>UnlockMe</span>"
- }
- export -f showActProgress
- componentInstall() {
- if zenity --question --width="320" --height="110" --title="Missing component" \
- --text="\nCompton Compositor is already installed but the Settings Editor component is missing.\n\n\
- Would you like to install it now?" 2>/dev/null; then
- # elevate for compton-conf installation
- bash -c "pkexec unlockme-admin COMPTONCONFINST"
- if [[ "${PIPESTATUS[@]}" = "126" ]]; then
- break
- else
- if [[ "$?" = "1" ]]; then
- if [[ -z "$(dpkg -l | grep -E '^ii' | grep -F ' compton-conf ')" ]]; then
- zenity --warning --width="320" --height="110" --title="Missing component" \
- --text="\nCompton Settings Editor component is missing. You will not be able \
- to edit compton configuration from UI." 2>/dev/null
- :
- fi
- fi
- fi
- fi
- }
- export -f componentInstall
- # function save configuration
- saveConfig() {
- szSavePath=$(zenity --file-selection --title=" Save ${_FNAME} configuration" --width="550" --height="380" \
- --filename="${HOME}/compton.conf" --window-icon="$ICONSAVE" --file-filter='*.conf' \
- --file-filter='All files | *' --save --confirm-overwrite)
- if [[ "$?" = "0" ]]; then
- cp "${HOME}/.config/compton.conf" "$szSavePath"
- fi
- }
- export -f saveConfig
- # function restore configuration
- restoreConfig() {
- szSavePath=$(zenity --file-selection --title=" Restore Compton configuration" --width="550" --height="380" \
- --filename="${HOME}/compton.conf" --window-icon="$_ICON" --file-filter='*.conf' \
- --file-filter='All files | *')
- if [[ "$?" = "0" ]]; then
- ( echo "# Importing configuration..."
- cp -f "$szSavePath" "${HOME}/.config/compton.conf" ; sleep 2
- echo "# Restarting ${_FNAME}..." ; sleep 1
- killall -9 compton ; sleep 1
- compton -b ; sleep 1 )| showActProgress
- fi
- }
- export -f restoreConfig
- # function restore configuration
- defaultConfig() {
- ( echo "# Loading UnlockMe configuration..."
- cp -f "/usr/share/unlockme/tools/compton.conf" "${HOME}/.config/compton.conf" ; sleep 2
- echo "# Restarting ${_FNAME}..." ; sleep 1
- killall -9 compton ; sleep 1
- compton -b ; sleep 1 )| showActProgress
- }
- export -f defaultConfig
- editComConfig() {
- if [[ -z "$(dpkg -l | grep -E '^ii' | grep -F ' compton-conf ')" ]]; then
- componentInstall
- fi
- origen="/home/${USER}/.config/compton.conf"
- testmode="/tmp/.comptontestmode"
- touch "$origen" "$testmode"
- compton-conf && wait
- if [[ "$origen" -nt "$testmode" ]]; then
- killall -9 compton
- compton -b
- fi
- }
- export -f editComConfig
- configOptions() {
- yad --form --width="140" --text-align="center" --window-icon="$ICON" --buttons-layout="center" --undecorated --skip-taskbar \
- --image-on-top --title="$_FNAME" --text="<span font='12'>Compton Configuration</span>\n" --button="Close":1 --borders="20" \
- --field=" Backup configuration !"gtk-save":FBTN" "bash -c saveConfig" \
- --field=" Restore from backup !"gtk-open":FBTN" "bash -c restoreConfig" \
- --field=" Use UnlockMe defaults !"gtk-refresh":FBTN" "bash -c defaultConfig" \
- --field=" Push current to all users!"gtk-copy":FBTN" 'bash -c "pkexec unlockme-admin COMPTONWCPUSH"' \
- --field=" :LBL" ""
- if [[ "$?" = "1" || "$?" = "252" ]]; then exit 0; fi
- }
- export -f configOptions
- # the loop
- while (true); do
- echo "#• ${_FNAME}..."
- XFWM4PROCESS4=$(xfconf-query -c xfwm4 -p /general/use_compositing -t bool)
- # check if compton compositor is installed
- if [[ -z "$(dpkg -l | grep -E '^ii' | grep -F ' compton ')" ]]; then
- # if not installed, prompt user for installation
- if zenity --question --width="340" --height="80" --title=" $_APPNAME" \
- --text="\nCompton is not available in your system.\nWould you like to install ${_FNAME}?" 2>/dev/null; then
- echo "#• Installing ${_FNAME}..." ; sleep 1
- # elevate for compton installation
- bash -c "pkexec unlockme-admin COMPTONWCINST"
- if [[ "${PIPESTATUS[@]}" = "126" ]]; then
- break
- else
- if [[ "$?" = "1" ]]; then
- if [[ -n "$(dpkg -l | grep -E '^ii' | grep 'compton')" ]]; then
- :
- else
- if [[ "$XFWM4PROCESS4" = "false" ]]; then
- echo "#• Enabling xfwm4 compositing..."
- xfconf-query -c xfwm4 -p /general/use_compositing -t bool -s true ; sleep 2
- fi
- break
- fi
- fi
- fi
- sed -i 's/Hidden=.*/Hidden=false/' "$AUTOSTART"
- # disable xfwm4 compositing if enabled
- if [[ "$XFWM4PROCESS4" = "true" ]]; then
- echo "#• Disabling xfwm4 compositing..." ; sleep 1
- xfconf-query -c xfwm4 -p /general/use_compositing -t bool -s false ; sleep 1
- fi
- echo "#• Starting ${_FNAME}..." ; sleep 1 ; compton -b ; sleep .5
- else
- break
- fi # exit on cancel
- else
- # ensure compton-conf is installed
- if [[ -z "$(dpkg -l | grep -E '^ii' | grep -F ' compton-conf ')" ]]; then
- componentInstall
- fi
- # if a compton.conf file doesn't exist, add it
- [[ ! -f "/home/${USER}/.config/compton.conf" ]] && cp -f /usr/share/unlockme/tools/compton.conf "/home/${USER}/.config/"
- # check if compton is running and assign variables
- [[ $(pgrep -f 'compton -b') ]] && _status="Enabled" COMPTONPROCESS="1" || _status="Disabled" COMPTONPROCESS=""
- grep -qFx 'Hidden=false' "$AUTOSTART" && LOGONAUTO="will" || LOGONAUTO="<b>will not</b>"
- # compton Status
- echo "# ${_FNAME}..."
- if [[ "$_status" = "Enabled" ]]; then
- MDTXT="\n<span font='Bold 10'> Compton Status</span>: <span foreground='green'>${_status}</span>\n\n\
- *<span font='9'> ${_FNAME} is running\n\
- * ${_FNAME} ${LOGONAUTO} autostart on logon</span>\n\n\
- <b>Important</b>: No other display compositor must be enable while Compton is running. To enable the default display compositing in \
- <i>Settings >> Window Manager Tweaks >> Compositor | Enable display compositing</i>, you should first disable or uninstall Compton to prevent \
- display compositing conflicts.\n"
- YBTN="Disable compton"
- DLGSIZE="--width=480 --height=150"
- COMPTON=$(yad ${DLGSIZE} --window-icon="$ICON" --image="$ICON" \
- --title="$_FNAME" --text="$MDTXT" --borders="8" \
- --button="Uninstall":2 \
- --button="...":'bash -c "configOptions"' \
- --button="Config!gtk-edit":'bash -c "editComConfig"' \
- --button="$YBTN"\!gtk-apply:0 ; echo $?)
- else
- MDTXT="\n<span font='Bold 10'> Compton Status</span>: <span foreground='red'>${_status}</span>\n\n\
- *<span font='9'> ${_FNAME} is disabled\n\
- * ${_FNAME} ${LOGONAUTO} autostart on logon</span>\n"
- YBTN="Enable compton"
- DLGSIZE="--width=370 --height=150"
- COMPTON=$(yad ${DLGSIZE} --window-icon="$ICON" --image="$ICON" --buttons-layout="center" \
- --title="$_FNAME" --text="$MDTXT" --borders="8" \
- --button="Uninstall":2 \
- --button="$YBTN"\!gtk-apply:0 ; echo $?)
- fi
- # compton Main dialog
- case $COMPTON in
- 0) if [[ "$_status" = "Enabled" ]]; then
- # stop compton
- echo "#• Stopping ${_FNAME}..." ; sleep 1 ; killall -9 compton ; sleep .5
- # ensure compton autostart exists
- [[ ! -f "$AUTOSTART" ]] && cp -f /usr/share/unlockme/tools/compton.desktop "$AUTOSTART"
- # disable compton autostart
- sed -i 's/Hidden=.*/Hidden=true/' "$AUTOSTART"
- else
- echo "#• Starting ${_FNAME}..." ; sleep 1
- if [[ $(xfconf-query -c xfwm4 -p /general/use_compositing -t bool) = "true" ]]; then
- echo "#• Disabling xfwm4 compositing..."
- xfconf-query -c xfwm4 -p /general/use_compositing -t bool -s false ; sleep 2
- echo "#• Enabling ${_FNAME}..." ; sleep 1
- fi
- # start compton
- compton -b ; sleep .5
- # ensure compton autostart exists
- [[ ! -f "$AUTOSTART" ]] && cp -f /usr/share/unlockme/tools/compton.desktop "$AUTOSTART"
- # enable compton autostart
- sed -i 's/Hidden=.*/Hidden=false/' "$AUTOSTART"
- fi
- ;;
- #1) return
- # ;;
- 2) # Remove compton
- if zenity --question --width="300" --title=" $_APPNAME" \
- --text="\nAre you sure you want to remove ${_FNAME}?" 2>/dev/null; then
- echo "#• Uninstalling ${_FNAME}..."
- # elevate for compton removal
- bash -c "pkexec unlockme-admin COMPTONWCINST"
- if [[ "${PIPESTATUS[@]}" = "126" ]]; then
- continue
- else
- if [[ "$?" = "1" ]]; then
- if [[ -n "$(dpkg -l | grep -E '^ii' | grep 'compton')" ]]; then
- continue
- else
- if [[ "$XFWM4PROCESS4" = "false" ]]; then
- echo "#• Enabling xfwm4 compositing..."
- xfconf-query -c xfwm4 -p /general/use_compositing -t bool -s true ; sleep 2
- fi
- break
- fi
- fi
- fi
- else
- continue
- fi
- ;;
- *) return ;;
- esac
- fi
- done
- }
- # function remove Chrome cache
- CHROMECACHE() {
- _BROWSERNAME="Google Chrome" _BROWSERCACHEDIR="${HOME}/.cache/google-chrome/" ; removeBrowserCache
- }
- # function remove Chrome profile
- CHROMEPROFILE() {
- _BROWSERNAME="Google Chrome" _BROWSERPROFILE="${HOME}/.config/google-chrome/" ; removeBrowserProfile
- }
- # function remove Chromium Cache
- CHROMIUMCACHE() {
- _BROWSERNAME="Chromium" _BROWSERCACHEDIR="${HOME}/.cache/chromium/" ; removeBrowserCache
- }
- # function remove Chromium profile
- CHROMIUMPROFILE() {
- _BROWSERNAME="Chromium" _BROWSERPROFILE="${HOME}/.config/chromium/" ; removeBrowserProfile
- }
- # function remove Firefox Cache
- FIREFOXCACHE() {
- _BROWSERNAME="Firefox"
- echo "#• Looking up ${_BROWSERNAME} browser profiles..." ; sleep 1
- cd "${HOME}/.mozilla/firefox" && FFPRODIRS=$(grep 'Path' profiles.ini | cut -d\= -f2)
- for DIR in ${FFPRODIRS[@]}; do
- FFCACHEDIR=$(grep 'browser.cache.disk.parent_directory' "${DIR}/prefs.js" | awk '{print $2}' | cut -d\" -f2 -)
- if [[ -n "$FFCACHEDIR" ]]; then
- rm -rf "$FFCACHEDIR"/*
- rm -rf "$DIR"/cache2/*
- else
- rm -rf "$DIR"/cache2/*
- fi
- done
- _BROWSERCACHEDIR="${HOME}/.cache/mozilla/firefox/" ; removeBrowserCache
- }
- # function remove Firefox profile
- FFOXPROFILE() {
- _BROWSERNAME="Firefox" _BROWSERPROFILE="${HOME}/.mozilla/firefox/" ; removeBrowserProfile
- }
- # function fix dropbox | cinnamon
- FIXDBCIN() {
- _LGFILE="/home/${_SOFTUSR}/.local/share/.fixdbcin"
- _ASTF="/home/${_SOFTUSR}/.config/autostart/unlockme-dropbox.desktop"
- if [[ ! -f "$_LGFILE" ]]; then
- # Fix dropbox autostart
- echo "#• Updating Dropbox autostart..." && sleep 2
- cp -f /usr/share/unlockme/tools/unlockme-dropbox.desktop "$_ASTF"
- bash /usr/share/unlockme/tools/unlockme-dropbox.sh
- touch "$_LGFILE" && echo "#✔ Dropbox autostart updated." && sleep 1.5
- else
- echo "#• Removing UnlockMe Dropbox autostart..." && sleep 2
- rm -f "$_ASTF" "$_LGFILE"
- echo "#✔ UnlockMe Dropbox autostart removed." && sleep 1.5
- fi
- }
- # function fix dropbox | xfce - budgie
- FIXDBXFCE() {
- stop_dropbox() {
- dropbox stop ; [[ -n "$(pgrep dropbox)" ]] && killall -9 dropbox
- }
- echo "#• Terminating dropbox instances..." && sleep 1 ; stop_dropbox
- # Fix dropbox autostart
- echo "#• Fixing application autostart..." && sleep 1
- _DBATFL="/home/${_SOFTUSR}/.config/autostart/dropbox.desktop"
- if [[ -f "$_DBATFL" ]]; then
- sed -i 's/Exec=.*/Exec=dbus-launch dropbox start -i/g' "$_DBATFL"
- else
- echo "# Starting dropbox..." && sleep 1 ; stop_dropbox
- fi
- echo "# ready..."
- # Elevate privileges for required fix
- FIXDPADM="FIXDBXFCE2" ; export FIXDPADM && pkexec unlockme-admin "$FIXDPADM"
- if [[ "${PIPESTATUS[0]}" != "0" ]]; then
- echo "#• User aborted..." && sleep 1 ; continue
- fi
- # Finally start dropbox
- echo "#• Starting Dropbox..." && sleep 1
- dbus-launch dropbox start -i
- }
- # icon theme installer
- ICONTHEMESERIK() {
- echo "# Icon Theme Installer"
- bash icon-themes-erikdubois
- }
- # function remove Midori Cache
- MIDORICACHE() {
- _BROWSERNAME="Midori" _BROWSERCACHEDIR="${HOME}/.cache/midori/" ; removeBrowserCache
- }
- # function remove Midori profile
- MIDORIPROFILE() {
- _BROWSERNAME="Midori" _BROWSERPROFILE="${HOME}/.config/midori/" ; removeBrowserProfile
- }
- # function remove Opera cache
- OPERACACHE() {
- _BROWSERNAME="Opera" _BROWSERCACHEDIR="${HOME}/.cache/opera/Cache/" ; removeBrowserCache
- }
- # function remove Opera profile
- OPERAPROFILE() {
- _BROWSERNAME="Opera" _BROWSERPROFILE="${HOME}/.config/opera/" ; removeBrowserProfile
- }
- # function remove Pale Moon cache
- PALEMOONCACHE() {
- _BROWSERNAME="Pale Moon" _BROWSERCACHEDIR="${HOME}/.cache/moonchild productions/pale moon/" ; removeBrowserCache
- }
- # function remove Pale Moon profile
- PALEMOONPROFILE() {
- _BROWSERNAME="Pale Moon" _BROWSERPROFILE="${HOME}/.moonchild productions/" ; removeBrowserProfile
- }
- # function remove SeaMonkey cache
- SEAMONKEYCACHE() {
- _BROWSERNAME="SeaMonkey" _BROWSERCACHEDIR="${HOME}/.cache/mozilla/seamonkey/" ; removeBrowserCache
- }
- # function remove SeaMonkey profile
- SEAMONKEYPROFILE() {
- _BROWSERNAME="SeaMonkey" _BROWSERPROFILE="${HOME}/.mozilla/seamonkey/" ; removeBrowserProfile
- }
- # function delete thumbnail cache
- THUMBNAILS() {
- echo "#• Deleting Thumbnail Cache..." && sleep 1
- rm -rf ${HOME}/.cache/thumbnails/*
- if [[ "${PIPESTATUS[0]}" != "0" ]]; then
- echo "# Error..." && sleep 1
- zenity --error --width="260" --height="80" --title=" Error" \
- --text="\nAn error occurred while deleting Thumbnail Cache!" 2>/dev/null; return
- fi
- echo "#✔ Thumbnail Cache cleared." && sleep 1
- }
- # function empty trash bin
- TRASHBIN() {
- echo "#• Emptying the Trash bin..." && sleep 1
- rm -rf ${HOME}/.local/share/Trash/files/*
- if [[ "${PIPESTATUS[0]}" != "0" ]]; then
- echo "# Error..." && sleep 1
- zenity --error --width="260" --height="80" --title=" Error" \
- --text="\nAn error occurred while emptying the Trash bin!" 2>/dev/null; return
- fi
- echo "#✔ Trash bin emptied." && sleep 1
- }
- # function remove Vivaldi Cache
- VIVALDICACHE() {
- _BROWSERNAME="Vivaldi" _BROWSERCACHEDIR="${HOME}/.cache/vivaldi/" ; removeBrowserCache
- }
- # function remove Vivaldi profile
- VIVALDIPROFILE() {
- _BROWSERNAME="Vivaldi" _BROWSERPROFILE="${HOME}/.config/vivaldi/" ; removeBrowserProfile
- }
- # function remove Waterfox Cache
- WATERFOXCACHE() {
- _BROWSERNAME="Waterfox" _BROWSERCACHEDIR="${HOME}/.cache/waterfox/" ; removeBrowserCache
- }
- # function remove Waterfox profile
- WATERFOXPROFILE() {
- _BROWSERNAME="Waterfox" _BROWSERPROFILE="${HOME}/.waterfox/" ; removeBrowserProfile
- }
- # function whisker menu restore | linuxlite
- WHISKERMREST() {
- _APPNAME="Whisker Menu Restore"
- APP_ICON="${THEME:1:-1}xfce4-whiskermenu"
- THEME=$(xfconf-query -c xsettings -p /Net/IconThemeName)
- echo "# $_APPNAME..." & sleep .5
- copy_files() {
- # restore Linux Lite Custom menu
- echo "#• Restoring Whisker menu files..." & sleep .8
- cp -f /etc/skel/.config/menus/xfce-applications.menu ${HOME}/.config/menus/
- echo "#✔ Whisker menu files restored." & sleep .5
- # restore Linux Lite Default application shortcuts
- echo "#• Restoring Lite default application shortcuts..." & sleep .8
- cp -rf /etc/skel/.local/share/applications/* ${HOME}/.local/share/applications/
- echo "#✔ Lite default applications shortcuts restored." & sleep .5
- # restore whiskermenu
- echo "#• Restoring Whisker menu..." & sleep .8
- cp -f /etc/skel/.config/xfce4/panel/whiskermenu-1.rc ${HOME}/.config/xfce4/panel/
- echo "#✔ Whisker menu restored." & sleep .5
- # allow removing items from the whisker menu
- echo "#• Fixing Items removal from Whisker menu..." & sleep .8
- sed -i 's!/etc/skel!~!g' ${HOME}/.config/menus/xfce-applications.menu
- echo "#✔ Remove Items from Whisker menu fixed." & sleep .5
- }
- restart_panel() {
- echo "# Restarting the panel..." & sleep .8
- dbus-send --print-reply --dest=org.xfce.Panel /org/xfce/Panel org.xfce.Panel.Terminate boolean:true >/dev/null 2>&1 && sleep 1
- echo "#✔ Whisker Menu successfully restored." & sleep .8
- continue
- }
- # read Favorites items
- _WMFILE="${HOME}/.config/xfce4/panel/whiskermenu-1.rc"
- echo "#• Reading Favorites items..." & sleep .1
- USER_FAVORITES=$(grep -F 'favorites=' $_WMFILE | head -n+1)
- # read Recent items
- echo "#• Reading Recently Used items..." & sleep .1
- USER_RECENT=$(grep -F 'recent=' $_WMFILE | head -n+1)
- # read Menu icon
- echo "#• Reading Menu icon..." & sleep .1
- USER_MICON=$(grep -F 'button-icon=' $_WMFILE | head -n+1)
- # read Menu title
- echo "#• Reading Menu title..." & sleep .1
- USER_MTITLE=$(grep -F 'button-title=' $_WMFILE | head -n+1)
- # read Menu item icon size
- echo "#• Reading Item icon size..." & sleep .1
- USER_MICSIZE=$(grep -F 'item-icon-size=' $_WMFILE | head -n+1)
- # read Menu categry icon size
- echo "#• Reading Category icon size..." & sleep .1
- USER_MCATSIZE=$(grep -F 'category-icon-size=' $_WMFILE | head -n+1)
- # read Menu hierarchy
- echo "#• Reading menu hierarchy..." & sleep .1
- USER_MHIERARCHY=$(grep -F 'load-hierarchy=' $_WMFILE)
- # read Menu opacity
- echo "#• Reading menu opacity..." & sleep .1
- USER_MOPACITY=$(grep -F 'menu-opacity=' $_WMFILE)
- # read Menu width and height
- echo "#• Reading menu width and height..." & sleep .1
- USER_MWIDTH=$(grep -F 'menu-width' $_WMFILE)
- USER_MHEIGHT=$(grep -F 'menu-height' $_WMFILE)
- echo "# $_APPNAME..."
- # read and save selections
- if [[ ! -d "${HOME}/.config/UnlockMe" ]]; then
- mkdir -p "${HOME}/.config/UnlockMe"
- else :
- fi
- LWMRFILE="${HOME}/.config/UnlockMe/LWMR"
- # Defaults FALSE
- DEF_FALSE=(keep_favorites keep_recent keep_micsize keep_mcatsize keep_menu_icon keep_menu_title)
- for def_false in "${DEF_FALSE[@]}"; do
- eval $def_false='"FALSE"'
- done
- # Defaults TRUE
- if [[ ! -f "$LWMRFILE" ]]; then
- DEF_TRUE=(keep_mhierarchy keep_opacity keep_wxhy)
- for def_true in "${DEF_TRUE[@]}"; do
- eval $def_true='"TRUE"'
- done
- fi
- # Remember user selection
- if [ -s "$LWMRFILE" ]; then cp -f "$LWMRFILE" "$LWMRFILE".bak; LWMR_EVAL=$(cat "$LWMRFILE" | sed 's/|/ /g')
- for ksaved in $LWMR_EVAL; do eval $ksaved='"TRUE"'; done
- fi
- # main dialog
- OPT=$(yad --list --checklist --fixed --width="640" --height="440" --title="$_APPNAME" \
- --window-icon=$APP_ICON --image=/usr/share/pixmaps/unlockme-wm.png --image-on-top \
- --button="Cancel"\!gtk-cancel:1 --button="Proceed"\!gtk-apply:0 \
- --text="<span font='11'>\n Choose reset preferences from the options below:</span>\n" \
- --column="Pick" --column="OPTS" --column="Items" --column="Description" \
- --dclick-action= --no-selection --hide-column="2" --print-column="2" --wrap-width=370 \
- "${keep_favorites}" "keep_favorites" "Favorites" "Help Manual and Install Updates will be restored. \
- All other items in your Favorites will be kept when this option is selected." \
- "${keep_recent}" "keep_recent" "Recently Used" "Keep your current Recently Used items" \
- "${keep_opacity}" "keep_opacity" "Background Opacity" "Keep your current Background Opacity preference" \
- "${keep_mcatsize}" "keep_mcatsize" "Category icon size" "Keep your current Category icon size preference" \
- "${keep_micsize}" "keep_micsize" "Item icon size" "Keep your current Item icon size preference" \
- "${keep_mhierarchy}" "keep_mhierarchy" "Menu hierarchy" "Keep your current menu hierarchy preference" \
- "${keep_menu_icon}" "keep_menu_icon" "Menu icon" "Keep your current Whisker menu icon" \
- "${keep_menu_title}" "keep_menu_title" "Menu title" "Keep your current Whisker menu title" \
- "${keep_wxhy}" "keep_wxhy" "Width and height" "Keep the menu's current width and height")
- if [[ "$?" -eq "1" || "$?" -eq "252" ]]; then
- mv "$LWMRFILE".bak "$LWMRFILE"
- echo "# User aborted..." ; sleep .5
- return
- fi
- # begin restore
- echo "#• Restoring Whisker Menu files..."
- copy_files
- # preserve favorites items
- if [[ "$OPT" =~ "keep_favorites" ]]; then
- echo "#✔ Updating user's Favorites items..." ; sleep .8
- sed -i '1 c\'$USER_FAVORITES'' "$_WMFILE"
- fi
- # preserve recently used items if selected
- if [[ "$OPT" =~ "keep_recent" ]]; then
- echo "#✔ Updating user's Recently Used items..." ; sleep .8
- sed -i '2 c\'$USER_RECENT'' "$_WMFILE"
- else
- sed -i '2 c\recent=' "$_WMFILE"
- fi
- # preserve current menu title if selected
- if [[ "$OPT" =~ "keep_menu_title" ]]; then
- sed -i "3 c\\$USER_MTITLE" "$_WMFILE"
- fi
- # preserve menu icon if selected
- if [[ "$OPT" =~ "keep_menu_icon" ]]; then
- sed -i '4 c\'$USER_MICON'' "$_WMFILE"
- fi
- # preserve item icon size if selected
- if [[ "$OPT" =~ "keep_micsize" ]]; then
- sed -i 's/item-icon-size=.*/'$USER_MICSIZE'/' "$_WMFILE"
- fi
- # preserve category icon size if selected
- if [[ "$OPT" =~ "keep_mcatsize" ]]; then
- sed -i 's/category-icon-size=.*/'$USER_MCATSIZE'/' "$_WMFILE"
- fi
- # Defaults
- # menu hierarchy
- if [[ "$OPT" =~ "keep_mhierarchy" ]]; then
- sed -i 's/load-hierarchy=.*/'$USER_MHIERARCHY'/' "$_WMFILE"
- fi
- # menu opacity
- if [[ "$OPT" =~ "keep_opacity" ]]; then
- sed -i 's/menu-opacity=.*/'$USER_MOPACITY'/' "$_WMFILE"
- fi
- # menu width and height
- if [[ "$OPT" =~ "keep_wxhy" ]]; then
- sed -i 's/menu-width=.*/'$USER_MWIDTH'/' "$_WMFILE"
- sed -i 's/menu-height=.*/'$USER_MHEIGHT'/' "$_WMFILE"
- fi
- # do not keep anything
- if [[ -z "$OPT" ]]; then
- sed -i '2 c\recent=' "$_WMFILE"
- fi
- echo "$OPT" > "$LWMRFILE"
- # restart panel for changes to take effect
- restart_panel
- }
- ICON="/usr/share/pixmaps/unlockme.png" # dialog window icon
- ARRAYS() {
- # Invoke arrays
- ARRAYA=() # Array for non-admin tasks
- ARRAYB=() # Array for admin tasks
- # array A definitions
- ARRAYADEF=(BLOCKHOSTS CHROMECACHE CHROMEPROFILE CHROMIUMCACHE CHROMIUMPROFILE COMPTONWC FIREFOXCACHE FFOXPROFILE FIXDBCIN \
- FIXDBXFCE ICONTHEMESERIK MIDORICACHE MIDORIPROFILE OPERACACHE OPERAPROFILE PALEMOONCACHE PALEMOONPROFILE \
- PRELOAD SEAMONKEYCACHE SEAMONKEYPROFILE SYSSWAP THUMBNAILS TRASHBIN VIVALDICACHE \
- VIVALDIPROFILE WATERFOXCACHE WATERFOXPROFILE WHISKERMREST ZRAM ZSWAP NULL)
- # array B definitions
- ARRAYBDEF=(AUTOREMOVE BYPASSPSWADMPKEXEC DNSCACHE IPV6 MGMTSAVESESSION OPENASROOT_THUNAR OPENTERM_HERE THEMING SOFTINST LITECCMODS \
- LOGARCHIVES LXTERMWINSIZE CHNAMEHOST PACKAGECACHE RESIDCONFIG SYSCACHEPR SAMBASVR NULL)
- # Read selection into array
- readarray selection <$selection_temp
- SELECTRUN=${#selection[@]}
- # construct arrays from user selection
- for (( i=0; i<${SELECTRUN}; i++ ))
- do
- grep -q "${selection[${i}]}" <<< "${ARRAYADEF[@]}" && ARRAYA+=("${selection[${i}]}")
- grep -q "${selection[${i}]}" <<< "${ARRAYBDEF[@]}" && ARRAYB+=("${selection[${i}]}")
- # remove selections
- # remove preload from array
- if grep -q 'PRELOAD' <<< "${selection[${i}]}"; then
- # if kernel swappiness is set in /etc/sysctl.conf display info
- if [[ -n "$(grep -F 'vm.swappiness' /etc/sysctl.conf)" ]]; then
- # remove
- REMOVE="PRELOAD"
- ARRAYB=( "${ARRAYB[@]/$REMOVE}" )
- zenity --warning --width="380" --window-icon="info" --icon-name="info" \
- --title="Custom kernel swappiness detected" \
- --text="\nYou must reset Kernel Swappiness to defaults before enabling Preload. \
- \n\nPreload is an adaptive readahead daemon that prefetches files mapped by applications from the disk to reduce their startup time. \
- It already favors and makes use of the kernel page cache. \
- \n\nContrary to common online tweakguides advises, there should not be a custom vm.swappiness set in the system while also using Preload. \
- \n\nYou can reset Kernel Swappiness using UnlockMe App Kernel Swappiness tweak.\n" 2>/dev/null
- else
- ARRAYB+=('PRELOAD')
- fi
- fi
- # remove kernel swappiness from array
- if grep -q 'SYSSWAP' <<< "${selection[${i}]}"; then
- # if preload is installed display info
- if [[ -n "$(dpkg -l | grep -E '^ii' | grep '\spreload\s\s')" ]]; then
- # remove
- REMOVE="SYSSWAP"
- ARRAYB=( "${ARRAYB[@]/$REMOVE}" )
- zenity --warning --width="420" --title="preload daemon detected" --window-icon="info" --icon-name="info" \
- --text="\nYou must remove Preload from the system before manually adjusting kernel swappiness. \
- \n\nPreload is an adaptive readahead daemon that prefetches files mapped by applications from the disk to reduce their startup time. \
- It already favors and makes use of the kernel page cache. \
- \n\nContrary to common online tweakguides advises, there should not be a custom vm.swappiness defined while also running Preload. \
- \nYou can remove Preload using UnlockMe App or by executing the following command from Terminal: \
- \n\n~$ <b>sudo apt-get remove preload -y</b> \n" 2>/dev/null
- else
- ARRAYB+=('SYSSWAP')
- fi
- fi
- # remove zram from array
- if grep -q 'ZRAM' <<< "${selection[${i}]}"; then
- # if zswap is installed display info
- if [[ "$VARZSWAP" == "Y" || -n "$(grep 'zswap.enabled=1' /etc/default/grub)" ]]; then
- # remove
- REMOVE="ZRAM"
- ARRAYB=( "${ARRAYB[@]/$REMOVE}" )
- zenity --warning --width="340" --height="80" --title=" zSWAP detected" --window-icon="info" --icon-name="info" \
- --text="\nZSWAP is currently enabled in your system. ZSWAP and ZRAM must not be enabled at the same time. \
- \n\nPlease disable ZSWAP before enabling ZRAM." 2>/dev/null
- else
- ARRAYB+=('ZRAM')
- fi
- fi
- # remove zswap from array
- if grep -q 'ZSWAP' <<< "${selection[${i}]}"; then
- # check for pending restart
- if [[ "$VARZSWAP" == "Y" && -z "$(grep 'zswap.enabled=1' /etc/default/grub)" ]] || [[ "$VARZSWAP" == "N" && -n "$(grep 'zswap.enabled=1' /etc/default/grub)" ]]; then
- # display restart pending message
- zenity --question --width="360" --height="120" --title=" Pending Restart" \
- --text="\nThe computer must be restarted for changes to take effect.\n\nWould you like to reboot now?" 2>/dev/null
- # restart if acknowledged
- if [[ "$?" = "0" ]]; then
- systemctl reboot
- else
- continue
- fi
- fi
- # if zram is installed display info
- if [[ "$VARZRAM" == "ii" ]]; then
- # remove
- REMOVE="ZSWAP"
- ARRAYB=( "${ARRAYB[@]/$REMOVE}" )
- zenity --warning --width="360" --height="80" --title=" zRAM detected" --window-icon="info" --icon-name="info" \
- --text="\nzRAM is currently enabled in your system. zRAM and zSWAP must not be enabled at the same time.\n\n\
- Please disable zRAM before enabling zSWAP." 2>/dev/null
- else
- ARRAYB+=('ZSWAP')
- fi
- fi
- done
- }
- RUN() {
- # Check if ARRAYA is empty. If empty, skip the execution
- if [[ "${#ARRAYA[@]}" != "0" ]]; then
- printf '%s \n' "${ARRAYA[@]}"|
- while read line; do
- "$line" 2>/dev/null # Execute functions one at a time
- if [[ "$?" = "1" ]]; then
- zenity --error --width="260" --title="UnlockMe" --text="An error occurred while executing:\n\n ${line}" 2>/dev/null
- exit 1
- fi
- done | yad --width="340" --height="110" --text-align="center" --borders="10" --no-buttons --undecorated \
- --fixed --center --skip-taskbar --progress --pulsate --auto-close --auto-kill \
- --text="\n<span font='13'>UnlockMe</span>"
- fi
- # Check whether ARRAYB is empty and skip execution if so
- if [[ "${#ARRAYB[@]}" != "0" ]]; then
- case $? in
- 0) pkexec unlockme-admin "${ARRAYB[@]}"
- ;;
- 1) return
- ;;
- esac
- fi
- }
- # Execute checks
- CHECK() {
- VARZSWAP="$(< /sys/module/zswap/parameters/enabled)" # zswap variable
- VARZRAM="$(dpkg -l | grep -E '^ii' | grep zram-config | cut -d' ' -f1)" # zram variable
- FILEPKEXEC="/home/${_SOFTUSR}/.local/share/unlockme/ACTPKEXEC" # pkexec.pkla file
- _CAFILE="${HOME}/.config/Thunar/uca.xml" # Custom Action file - xfce
- # Manage Save Session
- if [[ "$LMDENV" =~ "Xfce" ]] || [[ "$LLDENV" =~ "Lite" ]]; then
- _mgmtsavesession=(FALSE "MGMTSAVESESSION" "Manage Save Session" "Management" "System" "Enable or disable users ability of saving their session on logout")
- else _mgmtsavesession=()
- fi
- # Check Autoremove packages
- if [[ -f "$_DRYAPT" ]] && [[ "$(head -n+1 < "$_DRYAPT")" -gt 0 ]]; then
- _DRYAPTVAL=$(head -n+1 < "$_DRYAPT")
- _autoremove=(FALSE "AUTOREMOVE" "Autoremove Packages" "Cleanup" "System" "You can remove ${_DRYAPTVAL} packages that are no longer necessary")
- else _autoremove=()
- fi
- # Check for blockhosts
- if [[ -s /etc/NetworkManager/dnsmasq.d/blacklist ]]; then
- blocked_count=$(wc -l /etc/NetworkManager/dnsmasq.d/blacklist | cut -d\/ -f1)
- _blockhosts=(FALSE "BLOCKHOSTS" "Blacklist Generator" "Management" "System" "<span foreground='green'>${blocked_count} undesirable hosts blacklisted - (select to modify)</span>")
- else _blockhosts=(FALSE "BLOCKHOSTS" "Blacklist Generator" "Management" "System" "Block ads, adware, malware and tracking domains")
- fi
- # Check for bypass pkexec password prompt
- if [[ ! -f "/usr/share/unlockme/set/ACTPKEXEC" && ! -f "$FILEPKEXEC" ]]; then
- _bypasspswadmpkexec=(FALSE "BYPASSPSWADMPKEXEC" "pkexec Password Prompt" "Management" "System" "Bypass pkexec password prompt for admin accounts")
- else _bypasspswadmpkexec=(FALSE "BYPASSPSWADMPKEXEC" "pkexec Password Prompt" "Management" "System" "<span foreground='green'>Bypass pkexec prompt for admins - (select to remove)</span>")
- fi
- # Check if the google-chrome browser cache exists
- if [[ -d "${HOME}/.cache/google-chrome/" ]]; then
- GCCACHESIZE=$(du -sh "${HOME}/.cache/google-chrome/" | awk '{print $1"B"}')
- chromecache=(FALSE "CHROMECACHE" "Chrome Cache" "Cleanup" "User" "You can remove $GCCACHESIZE from your Chrome browser cache")
- else chromecache=()
- fi
- # Check if google-chrome browser profile exists
- if [[ -d "${HOME}/.config/google-chrome" ]]; then
- _chromeprofile=(FALSE "CHROMEPROFILE" " -- Chrome Profile" "Cleanup" "User" "<span foreground='chocolate'>Remove Chrome browser profile</span>")
- else _chromeprofile=()
- fi
- # Check for chromium browser cache
- if [[ -d "${HOME}/.cache/chromium/" && $(du -sb "${HOME}/.cache/chromium/" | cut -f1) -ge 1048576 ]]; then
- CHRCACHESIZE=$(du -sh "${HOME}/.cache/chromium/" | awk '{print $1"B"}')
- chromiumcache=(FALSE "CHROMIUMCACHE" "Chromium Cache" "Cleanup" "User" "You can remove $CHRCACHESIZE from your Chromium browser cache")
- else chromiumcache=()
- fi
- # Check if chromium browser profile exists
- if [[ -d "${HOME}/.config/chromium/" ]]; then
- _chromiumprofile=(FALSE "CHROMIUMPROFILE" " -- Chromium Profile" "Cleanup" "User" "<span foreground='chocolate'>Remove Chromium browser profile</span>")
- else _chromiumprofile=()
- fi
- # check for compton compositor
- if [[ "$LMDENV" = "Xfce" || "$LLDENV" = "Lite" || "$PPMDENV" =~ "PeppermintOS" ]]; then
- if [[ -z $(dpkg -l | grep -E '^ii' | grep 'compton') ]]; then
- _comptonwc=(FALSE "COMPTONWC" "Compton Compositor" "Compositing" "User" "Compton Compositor for beautiful tear free compositing")
- else _comptonwc=(FALSE "COMPTONWC" "Compton Compositor" "Compositing" "User" "<span foreground='green'>Compton Compositor is currently installed - (select to modify)</span>")
- fi
- else _comptonwc=()
- fi
- # Check for dns cache tweak
- if [[ ! -f "/etc/NetworkManager/dnsmasq.d/cache" ]]; then
- _dnscache=(FALSE "DNSCACHE" "Enable DNS Cache" "Management" "System" "Enable DNS Cache")
- else _dnscache=(FALSE "DNSCACHE" "DNS Cache" "Management" "System" "<span foreground='green'>DNS Cache Enabled - (select to modify)</span>")
- fi
- # check for dropbox Cinnamon Fix
- if [[ "$LMDENV" =~ "Cinnamon" ]]; then
- if [[ -z "$(dpkg -l | grep -E '^ii' | grep '\s\sdropbox\s')" ]]; then _fixdpcin=()
- else
- if [[ ! -f "/home/$_SOFTUSR/.local/share/.fixdbcin" ]]; then
- _fixdpcin=(FALSE "FIXDBCIN" "Dropbox Startup Fix" "Repair" "User" "Fix Dropbox Autostart in Cinnamon")
- else _fixdpcin=(FALSE "FIXDBCIN" "Dropbox Startup Fix" "Repair" "User" "<span foreground='green'>Applied - (select to remove)</span>")
- fi
- fi
- fi
- # check for dropbox - Xfce|Budgie Fix
- if [[ "$LMDENV" =~ "Xfce" ]] || [[ "$DESKTOP_SESSION" = "budgie-desktop" ]]; then
- if [[ "$LMDENV" =~ "Xfce" ]]; then
- applyfix="Xfce"
- else
- if [[ $(lsb_release -sc) = "xenial" ]] && [[ "$DESKTOP_SESSION" = "budgie-desktop" ]]; then
- applyfix="Budgie"
- fi
- fi
- if [ -z "$(dpkg -l | grep -E '^ii' | grep '\(\sdropbox\s\|nautilus-dropbox\)')" ]; then
- _fixdbxfce=()
- else
- if [ "$(grep -F 'Exec=dbus-launch' /usr/share/applications/dropbox.desktop)" ] && \
- [ "$(grep -F 'Exec=dbus-launch' /home/$_SOFTUSR/.config/autostart/dropbox.desktop)" ]; then
- _fixdbxfce=()
- else
- _fixdpxfce=(FALSE "FIXDBXFCE" "Dropbox Systray Fix" "Repair" "User" "Fix Dropbox System tray icon and menu - $applyfix ")
- fi
- fi
- fi
- # check for firefox browser cache
- if [[ -d "${HOME}/.cache/mozilla/firefox" && $(du -sb "${HOME}/.cache/mozilla/firefox" | cut -f1) -ge 1048576 ]]; then
- FFCACHESIZE=$(du -sh "${HOME}/.cache/mozilla/firefox/" 2>&1 | awk '{print $1"B"}')
- firefoxcache=(FALSE "FIREFOXCACHE" "Firefox Cache" "Cleanup" "User" "You can remove $FFCACHESIZE from your Firefox browser cache")
- else firefoxcache=()
- fi
- # Check if firefox browser profile exists
- if [[ -d "${HOME}/.mozilla/firefox/" ]]; then
- _ffoxprofile=(FALSE "FFOXPROFILE" " -- Firefox Profile" "Cleanup" "User" "<span foreground='chocolate'>Remove Firefox browser profile</span>")
- else _ffoxprofile=()
- fi
- # Check enable / disable IPv6 tweak
- if [[ $(< /proc/sys/net/ipv6/conf/all/disable_ipv6) = "1" ]]; then
- _ipv6=(FALSE "IPV6" "Enable IPv6" "Management" "System" "<span foreground='green'>IPv6 has been disabled - Select to Enable IPv6</span>")
- else _ipv6=(FALSE "IPV6" "Disable IPv6" "Management" "System" "Disable IPv6")
- fi
- # check for kernel cache pressure
- if [[ $(< /proc/sys/vm/vfs_cache_pressure) != "100" ]]; then
- _syscachepr=(FALSE "SYSCACHEPR" "Kernel Cache Pressure" "Performance" "System" "<span foreground='green'>Custom kernel cache pressure applied - (select to modify)</span>")
- else _syscachepr=(FALSE "SYSCACHEPR" "Kernel Cache Pressure" "Performance" "System" "Controls how the kernel reclaims memory used for caching")
- fi
- # check for kernel swappiness
- if [[ $(< /proc/sys/vm/swappiness) = "60" ]]; then
- if which preload > /dev/null; then
- _sysswap=(FALSE "SYSSWAP" "Kernel Swappiness ¡¡" "" "" "Kernel setting that controls how often the swap file is used")
- else _sysswap=(FALSE "SYSSWAP" "Kernel Swappiness" "Performance" "System" "Kernel setting that controls how often the swap file is used")
- fi
- else
- _sysswap=(FALSE "SYSSWAP" "Kernel Swappiness" "Performance" "System" "<span foreground='green'>Custom kernel swappiness applied - (select to modify)</span>")
- fi
- # check for lite-controlcenter modules
- if [[ "$LLDENV" = "Lite" && -n "$(dpkg -l | grep -E '^ii' | grep '\s\slite-controlcenter\s')" ]] && \
- [[ -d /usr/share/litecc/modules/disabled && "$(ls -A /usr/share/litecc/modules/disabled)" ]]; then
- _liteccmodules=(FALSE "LITECCMODS" "Control Center modules" "Management" "System" "Enable UnlockMe modules in Linux Lite Control Center")
- else _liteccmodules=()
- fi
- # lxterminal geometry size | linuxlite specific
- if [[ "$LLDENV" = "Lite" ]]; then
- _lxtermwinsize=(FALSE "LXTERMWINSIZE" "LXTerminal Geometry" "Management" "System" "Change default LXTerminal geometry in Linux Lite (system-wide)")
- else _lxtermwinsize=()
- fi
- # Check if midori browser cache exists
- if [[ -d "${HOME}/.cache/midori/" ]]; then
- MDCACHESIZE=$(du -sh "${HOME}/.cache/midori/" | awk '{print $1"B"}')
- _midoricache=(FALSE "MIDORICACHE" "Midori Cache" "Cleanup" "User" "You can remove $MDCACHESIZE from your Midori browser cache")
- else _midoricache=()
- fi
- # Check if midori browser profile exists
- if [[ -d "${HOME}/.config/midori/" ]]; then
- _midoriprofile=(FALSE "MIDORIPROFILE" " -- Midori Profile" "Cleanup" "User" "<span foreground='chocolate'>Remove Midori browser profile</span>")
- else _midoriprofile=()
- fi
- # Check if opera browser cache exists
- if [[ -d "${HOME}/.cache/opera/Cache/" ]]; then
- OPCACHESIZE=$(du -sh "${HOME}/.cache/opera/Cache/" | awk '{print $1"B"}')
- _operacache=(FALSE "OPERACACHE" "Opera Cache" "Cleanup" "User" "You can remove $OPCACHESIZE from your Opera browser cache")
- else _operacache=()
- fi
- # Check if opera browser profile exists
- if [[ -d "${HOME}/.config/opera/" ]]; then
- _operaprofile=(FALSE "OPERAPROFILE" " -- Opera Profile" "Cleanup" "User" "<span foreground='chocolate'>Remove Opera browser profile</span>")
- else _operaprofile=()
- fi
- # Check if Pale Moon browser cache exists
- if [[ -d "${HOME}/.cache/moonchild productions/pale moon/" ]]; then
- PMCACHESIZE=$(du -sh "${HOME}/.cache/moonchild productions/pale moon/" | awk '{print $1"B"}')
- _palemooncache=(FALSE "PALEMOONCACHE" "Pale Moon Cache" "Cleanup" "User" "You can remove $PMCACHESIZE from your Pale Moon browser cache")
- else _palemooncache=()
- fi
- # Check if Pale Moon browser profile exists
- if [[ -d "${HOME}/.moonchild productions/" ]]; then
- _palemoonprofile=(FALSE "PALEMOONPROFILE" " -- Pale Moon Profile" "Cleanup" "User" "<span foreground='chocolate'>Remove Pale Moon browser profile</span>")
- else _palemoonprofile=()
- fi
- # Check for Change Hostname
- if [[ "$LMDENV" =~ "Cinnamon" ]]; then
- _chnamehost=(FALSE "CHNAMEHOST" "Hostname" "Change Hostname" "System" "Change the computer hostname. (Logout required)")
- elif [[ "$LMDENV" =~ "Xfce" ]] || [[ "$LMDENV" =~ "MATE" ]] || [[ "$LLDENV" =~ "Lite" ]] ||
- [[ "$PPMDENV" =~ "PeppermintOS" ]] || [[ $DESKTOP_SESSION = 'budgie-desktop' ]]; then
- _chnamehost=(FALSE "CHNAMEHOST" "Hostname" "Change Hostname" "System" "Change the computer hostname. (no restart required)")
- else _chnamehost=()
- fi
- # Check logs archives
- if [[ "$(find /var/log -type f \( -iname \*.gz -o -iname \*.0 -o -iname \*.1 \) 2>/dev/null -maxdepth 100 -size +1k)" ]]; then
- 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"}')
- _logarchives=(FALSE "LOGARCHIVES" "Log Archives" "Cleanup" "System" "You can remove $LOGARCHIVESIZE worth of archived logs")
- else _logarchives=()
- fi
- # Check if any thumbnails exist
- if [[ $(du -sk "${HOME}/.cache/thumbnails/" | awk '{print $1}') > 100 ]]; then
- THUMBCACHESIZE=$(du -sh "${HOME}"/.cache/thumbnails/ | awk '{print $1"B"}')
- _thumbn=(FALSE "THUMBNAILS" "Thumbnail Cache" "Cleanup" "User" "You can remove $THUMBCACHESIZE from your thumbnail cache")
- else _thumbn=()
- fi
- # check for open as root - Thunar custom action
- if which Thunar > /dev/null; then
- if [[ -n $(grep '<name>Open as' "$_CAFILE") && -n $(grep 'pkexec Thunar %F' "${_CAFILE}") ]]; then
- _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>")
- else
- _openasroot_thunar=(FALSE "OPENASROOT_THUNAR" "pkexec Open as Root" "Custom Action" "User" "Use pkexec PolicyKit to open folders as Root in Thunar")
- fi
- fi
- # check for Open terminal Here - linuxlite specific
- if [[ "$LLDENV" = "Lite" ]]; then
- _CHKFILE="/etc/skel/.config/Thunar/uca.xml"
- _CHKNEWL="<command>x-terminal-emulator -t "Command Line" --working-directory=%f"
- if [[ -n $(grep -F "$_CHKNEWL" "$_CHKFILE") && -n $(grep 'Open Terminal Here' "${_CHKFILE}") ]]; then
- _openterm_here=(FALSE "OPENTERM_HERE" "Open Terminal Here" "Custom Action" "User" "<span foreground='green'>Terminal opens in the selected folder (select to revert)</span>")
- else
- _openterm_here=(FALSE "OPENTERM_HERE" "Open Terminal Here" "Custom Action" "User" "Fixes custom action so that LXTerminal opens in the selected folder")
- fi
- fi
- # Check package cache
- if [[ "$(find /var/cache/apt/archives/ -maxdepth 1 -size +100k)" ]]; then
- APTCACHESIZE=$(du -sh /var/cache/apt/archives/ 2>/dev/null | awk '{print $1"B"}')
- _packagecache=(FALSE "PACKAGECACHE" "Packages Cache" "Cleanup" "System" "You can remove $APTCACHESIZE worth of files from the packages cache")
- else _packagecache=()
- fi
- # Check if preload is installed
- if [[ -z "$(dpkg -l | grep -E '^ii' | grep '\spreload\s')" ]]; then
- if [[ -z "$(grep -F 'vm.swappiness' /etc/sysctl.conf)" ]];then
- _preload=(FALSE "PRELOAD" "Preload Apps" "Performance" "System" "Fetch commonly used apps into RAM for faster startup times")
- else
- _preload=(FALSE "PRELOAD" "Preload Apps ¡¡" "" "" "Fetch commonly used apps into RAM for faster startup times")
- fi
- else _preload=(FALSE "PRELOAD" "Preload Apps" "Performance" "System" "<span foreground='green'>Preload is currently installed - (select to modify)</span>")
- fi
- # Check residual configuration files
- if [[ -n "$(dpkg -l | grep '^rc')" ]]; then
- RESCONFIGQTY=$(dpkg -l | grep '^rc' | awk '{print $2}'| wc -w)
- _resconfig=(FALSE "RESIDCONFIG" "Residual Config Files" "Cleanup" "System" "There are $RESCONFIGQTY residual configuration files that can be removed")
- else _resconfig=()
- fi
- # Check if the seamonkey browser cache exists
- if [[ -d "${HOME}/.cache/mozilla/seamonkey/" ]]; then
- SMCACHESIZE=$(du -sh "${HOME}/.cache/mozilla/seamonkey/" | awk '{print $1"B"}')
- _seamonkeycache=(FALSE "SEAMONKEYCACHE" "SeaMonkey Cache" "Cleanup" "User" "You can remove $SMCACHESIZE from your SeaMonkey browser cache")
- else _seamonkeycache=()
- fi
- # Check if seamonkey browser profile exists
- if [[ -d "${HOME}/.mozilla/seamonkey/" ]]; then
- _seamonkeyprofile=(FALSE "SEAMONKEYPROFILE" " -- SeaMonkey Profile" "Cleanup" "User" "<span foreground='chocolate'>Remove SeaMonkey browser profile</span>")
- else _seamonkeyprofile=()
- fi
- # Check the Trash
- if [[ "$(ls -A "${HOME}/.local/share/Trash/files/")" ]]; then
- TRASHCACHESIZE=$(du -sh "${HOME}/.local/share/Trash/" | awk '{print $1"B"}')
- _trashbin=(FALSE "TRASHBIN" "Trash Bin" "Cleanup" "User" "You can remove $TRASHCACHESIZE from the Trash bin")
- else _trashbin=()
- fi
- # Check vivaldi-stable cache
- if [[ -d "${HOME}/.cache/vivaldi/" ]]; then
- VCSIZE=$(du -sh "${HOME}/.cache/vivaldi/" | awk '{print $1"B"}')
- _vivaldicache=(FALSE "VIVALDICACHE" "Vivaldi Cache" "Cleanup" "User" "You can remove $VCSIZE from your Vivaldi browser cache")
- else _vivaldicache=()
- fi
- # Check if vivaldi browser profile exists
- if [[ -d "${HOME}/.config/vivaldi" ]]; then
- _vivaldiprofile=(FALSE "VIVALDIPROFILE" " -- Vivaldi Profile" "Cleanup" "User" "<span foreground='chocolate'>Remove Vivaldi browser profile</span>")
- else _vivaldiprofile=()
- fi
- # Check for zram
- if [[ -z "$VARZRAM" ]]; then
- if [[ "$VARZSWAP" == "Y" ]] || [[ -n "$(grep 'zswap.enabled=1' /etc/default/grub)" ]]; then
- _zram=(FALSE "ZRAM" "zRAM ¡¡" "" "" "Compressed RAM based block device for faster I/O")
- else
- _zram=(FALSE "ZRAM" "zRAM" "Performance" "System" "Compressed RAM based block device for faster I/O")
- fi
- else _zram=(FALSE "ZRAM" "zRAM" "Performance" "System" "<span foreground='green'>zRAM is currently installed - (select to modify)</span>")
- fi
- # Check for zswap
- # check kernel for zswap
- if [[ $(cat /boot/config-$(uname -r) | grep -i zswap | cut -d= -f2) == "y" ]]; then
- # if zswap is not enabled
- if [[ "$VARZSWAP" == "N" ]]; then
- # if zram is installed
- if [[ -n "$VARZRAM" ]]; then
- _zswap=(FALSE "ZSWAP" "zSWAP ¡¡" "" "" "Efficient use of RAM and disk based swap. Minimizes Disk I/O")
- else
- # if zswap is not enabled but grub value exists
- if [[ "$VARZSWAP" == "N" ]] && [[ -n "$(grep 'zswap.enabled=1' /etc/default/grub)" ]]; then
- _zswap=(FALSE "ZSWAP" "zSWAP <span foreground='red'>(Pending restart) ¡¡</span>" "" "" "Efficient use of RAM and disk based swap. Minimizes Disk I/O")
- else
- # zswap default
- _zswap=(FALSE "ZSWAP" "zSWAP" "Performance" "System" "Efficient use of RAM and disk based swap. Minimizes Disk I/O")
- fi
- fi
- else
- if [[ "$VARZSWAP" == "Y" ]] && [[ -z "$(grep 'zswap.enabled=1' /etc/default/grub)" ]]; then
- # pending reboot for removal
- _zswap=(FALSE "ZSWAP" "zSWAP <span foreground='red'>(Pending restart) ¡¡</span>" "Performance" "System" "<span foreground='green'>zSWAP is currently enabled - (select to modify)</span>")
- else
- # zswap installed
- _zswap=(FALSE "ZSWAP" "zSWAP" "Performance" "System" "<span foreground='green'>zSWAP is currently enabled - (select to modify)</span>")
- fi
- fi
- fi
- # Check if waterfox browser cache exists
- if [[ -d "${HOME}/.cache/waterfox/" ]]; then
- WFCACHESIZE=$(du -sh "${HOME}/.cache/waterfox/"| awk '{print $1"B"}')
- _waterfoxcache=(FALSE "WATERFOXCACHE" "Waterfox Cache" "Cleanup" "User" "You can remove $WFCACHESIZE from your Waterfox browser cache")
- else _waterfoxcache=()
- fi
- # Check if waterfox browser profile exists
- if [[ -d "${HOME}/.waterfox" ]]; then
- _waterfoxprofile=(FALSE "WATERFOXPROFILE" " -- Waterfox Profile" "Cleanup" "User" "<span foreground='chocolate'>Remove Waterfox browser profile</span>")
- else _waterfoxprofile=()
- fi
- # Whisker Menu Restore if Linux Lite
- if [[ "$LLDENV" =~ "Lite" ]]; then
- _whiskermrest=(FALSE "WHISKERMREST" "Whisker Menu Restore" "Fix" "User" "Restore Linux Lite Whisker Menu defaults")
- else _whiskermrest=()
- fi
- # Check for samba service -Linux Lite
- if [[ "$LLDENV" = "Lite" ]]; then
- if [[ -n $(pgrep -f 'smbd') ]]; then
- _sambasrv=(FALSE "SAMBASVR" " -- Service: samba" "Performance" "System" "If not using this PC as a file server, this service can safely disabled")
- else _sambasrv=(FALSE "SAMBASVR" " -- Service: samba" "Performance" "System" "<span foreground='green'>Samba is disabled (select to enable samba)</span>")
- fi
- fi
- }
- # Function that displays additional info in the second paned tab
- function display_info() {
- # Formfeed character \f clears text info diaolg
- echo -e "\f" >$info_pipe
- case $2 in
- THEMING) echo "Install ralphy's selection of themes" >$info_pipe ;;
- SOFTINSTALL) echo "Install ralphy's selection of software" >$info_pipe ;;
- BLOCKHOSTS) echo "Block hosts" >$info_pipe ;;
- CHROMIUMCACHE) echo "Install ralphy's selection of software" >$info_pipe ;;
- *) echo "$2" >$info_pipe ;;
- esac
- }
- export -f display_info
- # Main loop
- while (true); do
- _APPNAME="UnlockMe"
- _SOFTUSR=$(whoami)
- TMPUSRFL="/tmp/.unlockusr"
- echo "$DESKTOP_SESSION" > "$unlockds" ; chmod 600 "$unlockds"
- if [[ ! -f "$TMPUSRFL" ]]; then
- echo "$_SOFTUSR" > "$TMPUSRFL"
- chmod 600 "$TMPUSRFL"
- else :
- fi
- # first run the checks
- CHECK
- # Main dialog os version
- BITS=$(getconf LONG_BIT)
- if [[ -f "$mintinfo" ]]; then
- # check if peppermint
- if [[ "$PPMDENV" =~ "PeppermintOS" ]]; then
- DISTRO="${PPMDENV} ${BITS}-bit"
- else
- # assume linuxmint
- DISTRO="$(grep -F 'GRUB' "$mintinfo" | cut -d\= -f2)"
- fi
- # check if linuxlite
- elif [[ -f "$liteinfo" ]]; then
- DISTRO="$(< "$liteinfo") ${BITS}-bit"
- # check if ubuntu-budgie
- elif grep -q 'Ubuntu' /etc/issue && [[ $DESKTOP_SESSION = 'budgie-desktop' ]]; then
- DISTRO="Ubuntu Budgie $(awk '{print $2,$3}' < /etc/issue | head -n1) ${BITS}-bit"
- # check if ubuntu-mate
- elif [[ $(uname -a | grep -F "ubuntu-mate" | awk '{print $2}') == 'ubuntu-mate' ]]; then
- DISTRO="Ubuntu MATE $(awk '{print $2,$3}' < /etc/issue | head -n1) ${BITS}-bit"
- # others
- else DISTRO="$(cut -d\\ -f1 < /etc/issue)"
- fi
- # Create a key for the plug dialog
- unlockme_key="$(($RANDOM * $$))"
- export info_pipe="$(mktemp -u /tmp/UnLockmE_XXXXX).$RANDOM-$$"
- mkfifo -m 0600 "$info_pipe"
- # temp file to export selection
- export selection_temp="$(mktemp /tmp/SeleXXXion_XXXXX_UnlockMe)"
- # Trap to remove temp files
- trap "rm -f $info_pipe $selection_temp" EXIT
- exec 3<> $info_pipe
- # main dialog
- yad --plug="$unlockme_key" --tabnum=1 --list --checklist --separator=" " \
- --search-column="3" --image-on-top \
- --column="Select" --column="SELECTION" --column="Name" --column="Task" \
- --column="Category" --column="Description" --hide-column="2" --print-column=2 \
- --select-action='bash -c "display_info %s"' \
- --text="<span font='9'>${DISTRO}\n</span>
- <span font='9'>Select the task(s) you wish to perform, then click the Begin button. Sort by clicking on the columns header.
- You can select multiple tasks for sequential execution (Administrative privileges are required for some tasks).</span>" \
- "FALSE" "THEMING" "Appearance" "Install or Remove" "System" "A selection of popular desktop themes, icons and cursors" \
- "FALSE" "SOFTINST" "Application Software" "Install or Remove" "System" "Install and remove selected commonly used applications" \
- "${_autoremove[@]}" \
- "${_blockhosts[@]}" \
- "${chromecache[@]}" \
- "${chromiumcache[@]}" \
- "${_comptonwc[@]}" \
- "${_liteccmodules[@]}" \
- "${_dnscache[@]}" \
- "${_fixdpcin[@]}" \
- "${_fixdpxfce[@]}" \
- "${_ipv6[@]}" \
- "${firefoxcache[@]}" \
- "${_chnamehost[@]}" \
- "FALSE" "ICONTHEMESERIK" "Icon Themes" "Install or Remove" "User" "Colorful icon themes collection for linux desktops by Erik Dubois" \
- "${_syscachepr[@]}" \
- "${_sysswap[@]}" \
- "${_logarchives[@]}" \
- "${_lxtermwinsize[@]}" \
- "${_mgmtsavesession[@]}" \
- "${_midoricache[@]}" \
- "${_operacache[@]}" \
- "${_palemooncache[@]}" \
- "${_packagecache[@]}" \
- "${_openasroot_thunar[@]}" \
- "${_openterm_here[@]}" \
- "${_bypasspswadmpkexec[@]}" \
- "${_preload[@]}" \
- "${_resconfig[@]}" \
- "${_seamonkeycache[@]}" \
- "${_thumbn[@]}" \
- "${_trashbin[@]}" \
- "${_vivaldicache[@]}" \
- "${_waterfoxcache[@]}" \
- "${_whiskermrest[@]}" \
- "${_zram[@]}" \
- "${_zswap[@]}" \
- "${_chromeprofile[@]}" \
- "${_chromiumprofile[@]}" \
- "${_ffoxprofile[@]}" \
- "${_midoriprofile[@]}" \
- "${_operaprofile[@]}" \
- "${_palemoonprofile[@]}" \
- "${_seamonkeyprofile[@]}" \
- "${_vivaldiprofile[@]}" \
- "${_waterfoxprofile[@]}" \
- "${_sambasrv[@]}" >$selection_temp &
- yad --plug="$unlockme_key" --tabnum=2 --text "Info tab" --text-info <&3 &
- yad --center --paned --key="$unlockme_key" --button="gtk-quit:1" --button=" Begin"\!gtk-apply:0 --width="880" --height="600" \
- --window-icon="$ICON" --image="$ICON" --title=" $_APPNAME" --orient=vert --splitter=450
- if [[ "$?" = "1" || "$?" = "252" ]]; then _CLEANUP; exit 0 ; fi # If Quit or (X) is clicked then exit
- grep -q '[a-zA-Z0-9]' "$selection_temp"
- if [[ "$?" != "0" ]]; then
- zenity --info --ok-label="Go Back" --width="260" --height="80" --title=" $_APPNAME" \
- --text="\n<b>No tasks were selected for execution</b> \n\nPlease try again selecting a at least one task." 2>/dev/null
- continue
- fi
- ARRAYS # Separate selected items into arrays A and B
- RUN
- done
- exit 0
Add Comment
Please, Sign In to add comment