Linux Lite 8.0 RC1 has been released - Click here


Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5

Lite Tweaks Development
#41

Exelent!
Tested the code from github. 'Package System Repair' is working.
I think it's ready. Shall we wait unti LL 2.4 beta to anounce or you want to update it now?
Reply
#42

I'll create an updated package soon for release. Thank you for helping :)

Download your free copy of Linux Lite today.

Jerry Bezencon
Linux Lite Creator

"Do not correct a fool, or he will hate you; correct a wise man and he will appreciate you."

[Image: X5qGkCg.png]

[Image: 0op1GNe.png] [Image: LgJ2mtP.png] [Image: vLZcFUE.png] [Image: lrUHro3.jpg]
Reply
#43

Glad to help. :)
So, you are preparing the new release?
What happened to Lite Control Center? Will it be ready for LL 2.4?
Reply
#44

(03-02-2015, 10:08 AM)misko_2083 link Wrote:  So, you are preparing the new release?

Yes, I will do that tonight.

(03-02-2015, 10:08 AM)misko_2083 link Wrote:  What happened to Lite Control Center? Will it be ready for LL 2.4?

We have a python3 version but I am unable to verify that it works due to the fact it was developed with the latest versions of some software.
I'm still waiting on the python2 version from the devs working on the Bounty. To be honest it doesn't worry me that much as with such an awesome piece of software, it would be nice to make it the main event in LL 3.0 :)

Download your free copy of Linux Lite today.

Jerry Bezencon
Linux Lite Creator

"Do not correct a fool, or he will hate you; correct a wise man and he will appreciate you."

[Image: X5qGkCg.png]

[Image: 0op1GNe.png] [Image: LgJ2mtP.png] [Image: vLZcFUE.png] [Image: lrUHro3.jpg]
Reply
#45

So it's going to be named LL 3.0 after all :)
The community has decided on numbering system.
It's fine if you ask me. Still better than the Windows system (1,2,3,95,98,Me,2000,XP,Vista,7,8,10)
:D
Reply
#46

Yup, the power of community :)

Download your free copy of Linux Lite today.

Jerry Bezencon
Linux Lite Creator

"Do not correct a fool, or he will hate you; correct a wise man and he will appreciate you."

[Image: X5qGkCg.png]

[Image: 0op1GNe.png] [Image: LgJ2mtP.png] [Image: vLZcFUE.png] [Image: lrUHro3.jpg]
Reply
#47

Just thought, because there will be future versions of LL, eg. 2.4, 2.6 and 2.8 we'll need to somehow ensure that with 'Bootup Fix' we'll have to add a check or change the sed command according to the version of LL it's fixing. Perhaps by checking /etc/llver ?

Download your free copy of Linux Lite today.

Jerry Bezencon
Linux Lite Creator

"Do not correct a fool, or he will hate you; correct a wise man and he will appreciate you."

[Image: X5qGkCg.png]

[Image: 0op1GNe.png] [Image: LgJ2mtP.png] [Image: vLZcFUE.png] [Image: lrUHro3.jpg]
Reply
#48

(03-06-2015, 01:50 AM)Jerry link Wrote:  Just thought, because there will be future versions of LL, eg. 2.4, 2.6 and 2.8 we'll need to somehow ensure that with 'Bootup Fix' we'll have to add a check or change the sed command according to the version of LL it's fixing. Perhaps by checking. /etc/llver ?
I know. From 2.0 to 2.8. I think lite-tweaks-super should handle that. For every release the commands should be different.
Reply
#49

I don't know what colors releses use. Are they the same for all 2.X?
Now lite-tweaks-super checks for LL version
also I've hidden the option to remove residual config files. I guess that way there will be no error when there are no residual config files to remove.
Code:
#! /bin/bash
#--------------------------------------------------------------------------------------------------------
# Name: Lite Tweaks
# Version: 1.0-0220
# Description: A collection of tools to tweak your Linux Lite system.
# Authors: Misko_2083, John Jenkins, Jerry Bezencon
# Date: March 2nd, 2015
# Website: https://www.linuxliteos.com
#--------------------------------------------------------------------------------------------------------

# Set functions for non-root execution
# The ones that need root go to the other file: lite-tweaks-super
FIREFOX() {
    echo "#Removing the Firefox cache..."
              rm -rf $HOME/.cache/mozilla/
            if [ "${PIPESTATUS[0]}" -ne "0" ]; then
                        echo "#Error"
                    sleep 2
                                        zenity --error \
                                        --title="Error" --text="There was an error while\nRemoving the Firefox cache!"
                        fi
}

CHROME() {
    echo "#Removing the Google Chrome cache..."
            rm -rf $HOME/.cache/google-chrome/
            if [ "${PIPESTATUS[0]}" -ne "0" ]; then
                        echo "#Error"
                    sleep 2
                                        zenity --error \
                                        --title="Error" --text="There was an error while\nRemoving the Google Chrome cache!"
                        fi
}

CHROMIUM() {
    echo"#Removing the Chromium cache..."
            rm -rf $HOME/.cache/chromium/
            if [ "${PIPESTATUS[0]}" -ne "0" ]; then
                        echo "#Error"
                    sleep 2
                                        zenity --error \
                                        --title="Error" --text="There was an error while\nRemoving the Chromium cache!"
                        fi
}

