Mengembalikan seperti keadaan semula mungkin sangat berguna bagi komputer dengan banyak pengguna, selain memudahkan admin untuk mengelola, juga bisa digunakan untuk menjaga tampilan desktop.
Pada sistem operasi seperti windows memang tersedia sebuah aplikasi yang berfungsi seperti tersebut diatas, tetapi pada sistem operasi Linux kebanyakan masih berbentuk script shell yang membackup settingan desktop dan mengembalikannya pada saat user login kembali.
Banyak yang sudah menulis script seperti ini, seperti mas Gwijayas dengan python. Tapi kali ini saya mencoba menulis script versi saya pribadi. Idenya adalah tidak hanya membackup dan mengembalikan settingan desktop seperti semula, tapi juga mengembalikan xsplash, GDM Theme, dan mungkin nantinya aplikasi yang terinstall.
Untuk versi yang saya release untuk pertama kalinya ini ada beberapa fungsi yang masih dalam percobaan, di mesin saya berjalan dengan baik tapi entah di mesin anda, saya memang butuh bantuan untuk testing dan sumbangan ide dan code.
FreezeDesktop, aplikasi utiliti kecil tersebut saya namai. Sebenarnya saya berkeinginan menulis aplikasi ini di python, selain mudah *katanya* juga nantinya akan berkembang menjadi aplikasi berbasis GUI. Mungkin ada yang bersukarela untuk memporting tool ini ke python saya akan sangat berterima kasih sebelumnya, saya juga sekalian ikut belajar.
Berikut kode dari FreezDesktop.
#!/bin/bash
#
# freezedesktop.sh
# Freeze Your Desktop
# Version 1.0
# http://adzymaniac.web.id/freezedesktop
#
# Copyright (C) 2010 Aji Kisworo Mukti
# Release under GPLv3
#
#
# FreezeDesktop 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 of the License, or (at your option) any later version.
# FreezeDesktop 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 along with GNOME Terminal; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
export USER=`whoami`
export HOME=/home/$USER
export DIRBACKUP=/home/$USER/.freeze
export XSPLASHDIR=/usr/share/images/xsplash
#if [[ $EUID -ne 0 ]]; then
# echo "This script must be run as root" 1>&2
# exit 1
#fi
about() {
echo ""
echo "Freeze Your Desktop"
echo "Copyright (C) 2010 Aji Kisworo Mukti"
echo "http://adzymaniac.web.id"
echo "Release under GPLv3"
echo ""
echo "Try with options:"
echo "--make Make backup desktop settings"
echo "--apply Applying all desktop settings"
echo ""
}
create_dir_backup(){
#echo "Checking backup directory..."
#sleep 2
#if [ -d "$DIRBACKUP" ]; then
# echo "Backup directory exist! skipping."
# sleep 2
#fi
#if [ ! -d "$DIRBACKUP" ]; then
# echo "Backup directory doesn't exist! creating.."
echo "Creating backup directory...$DIRBACKUP"
sleep 2
mkdir -v -p $DIRBACKUP
mkdir -v -p $DIRBACKUP/xsplash
mkdir -v -p $DIRBACKUP/dotconfig
#fi
}
check_backup_dir(){
echo "Checking backup files..."
sleep 2
if [[ -e "$DIRBACKUP" ]]; then
echo "Backup files exist! removing."
sleep 2
rm -rf $DIRBACKUP
fi
#if [ ! -d "$DIRBACKUP" ]; then
# echo "Backup files doesn't exist! creating.."
# sleep 2
create_dir_backup
#fi
}
checkSum() {
file=`basename $1`
dir=`dirname $1`
(cd $dir && md5sum -c -- $file >/dev/null 2>&1 && echo "$file OK"
echo "$file Changed" & cp $BACKUPDIR/xsplash/$file .)
}
calcSum() {
file=`basename $1`
dir=`dirname $1`
(cd $dir && md5sum -b -- $file > $file.md5 2>/dev/null && echo "$file CALCULATED"
echo "$file ERROR")
}
find_process() {
while read; do
#echo $REPLY
if test -n "`echo $REPLY
grep '\.md5`"; then
checkSum $REPLY
else
if test ! -f "$REPLY.md5"; then
calcSum $REPLY
fi
fi
done
}
current_xsplash(){
echo "Checking xsplash theme..."
# for file in /usr/share/images/xsplash/*; do
# md5sum $file > $DIRBACKUP/$file.md5
# done
find $XSPLASHDIR -type f
find_process;
}
backup_xsplash(){
current_xsplash
echo "Backuping xsplash theme..."
sleep 2
sudo cp $XSPLASHDIR/*.* $BACKUPDIR/xsplash
}
current_gdm(){
sleep 2
GDMTHEME=`sudo -u gdm gconftool-2 --get /desktop/gnome/interface/gtk_theme`
GMDICON=`sudo -u gdm gconftool-2 --get /desktop/gnome/interface/icon_theme`
GDMBACKGROUND=`sudo -u gdm gconftool-2 --get /desktop/gnome/background/picture_filename`
}
backup_gdm() {
current_gdm
echo "export GDMTHEMEASLI=$GDMTHEME" > $BACKUPDIR/gdm
echo "export GDMICONASLI=$GMDICON" >> $BACKUPDIR/gdm
echo "export GDMBACKGROUNDASLI=$GDMBACKGROUND" >> $BACKUPDIR/gdm
chmod +x $BACKUPDIR/gdm
}
apply_gdm(){
current_gdm
echo "Restoring GDM Theme..."
./$BACKUPDIR/gdm
if [[ $GDMTHEME != $GDMTHEMEASLI ]]; then
sudo -u gdm gconftool-2 --set --type string --set /desktop/gnome/interface/gtk_theme $GDMTHEMEASLI;
fi
if [[ $GDMICON != $GDMICONASLI ]]; then
sudo -u gdm gconftool-2 --set --type string --set /desktop/gnome/interface/icon_theme $GDMICONASLI;
fi
if [[ $GDMBACKGROUND != $GDMBACKGROUNDASLI ]]; then
sudo -u gdm gconftool-2 --set --type string --set /desktop/gnome/background/picture_filename $GDMBACKGROUNDASLI;
fi
}
backup_gconf(){
sudo gconftool-2 --dump / > $BACKUPDIR/dump_gconf.xml
}
apply_gconf(){
echo "Restoring / of Gconf..."
sudo gconftool-2 --load $BACKUPDIR/dump_gconf.xml
}
backup_dot_config(){
dot=( .bash_history .bash_logout .bashrc .cache .config .evolution .fontconfig .gnome2 .gnome2_private .local .mozilla .nautilus .openoffice.org .profile .update-notifier )
for index in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
do
echo " "
cp -p $HOME/${dot[index]} $BACKUPDIR/dotconfig/
done
}
apply_dot_config(){
echo "Restoring dot Config..."
cp -p $BACKUPDIR/dotconfig/.* $HOME
}
if [[ $1 == "--make" ]];then
check_backup_dir
# backup_xsplash
backup_gdm
backup_gconf
backup_dot_config
elif [[ $1 == "--apply" ]];then
# current_xsplash
apply_gdm
apply_gconf
backup_dot_config
else
about
exit 0
fi
exit 0
Atau bisa download script saya di http://adzymaniac.web.id/freezedesktop