09-07-2014, 07:13 PM
(09-07-2014, 11:12 AM)Valtam link Wrote: Have started on some of the scripts. Here's what the apt cache cleaner looks like, printing the directory size.Nice.
I've had some experiments on removing individual old kernels instead of all old kernels.
Code:
#! /bin/bash
ic="/usr/share/icons/zenity-llcc.png"
CURKERNEL=$(uname -r|sed 's/-*[a-z]//g'|sed 's/-386//g')
LINUXPKG="linux-(image|headers|ubuntu-modules|restricted-modules)"
METALINUXPKG="linux-(image|headers|restricted-modules)-(generic|i386|server|common|rt|xen)"
OLDKERNELS=$(dpkg -l|awk '{print $2}'|grep -E $LINUXPKG |grep -vE $METALINUXPKG|grep -v $CURKERNEL)
# sed command adds all FALSE entries in the column 'Select'
# separator sets the output of the checklist, "\n" can also be used
selection=$(echo "$OLDKERNELS" | sed -e 's/^/FALSE\n/' | zenity --window-icon="$ic" --list --checklist --separator=" " --width=890 --height=400 --column='Select' --column='Kernel' \
--text=' ' --title="Lite Cleaner" --ok-label="Clean" --cancel-label="Quit" )
# Next line just tests the output of a checklist
echo "$selection"
# Next line deletes all of the selected kernels
# gksudo "$(echo "$selection" | sed -e 's/^/sudo apt-get purge -y /')"