THUMBNAILS() {
    echo "#Deleting Thumbnail Cache..."
    sleep 1
             rm -rf $HOME/.thumbnails/*
            if [ "${PIPESTATUS[0]}" -ne "0" ]; then
                        echo "#Error"
                    sleep 2
                                        zenity --error \
                                        --title="Error" --text="There was an error while\nDeleting Thumbnail Cache!"
                        fi
}

WHISKER() {
echo "#Cleaning Whisker Menu Recently Used items..."
sleep 1
sed -i 's/^recent=.*$/recent=/g' ~/.config/xfce4/panel/whiskermenu-1.rc

            if [ "${PIPESTATUS[0]}" -ne "0" ]; then
                        echo "#Error"
                    sleep 2
                                        zenity --error \
                                        --title="Error" --text="There was an error while\nCleaning Whisker Menu Recently Used items!"
                        fi
echo "#Restarting the panel..."
dbus-send --print-reply --dest=org.xfce.Panel /org/xfce/Panel org.xfce.Panel.Terminate boolean:true
sleep 2
}

TRASH() {
    echo "#Emptying the Trash bin..."
    sleep 1
              rm -rf $HOME/.local/share/Trash/files/*
            if [ "${PIPESTATUS[0]}" -ne "0" ]; then
                        echo "#Error"
                    sleep 2
                                        zenity --error \
                                        --title="Error" --text="There was an error while\nEmptying the Trash bin!"
                        fi
}

DU() {
DU_TEXT="Double click on any <b>Partition</b> to open in the file manager.
Click on any Column to sort the information."
DU_TITLE="Disk Usage"
TMP_DU=$(mktemp /tmp/diskusage.XXXXX)

df -h -T| tail -n+2 | while read fs type size used rest target; do
    if [[ $rest ]] ; then
        echo "$fs" "$type" "$size"B "$used"B "$rest"B "${target[@]}" |grep /dev/sd |
        awk '{print $1,"\n",$2,"\n",$3,"\n",$4,"\n",$5,"\n",$6}BEGIN{ s = 7; e = 35; }{for (i=s; i<=e; i++) printf("%s%s", $(i), i<e ? OFS : "\n"); }' # Workaround for disk labels that contain whitespaces(number of characters that can be divided by whitespace =e-s)
    fi
done | sed -e 's/[ \t]*$//' $1|  tee $TMP_DU

SEL=$(cat $TMP_DU | zenity --list --width=600 --height=350 --title="${DU_TITLE}" --text="${DU_TEXT}" --column="Device" --column="Filesystem" --column="Size" --column="Used" --column="Free" --column="%Used" --column="Partition" --print-column="7"| cut -d '|' -f2)

if [ -z "$SEL" ]; then
rm -f $TMP_DU
return
fi

thunar "$(echo $SEL)"
rm -f $TMP_DU
}

# Set the dialogue window icon
ic="/usr/share/pixmaps/litetweaks.png"

ARRAYS() {
# Invoke arrays
ARRAYA=()       # Array for automatic cleaning tool
ARRAYB=()    # Array for cleaning tools that require root

# Populate arrays
echo $selection | grep "Package Cache" > /dev/null
if [ $? = 0 ];then
ARRAYB+=('APTGETCLEAN')
fi

echo $selection | grep "Autoremove Packages" > /dev/null
if [ $? = 0 ];then
ARRAYB+=('AUTOREMOVE')
fi

echo $selection | grep "Firefox" > /dev/null
if [ $? = 0 ];then
ARRAYA+=('FIREFOX')
fi

echo $selection | grep "Chrome" > /dev/null
if [ $? = 0 ];then
ARRAYA+=('CHROME')
fi

echo $selection | grep "Chromium" > /dev/null
if [ $? = 0 ];then
ARRAYA+=('CHROMIUM')
fi

echo $selection | grep "Display Disk Usage" > /dev/null
if [ $? = 0 ];then
ARRAYA+=('DU')
fi

echo $selection | grep "Thumbnail Cache" > /dev/null
if [ $? = 0 ];then
ARRAYA+=('THUMBNAILS')
fi

echo $selection | grep "Whisker Menu" > /dev/null
if [ $? = 0 ];then
ARRAYA+=('WHISKER')
fi

echo $selection | grep "Trash Bin" > /dev/null
if [ $? = 0 ];then
ARRAYA+=('TRASH')
fi

echo $selection | grep "Default Web Browser" > /dev/null
if [ $? = 0 ];then
ARRAYB+=('DBROWSER')
fi

echo $selection | grep "Locate Large Files" > /dev/null
if [ $? = 0 ];then
ARRAYB+=('FILESIZES')
fi

echo $selection | grep "Kernel Removal" > /dev/null
if [ $? = 0 ];then
ARRAYB+=('REMKERNELS')
fi

echo $selection | grep "Log Archives" > /dev/null
if [ $? = 0 ];then
ARRAYB+=('LOGARCHIVES')
fi

echo $selection | grep "Residual Config Files" > /dev/null
if [ $? = 0 ];then
ARRAYB+=('RESIDCONFIG')
fi

echo $selection | grep "Bootup Fix" > /dev/null
if [ $? = 0 ];then
ARRAYB+=('FIXBOOTUP')
fi

echo $selection | grep "Package System Repair" > /dev/null
if [ $? = 0 ];then
ARRAYB+=('FIXAPT')
fi
}

RUN() {
# Check if ARRAYA is empty
# If it is skip the execution
if [ ${#ARRAYA[@]} -ne 0 ]; then

    x=0
    for k in "${!ARRAYA[@]}"; do  x=$(( $x + 1 )); done  # Get the total number of selected items in array A

    TOTAL_LINES=$x

    printf '%s \n' "${ARRAYA[@]}"|
    while read  line
        do
            $line     # Execute functions one by one
            if [ $? = 1 ]; then
                zenity --error --title="Lite Tweaks" --text="There was an error while performing cleaning:\n ${line}"
                exit 1
            fi   
        let i++
         (( PERCENTAGE = 100 \* ${i} / ${TOTAL_LINES} ))
         echo "$PERCENTAGE"

        if [ "$PERCENTAGE" == "100" ]; then
            echo "#Done"
            sleep 2
        fi
   
    done| zenity --progress  --title="Lite Tweaks" --auto-kill --auto-close --width=300
fi

# Check if ARRAYB is empty
# If it is skip the execution
if [ ${#ARRAYB[@]} -ne 0 ]; then
    gksudo /usr/bin/lite-tweaks-super "${ARRAYB[@]}"      # Open the next file with superuser privileges and pass the array B
fi

if zenity --question --title="Lite Tweaks" --text="Process(s) complete.\nWould you like to continue using Lite Tweaks?"; then
    return
else
    exit 0
fi
}

CHECK() {
# Check package cache exists
if [ "$(find /var/cache/apt/archives/ -maxdepth 1 -size +100k)" ];  then
    APTCACHESIZE=$(du -sh /var/cache/apt/archives/ | awk '{print $1}' | sed 's/$/B/')
    aptcache=(FALSE "Package Cache" "Clean" "Packages" "Safe" "You can currently remove $APTCACHESIZE worth of files from your package cache" )
else
    aptcache=(FALSE "Package Cache" "Clean" "Packages" "Safe" "You can currently remove 0kB worth of files from your package cache")
fi

# Check if archived /var/log files exist
if [ "$(find /var/log -type f \( -iname \*.gz -o -iname \*.0 -o -iname \*.1 \) -maxdepth 100 -size +1k)" ];  then
    LOGARCHIVESIZE=$(find /var/log -type f \( -iname \*.gz -o -iname \*.0 -o -iname \*.1 \) -exec du -csh '{}' + | tail -1 | awk '{print $1}' | sed 's/$/B/')
    logarchive=(FALSE "Log Archives" "Clean" "System" "Safe" "You can currently remove $LOGARCHIVESIZE worth of archived logs" )
else
    logarchive=(FALSE "Log Archives" "Clean" "System" "Safe" "You can currently remove 0kB worth of archived logs")
fi

# Check if firefox cache exists
if [  -d  "$HOME/.cache/mozilla/" ];then
    FFCACHESIZE=$(du -sh "$HOME/.cache/mozilla/"| awk '{print $1}'| sed 's/$/B/')
    firefox=("FALSE"  "Firefox" "Clean" "Internet" "Safe" "You can currently remove $FFCACHESIZE from your Firefox cache" )
else
        firefox=()
fi

# Check if the google-chrome cache exists
if [ -d  "$HOME/.cache/google-chrome/" ]; then
    GCCACHESIZE=$(du -sh $HOME/.cache/google-chrome/ | awk '{print $1}' | sed 's/$/B/')
    chrome=("FALSE" "Chrome" "Clean" "Internet" "Safe" "You can currently remove $GCCACHESIZE from your Chrome cache" )
    else
        chrome=()
fi

# Check if the chromium cache exists
if [  -d  "$HOME/.cache/chromium/" ]; then
    CHRCACHESIZE=$(du -sh $HOME/.cache/chromium/ | awk '{print $1}' | sed 's/$/B/')
    chromium=("FALSE" "Chromium" "Clean" "Internet" "Safe" "You can currently remove $CHRCACHESIZE from your Chromium cache" )
else
         chromium=() # Main zenity dialogue window
fi

# Check if there are any residual configuration files
if [ ! -z  "$(dpkg -l | grep '^rc')"  ]; then
        RESCONFIGQTY=$(dpkg -l | grep '^rc' | awk '{print $2}'| wc -w)
    resconfig=(FALSE "Residual Config Files" "Clean" "Packages" "Safe" "You currently have $RESCONFIGQTY residual configuration files you can remove" )
else
        resconfig=()
fi

# Check if any thumbnails exist
if [ $(du -sk $HOME/.thumbnails/ | awk '{print $1}')  -gt 100  ]; then
        THUMBCACHESIZE=$(du -sh $HOME/.thumbnails/ | awk '{print $1}' | sed 's/$/B/')
    thumbn=("FALSE" "Thumbnail Cache" "Clean" "Images" "Safe" "You can currently remove $THUMBCACHESIZE from your thumbnail cache" )
else
        thumbn=( "FALSE" "Thumbnail Cache" "Clean" "Images" "Safe" "You can currently remove 0kB from your thumbnail cache" )
fi

# Check if Whisker Menu has Recently Used items
if [ -z "$(cat $HOME/.config/xfce4/panel/whiskermenu-1.rc | grep "^recent=" | cut -d '=' -f2)" ]; then
    whisker_recent=(FALSE "Whisker Menu" "Clean" "Menu" "Safe" "Whisker Menu has no Recently Used items to clean" )
else
    whisker_test=$(cat $HOME/.config/xfce4/panel/whiskermenu-1.rc | grep "^recent=" | cut -d '=' -f2 | sed 's/,/ /g'| wc -w)
    whisker_recent=(FALSE "Whisker Menu" "Clean" "Menu" "Safe" "You can currently remove $whisker_test Recently Used items from your Whisker Menu" )
fi

# Check if the Trash is empty
if [  "$(ls -A $HOME/.local/share/Trash/files/)" ]; then
        TRASHCACHESIZE=$(du -sh $HOME/.local/share/Trash/ | awk '{print $1}' | sed 's/$/B/')
    trash=("FALSE" "Trash Bin" "Clean" "Home" "Safe" "You can currently remove $TRASHCACHESIZE from your Trash bin" )
else
        trash=()
fi
}

# Main loop
while (true); do

CHECK        # first run the checks

# Main zenity dialogue window
selection=$(zenity --window-icon="$ic" --list --checklist --width=880 --height=580 --column="Select" --column="Name" --column="Task" --column="Category" --column="Status" \
--column="Description" --text='Select the task you wish to perform, then click the Begin button. Sort Categories by clicking on the column.\n\nThere are 2 levels of <b>Status</b>:\n<span foreground="green">Safe</span> - Safe to perform, no harm can be done.\n<span foreground="red">Caution</span> - Proceed with caution, involves altering system files.\n\nYou can select multiple tasks to perform (password required for some tasks).' --title="Lite Tweaks" --ok-label="Begin" --cancel-label="Quit" \
FALSE "Autoremove Packages" "Clean" "Packages" "Safe" "Remove packages installed for programs that are no longer present" \
FALSE "Bootup Fix" "Fix" "Repair" "Caution" "Restore the boot splash to Linux Lite" \
"${chrome[@]}" \
"${chromium[@]}" \
FALSE "Default Web Browser" "Preferred" "Browser" "Safe" "Set your default web browser" \
FALSE "Display Disk Usage" "Information" "System" "Safe" "Display overall disk usage information for all partitions" \
"${firefox[@]}" \
FALSE "Kernel Removal" "Clean" "System" "Caution" "Remove kernels you no longer wish to boot from" \
FALSE "Locate Large Files" "Information" "System" "Caution" "Find files on your system within a size range" \
"${logarchive[@]}" \
"${aptcache[@]}" \
FALSE "Package System Repair" "Fix" "Repair" "Caution" "Restore the package management system to default" \
"${resconfig[@]}" \
"${thumbn[@]}" \
"${trash[@]}" \
"${whisker_recent[@]}" )

# If Quit is clicked then exit
if [ "${PIPESTATUS[0]}" -ne "0" ]; then
      exit 0
fi

# Check if anything is selected
echo $selection | grep '[a-zA-Z0-9]'
if [ "${PIPESTATUS[1]}" -ne "0" ]; then
    zenity --info --title='Lite Tweaks' --text='No option was selected.'
fi

ARRAYS   #Separate selected items into arrays A and array B
RUN
done

exit 0
I've left the colors blank for LL 2.0 and 2.4.
fill them like this:
black="0x000000"
white="0xffffff"
brown="0xffff00"
blue="0x000000"
Code:
#! /bin/bash
#--------------------------------------------------------------------------------------------------------
# Name: Lite Tweaks Super
# Version: 1.0-0220
# Description: A collection of tools to tweak your Linux Lite system.
# Authors: Misko_2083, John Jenkins, Jerry Bezencon
# Date: March 2nd, 2015
# Website: https://www.linuxliteos.com
#--------------------------------------------------------------------------------------------------------

# Get input from a previous file
FRM="$@"

# Check if the input is correct and populate array C
echo "$FRM" | grep "APTGETCLEAN" > /dev/null
if [ $? = 0 ];then
ARRAYC+=('CLEAN')
fi

echo $FRM | grep "AUTOREMOVE" > /dev/null
if [ $? = 0 ];then
ARRAYC+=('REMOVE')
fi

echo $FRM | grep "DBROWSER" > /dev/null
if [ $? = 0 ];then
ARRAYC+=('BROWSER')
fi

echo $FRM| grep "FILESIZES" > /dev/null
if [ $? = 0 ];then
ARRAYC+=('FILES')
fi

echo $FRM | grep "REMKERNELS" > /dev/null
if [ $? = 0 ];then
ARRAYC+=('KERNELS')
fi

echo $FRM | grep "LOGARCHIVES" > /dev/null
if [ $? = 0 ];then
ARRAYC+=('LARCHIVES')
fi

echo $FRM | grep "RESIDCONFIG" > /dev/null
if [ $? = 0 ];then
ARRAYC+=('RCONFIG')
fi

echo $FRM | grep "FIXBOOTUP" > /dev/null
if [ $? = 0 ];then
ARRAYC+=('FIXBOOTUP')
fi

echo $FRM | grep "FIXAPT" > /dev/null
if [ $? = 0 ];then
ARRAYC+=('FIXAPT')
fi

CLEAN() {
echo "#Cleaning the package cache..."
sleep 2
    sudo apt-get clean
            if [ "${PIPESTATUS[0]}" -ne "0" ]; then
                        echo "#Error..."
                    sleep 2
                                        zenity --error \
                                        --title="Error" --text="There was an error while\nCleaning the package cache!"
                        fi
}

LARCHIVES() {
echo "#Deleting archived logs..."
sleep 2
    sudo find /var/log \( -name '*.gz' -o -name '*.0' -o -name '*.1' \) -exec rm -rf {} \;
            if [ "${PIPESTATUS[0]}" -ne "0" ]; then
                        echo "#Error..."
                    sleep 2
                                        zenity --error \
                                        --title="Error" --text="There was an error while\nDeleting archived logs!"
                        fi
}

REMOVE() {
    echo "#Removing unneeded packages, please wait..."
    sleep 2
            sudo apt-get autoremove -y
            if [ "${PIPESTATUS[0]}" -ne "0" ]; then
                        echo "#Error..."
                    sleep 2
                                        zenity --error \
                                        --title="Error" --text="There was an error while\nRemoving unneeded packages!"
                        fi
}

RCONFIG() {
    echo "#Removing residual configuration files..."
    sleep 1
            sudo dpkg --purge `dpkg -l | grep '^rc' | awk '{print $2}'`
            if [ "${PIPESTATUS[0]}" -ne "0" ]; then
                        echo "#Error..."
                    sleep 2
                                        zenity --error \
                                        --title="Error" --text="There was an error while\nRemoving residual configuration files!"
                        fi
return
}

BROWSER() {
echo "#Changing the Default Web Browser..."

file="/etc/gnome/defaults.list"
test_1=(` grep "application/xhtml+xml" $file`)
test_2=(` grep "text/html" $file`)
test_3=(`grep "x-scheme-handler/http" $file`)
test_4=(` grep "x-scheme-handler/https" $file`)

hash firefox 2>/dev/null
if [ "${PIPESTATUS[0]}" -eq "0"  ]; then
    if [ "${test_1[0]}" = "application/xhtml+xml=firefox.desktop;" ] && [ "${test_2[0]}" = "text/html=firefox.desktop;" ] && [ "${test_3[0]}" = "x-scheme-handler/http=firefox.desktop;" ] && [ "${test_4[0]}" = "x-scheme-handler/https=firefox.desktop;" ]; then
            firefox=("TRUE" "Firefox" "default" "Firefox is currently your default web browser" )
    else
        firefox=("FALSE" "Firefox" "not default" "Set firefox as the default web browser" )
    fi
else
    firefox=()
fi

hash chromium-browser 2>/dev/null
if [ "${PIPESTATUS[0]}" -eq "0"  ]; then
    if [ "${test_1[0]}" = "application/xhtml+xml=chromium-browser.desktop;firefox.desktop;" ] && [ "${test_2[0]}" = "text/html=chromium-browser.desktop;firefox.desktop;" ] && [ "${test_3[0]}" = "x-scheme-handler/http=chromium-browser.desktop;firefox.desktop;" ] && [ "${test_4[0]}" = "x-scheme-handler/https=chromium-browser.desktop;firefox.desktop;" ]; then
        chromium=("TRUE" "Chromium" "default" "Chromium is currently your default web browser" )
    else
        chromium=("FALSE" "Chromium" "not default" "Set Chromium as the default web browser" )
    fi
else
    chromium=()
fi

hash midori 2>/dev/null
if [ "${PIPESTATUS[0]}" -eq "0"  ]; then
    if [ "${test_1[0]}" = "application/xhtml+xml=midori.desktop;firefox.desktop;" ] && [ "${test_2[0]}" = "text/html=midori.desktop;firefox.desktop;" ] && [ "${test_3[0]}" = "x-scheme-handler/http=midori.desktop;firefox.desktop;" ] && [ "${test_4[0]}" = "x-scheme-handler/https=midori.desktop;firefox.desktop;" ]; then
        midori=("TRUE" "Midori" "default" "Midori is currently your default web browser" )
    else
        midori=("FALSE" "Midori" "not default" "Set Midori as the default web browser" )
    fi
else
    midori=()
fi

hash google-chrome 2>/dev/null
if [ "${PIPESTATUS[0]}" -eq "0"  ]; then
    if [ "${test_1[0]}" = "application/xhtml+xml=google-chrome.desktop;firefox.desktop;" ] && [ "${test_2[0]}" = "text/html=google-chrome.desktop;firefox.desktop;" ] && [ "${test_3[0]}" = "x-scheme-handler/http=google-chrome.desktop;firefox.desktop;" ] && [ "${test_4[0]}" = "x-scheme-handler/https=google-chrome.desktop;firefox.desktop;" ]; then
        googlechrome=("TRUE" "Google Chrome" "default" "Google Chrome is currently your default web browser" )
    else
        googlechrome=("FALSE" "Google Chrome" "not default" "Set Google Chrome as the default web browser" )
    fi
else
    googlechrome=()
fi

        selection=$(zenity --window-icon="$ic" --list --radiolist --width=650 --height=200 --column="Select" --column="Name" --column="Status" \
        --column="Description" --text="Select the web browser you wish to set as default." --title="Choose default browser" --ok-label="Set" --cancel-label="Cancel" \
        "${firefox[@]}" "${googlechrome[@]}" "${chromium[@]}" "${midori[@]}" )
       
        # "The kill switch"
         if [ "${PIPESTATUS[0]}" -ne "0" ]; then
            return
        fi
    case "$selection" in
    "Firefox") `sed -i "s!^"${test_1[0]}"!application/xhtml+xml=firefox.desktop;!g" /etc/gnome/defaults.list `;
           `sed -i "s!^"${test_2[0]}"!text/html=firefox.desktop;!g" /etc/gnome/defaults.list `; \
           `sed -i "s!^"${test_3[0]}"!x-scheme-handler/http=firefox.desktop;!g" /etc/gnome/defaults.list `; \
           `sed -i "s!^"${test_4[0]}"!x-scheme-handler/https=firefox.desktop;!g" /etc/gnome/defaults.list `;;
    "Google Chrome") `sed -i "s!^"${test_1[0]}"!application/xhtml+xml=google-chrome.desktop;firefox.desktop;!g" /etc/gnome/defaults.list `; \
       `sed -i "s!^"${test_2[0]}"!text/html=google-chrome.desktop;firefox.desktop;!g" /etc/gnome/defaults.list `; \
       `sed -i "s!^"${test_3[0]}"!x-scheme-handler/http=google-chrome.desktop;firefox.desktop;!g" /etc/gnome/defaults.list `; \
       `sed -i "s!^"${test_4[0]}"!x-scheme-handler/https=google-chrome.desktop;firefox.desktop;!g" /etc/gnome/defaults.list `;;
    "Chromium") `sed -i "s!^"${test_1[0]}"!application/xhtml+xml=chromium-browser.desktop;firefox.desktop;!g" /etc/gnome/defaults.list `; \
       `sed -i "s!^"${test_2[0]}"!text/html=chromium-browser.desktop;firefox.desktop;!g" /etc/gnome/defaults.list `; \
       `sed -i "s!^"${test_3[0]}"!x-scheme-handler/http=chromium-browser.desktop;firefox.desktop;!g" /etc/gnome/defaults.list `; \
       `sed -i "s!^"${test_4[0]}"!x-scheme-handler/https=chromium-browser.desktop;firefox.desktop;!g" /etc/gnome/defaults.list `;;
    "Midori") `sed -i "s!^"${test_1[0]}"!application/xhtml+xml=midori.desktop;firefox.desktop;!g" /etc/gnome/defaults.list `; \
       `sed -i "s!^"${test_2[0]}"!text/html=midori.desktop;firefox.desktop;!g" /etc/gnome/defaults.list `; \
       `sed -i "s!^"${test_3[0]}"!x-scheme-handler/http=midori.desktop;firefox.desktop;!g" /etc/gnome/defaults.list `; \
       `sed -i "s!^"${test_4[0]}"!x-scheme-handler/https=midori.desktop;firefox.desktop;!g" /etc/gnome/defaults.list `;;
    esac
unset file
}

FILES() {
echo "#Finding Large Files..."

# Main window dialogue
INSTALLER_TITLE="Find files within a range
---------------------------------------------------------------------------------------------------------------------------
This will find and list all files on your system in a range.

<b>Do not remove a file from your system unless you know what you are doing.
This is not a removal tool, it is provided as information only.</b>

When you click on Yes, this window will close and the process will begin.
---------------------------------------------------------------------------------------------------------------------------
Click on Yes to continue or No to cancel the system scan.\nWould you like to continue?"

# Call the zenity window icon location.
INSTALL_ICON="/usr/share/pixmaps/litecleaner.png"
APPNAME="Find files in a range"

      zenity --question --title="$APPNAME" --window-icon="${INSTALL_ICON}" --text="${INSTALLER_TITLE}"
        if [ "$?" -eq "0" ]; then

# Set the file size range
scale_min=$(zenity --title="Select the minimum file size" --scale --text="Select the minimum file size (in MB)" --min-value=25 --max-value=5000 --value=25 --step=25)

if [ "${PIPESTATUS[0]}" -ne "0" ]; then
      return
fi

size_min=$(echo $scale_min | sed "s/.*/+&M/")

scale_max=$(zenity --title="Select the maximum file size" --scale --text="Select the maximum file size (in MB)\nMinimum file size is $size_min\B" --min-value=25 --max-value=5000 --value=51 --step=25)

if [ "${PIPESTATUS[0]}" -ne "0" ]; then
      return
fi

while [ $scale_max -le $scale_min ]; do
      zenity --info --title="$APPNAME" --window-icon="${INSTALL_ICON}" --text="Maximum value must never be smaller or equal  to minimum value.\nSet it again or click Cancel to exit."
            scale_max=$(zenity --title="$APPNAME" --scale --text="Select the maximum file size.\nMinimum file size is $size_min\B" --min-value=25 --max-value=5000 --value=51 --step=25)

            if [ "${PIPESTATUS[0]}" -ne "0" ]; then
                  return
            fi
done

size_max=$(echo $scale_max | sed "s/.*/-&M/")

find_large=$(gksudo "stdbuf -oL /bin/bash \-c '(sudo find / -size $size_min -size $size_max -exec du -mh {} + 2>&1 | grep [0-9][MG] | sort -h -r ) 2>&1 | tee /var/log/findfilesrange.log'" |
stdbuf -oL sed -e '/\*$/ s/^/# /p'|
zenity --progress --title="Please wait whilst your system is scanned..." --pulsate \
--width=600 --auto-close )

            if [ "${PIPESTATUS[0]}" -ne "0" ]; then
              zenity --error \
              --title="Error" --text="$APPNAME has failed."
             return
            fi
          else
            return
          fi

PROCEED=$(zenity --question --title="$APPNAME" --window-icon=/usr/share/icons/zenity-llcc.png --text="Scan complete.\n\nWould you like to view the results?"; echo $?)
if [ ${PROCEED} -eq 1 ]; then
      zenity --info --title="Scan Complete" --window-icon="${INSTALL_ICON}" --text="Click OK to close."
else
    leafpad /var/log/findfilesrange.log &
fi
}

KERNELS() {
# Check current Kernel
CURKERNEL=$(uname -r|sed 's/-*[a-z]//g'|sed 's/-386//g')

# Define what Kernel packages to look for
LINUXPKG="linux-(image|headers|ubuntu-modules|restricted-modules)"
METALINUXPKG="linux-(image|headers|restricted-modules)-(generic|i386|i686|server|common|rt|xen)"

# Find old Kernels
OLDKERNELS=$(dpkg -l|awk '{print $2}'|grep -E $LINUXPKG |grep -vE $METALINUXPKG|grep -v $CURKERNEL)

# Check if there are old Kernels
echo $OLDKERNELS | grep linux*
if [ "${PIPESTATUS[1]}" -ne "0" ]; then
    zenity --info --title="Results" --text="No additional kernels found"
    return
fi

# sed command adds all FALSE entries in the column 'Select'
zen=(`echo "$OLDKERNELS" | sort | sed -e  's/^/FALSE\n/'`)

# Main window dialogue
DIALOG_TEXT="This will remove kernels you no longer wish to use.

Be sure to select both the header and the image for each version of
the kernel that you wish to remove.

When you click on Remove, this window will close and the process will begin.

Click on Cancel to halt the cleaning process."

# Call the zenity window icon location.
ic="/usr/share/icons/zenity-llcc.png"
APPNAME="Kernel Cleaner"

# Call the dialog. Don't change the separator here!
okernel=$(zenity --window-icon="$ic" --list --checklist --separator=" " --width=500 --height=380   --column="Select" --column="Kernel List" \
--text="${DIALOG_TEXT}" --title="$APPNAME" --ok-label="Remove" --cancel-label="Cancel" "${zen[@]}" )

# If cancel is clicked then exit
if [ "${PIPESTATUS[0]}" -ne "0" ]; then
     return
fi

# Check if anything is selected
echo $okernel | grep linux*
if [ "${PIPESTATUS[1]}" -ne "0" ]; then
    zenity --info --title='Cleaner' --text='Nothing was selected.'
    return
fi

zenity --question --title="$APPNAME"  --text="Do you want to proceed? You are about to remove:\n$okernel"
if [ "$?" -eq "0" ]; then
      sudo apt-get purge -y $okernel | zenity --progress --title='Removing Additional Kernels' --text='Removing...' --no-cancel --pulsate --width=400 --auto-close --auto-kill

                        if [ "${PIPESTATUS[0]}" -ne "0" ]; then
                       
                                        zenity --error \
                                        --title="Error" --text="$APPNAME has failed."
                                        return
                                fi

                else

                                        return
                fi

PROCEED=$(zenity --info --title="$APPNAME" --window-icon=/usr/share/icons/zenity-llcc.png --width=270 --text="The cleaner has finished."; echo $?)
if [ ${PROCEED} -eq 1 ]; then
    zenity --info --title="$APPNAME" --window-icon="${INSTALL_ICON}" --text="$APPNAME Complete."
    return
else
    return
fi
}

FIXBOOTUP() {
    echo "#Fixing the bootup, this might take a while..."
# Check LL version
LL_VERSION=$(awk '{print $3}' /etc/llver 2>/dev/null|| echo "Unknown")
case $LL_VERSION in
2.0)
title="Linux Lite 2.0"
black=
white=
brown=
blue=
;;
2.2)
title="Linux Lite 2.2"
black="0x000000"
white="0xffffff"
brown="0xffff00"
blue="0x000000"
;;
2.4)
title="Linux Lite 2.4"
black=
white=
brown=
blue=
;;
Unknown)
zenity --info --title="Bootup fix" --text="Unknown OS"
return
;;
*)
zenity --info --title="Lite Tweaks" --text="Bootup fix\nRelease not supported!"
return
;;
esac

sudo sed -i "s/^title=.*$/title=$title/;s/^black=.*$/black=$black/;s/white=.*$/white=$white/;s/^brown=.*$/brown=$brown/;s/^blue=.*$/blue=$blue/" /lib/plymouth/themes/ubuntu-text/ubuntu-text.plymouth
            if [ "${PIPESTATUS[0]}" -ne "0" ]; then
                        echo "#Error"
                    sleep 1
                                        zenity --error \
                                        --title="Error" --text="There was an error while\nFixing the bootup!\nUnable to write to /etc/lsb-release"
                    return
                        fi

sudo update-initramfs -u
            if [ "${PIPESTATUS[0]}" -ne "0" ]; then
                        echo "#Error"
                    sleep 1
                                        zenity --error \
                                        --title="Error" --text="There was an error while\nFixing the bootup!\nStatus: update-initramfs fail."
                    return
                        fi

echo "Linux Lite $LL_VERSION LTS \n \l" | sudo tee /etc/issue
            if [ "${PIPESTATUS[0]}" -ne "0" ]; then
                        echo "#Error"
                    sleep 1
                                        zenity --error \
                                        --title="Error" --text="There was an error while\nFixing the bootup!\nUnable to write to /etc/issue"
                    return
                        fi

sudo sed -i 's/^DISTRIB_DESCRIPTION=.*$/DISTRIB_DESCRIPTION="Linux Lite '"$LL_VERSION"'"/g' /etc/lsb-release
            if [ "${PIPESTATUS[0]}" -ne "0" ]; then
                        echo "#Error"
                    sleep 1
                                        zenity --error \
                                        --title="Error" --text="There was an error while\nFixing the bootup!\nUnable to write to /etc/lsb-release"
                    return
                        fi
}

FIXAPT() {
    echo "#Stage 1: Repairing the package system."$"\nPlease wait, this might take some time..."
sudo apt-get clean
cd /var/lib/apt
sudo mv lists lists.old
sudo mkdir -p lists/partial
sudo apt-get clean
sudo apt-get update
            if [ "${PIPESTATUS[0]}" -ne "0" ]; then
                        echo "#Error"
                    sleep 2
                                        zenity --error \
                                        --title="Error" --text="There was an error while\nFetching package lists!"
                    return
                        fi
    echo "#Stage 2: Repairing the package system."$"\nPlease wait, this might take some time..."

sudo apt-get install -f
            if [ "${PIPESTATUS[0]}" -ne "0" ]; then
                        echo "#Error"
                    sleep 2
                                        zenity --error \
                                        --title="Error" --text="There was an error while\nInstalling partialy installed packages!"
                    return
                        fi
    echo "#Stage 3: Repairing the package system."$"\nPlease wait, this might take some time..."

# Check for /etc/apt/sources.list.save file.If the file is not present then run...
if [ !  -f /etc/apt/sources.list.save ]; then
    sudo mv /etc/apt/sources.list /etc/apt/sources.list.bak
    sudo touch /etc/apt/sources.list
    sudo add-apt-repository -y "deb http://archive.ubuntu.com/ubuntu $(lsb_release -sc) main universe restricted multiverse"
fi

sudo rm /etc/apt/sources.list
sudo cp /etc/apt/sources.list.save /etc/apt/sources.list
sudo apt-get update

    echo "#Final Stage: Repairing the package system."$"\nCompleting Repair..."

sudo dpkg --configure -a
}

    x=0
    for k in "${!ARRAYC[@]}"; do  x=$(( $x + 1 )); done  # Get the total number of selected items in the array

    TOTAL_LINES=$x

    printf '%s \n' "${ARRAYC[@]}"|
    while read  line
        do
            $line     # Execute functions one by one
            if [ $? = 1 ]; then
                zenity --info --title="Lite Tweak" --text="Error:\n${line}"
            fi   
        let i++
         (( PERCENTAGE = 100 \* ${i} / ${TOTAL_LINES} ))
         echo "$PERCENTAGE"

        if [ "$PERCENTAGE" == "100" ]; then
            echo "#Done"
            sleep 2
        fi
   
    done| zenity --progress  --title="Lite Tweaks" --auto-kill --auto-close --width=300 --no-cancel

unset ARAYC
unset FRM
unset okernel
unset PROCEED
unset APPNAME
unset INSTALLER_TITLE
Reply
#50

Thank you misko, can you please send these full scripts to github, so I can see the changes before packaging. Cheers :)

Download your free copy of Linux Lite today.

Jerry Bezencon
Linux Lite Creator

"Do not correct a fool, or he will hate you; correct a wise man and he will appreciate you."

[Image: X5qGkCg.png]

[Image: 0op1GNe.png] [Image: LgJ2mtP.png] [Image: vLZcFUE.png] [Image: lrUHro3.jpg]
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)