FreezeDesktop : deepfreeze di Linux

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

23 Responses - Add Yours+

  1. garasinet says:

    Pertamax gan… izin sedot.. :D

    tararengkyu buat scriptnya.. ane mau nyobain di karmic dlu ya.. thx !!

    Firefox 3.5.3 Firefox 3.5.3 Ubuntu 9.10 Ubuntu 9.10
    Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.3) Gecko/20091020 Ubuntu/9.10 (karmic) Firefox/3.5.3
  2. garasinet says:

    mas aji… cara pakenya gmn? di konsol aku ketik ./freezedesktop.sh trus muncul ada dua opsi.. gtu ya?

    Try with options:
    –make Make backup desktop settings
    –apply Applying all desktop settings

    trus, cara unfreezenya gmn pula? hehe..

    maklum aja mas.. amatiran di linux nih.. :)

    Firefox 3.5.8 Firefox 3.5.8 Ubuntu 9.10 Ubuntu 9.10
    Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.8) Gecko/20100214 Ubuntu/9.10 (karmic) Firefox/3.5.8
  3. buat dulu backupnya dengan –make.
    trus pasang di startup applications dengan –apply

    Firefox 3.5.3 Firefox 3.5.3 Ubuntu 9.10 Ubuntu 9.10
    Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.3) Gecko/20090924 Ubuntu/9.10 (karmic) Firefox/3.5.3
  4. ditunggu kabarnya :)

    Firefox 3.5.3 Firefox 3.5.3 Ubuntu 9.10 Ubuntu 9.10
    Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.3) Gecko/20090924 Ubuntu/9.10 (karmic) Firefox/3.5.3
  5. Fajar says:

    WaH…
    SangaR GaN….
    Benar Benar MemberikaN Saya Inspirasi…
    HEhehe

    Firefox 3.0.18 Firefox 3.0.18 Windows Vista Windows Vista
    Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.9.0.18) Gecko/2010020220 Firefox/3.0.18 (.NET CLR 3.5.30729)
  6. @fajar : maturnuwun bro. saya sangat berharap feedback dr masnya berupa ide atau kode..

    Opera Mini 5.0.16823 Opera Mini 5.0.16823 J2ME/MIDP Device J2ME/MIDP Device
    Opera/9.80 (J2ME/MIDP; Opera Mini/5.0.16823/958; U; en) Presto/2.4.15
  7. FreezeDesktop dalam proses porting ke python… :)

    Google Chrome 4.0.249.43 Google Chrome 4.0.249.43 GNU/Linux GNU/Linux
    Mozilla/5.0 (X11; U; Linux i686; en-US) AppleWebKit/532.5 (KHTML, like Gecko) Chrome/4.0.249.43 Safari/532.5
  8. wejick says:

    cobain ini pak sisrestore.googlecode.com . ada gui sederhananya lho.
    please join us

    Opera Mini 4.2.14912 Opera Mini 4.2.14912 J2ME/MIDP Device J2ME/MIDP Device
    Opera/9.80 (J2ME/MIDP; Opera Mini/4.2.14912/958; U; en) Presto/2.4.15
  9. wejick says:

    cobain ini pak
    sisrestore.googlecode.com .
    ada simple gui front end nya lho

    Opera Mini 4.2.14912 Opera Mini 4.2.14912 J2ME/MIDP Device J2ME/MIDP Device
    Opera/9.80 (J2ME/MIDP; Opera Mini/4.2.14912/958; U; en) Presto/2.4.15
  10. kemarin juga sempat berpikiran menyisipkan sedikit dialog GUI, tapi nanggung…insyaallah mau diporting ke python dulu supaya GUInya tidak hanya disisipkan. :)

    Google Chrome 5.0.307.5 Google Chrome 5.0.307.5 GNU/Linux GNU/Linux
    Mozilla/5.0 (X11; U; Linux i686; en-US) AppleWebKit/532.9 (KHTML, like Gecko) Chrome/5.0.307.5 Safari/532.9
  11. keren bos,… ijin utak atik biar bisa jalan di openSUSE KDE :D

    Firefox 3.5.8 Firefox 3.5.8 SuSE SuSE
    Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.8) Gecko/20100204 SUSE/3.5.8-0.1.1 Firefox/3.5.8
  12. monggo om..
    btw KDE ada gconf like-nya gak yah?
    oh iya sekalian diporting ke python om biar nantinya bisa pake pyQT sama pyGTK :D ;)

    Google Chrome 5.0.342.1 Google Chrome 5.0.342.1 GNU/Linux GNU/Linux
    Mozilla/5.0 (X11; U; Linux i686; en-US) AppleWebKit/533.2 (KHTML, like Gecko) Chrome/5.0.342.1 Safari/533.2
  13. Arielz says:

    keren mas, mohon ijin nyobain ..

    Namoroka 3.6.2pre Namoroka 3.6.2pre Ubuntu 9.04 Ubuntu 9.04
    Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.2.2pre) Gecko/20100303 Ubuntu/9.04 (jaunty) Namoroka/3.6.2pre
  14. monggo mas silahkan…

    Google Chrome 5.0.307.5 Google Chrome 5.0.307.5 GNU/Linux GNU/Linux
    Mozilla/5.0 (X11; U; Linux i686; en-US) AppleWebKit/532.9 (KHTML, like Gecko) Chrome/5.0.307.5 Safari/532.9
  15. garasinet says:

    mas aji, script udah saya coba.. sudah di –make & –apply, waktu proses script nampilin pesan “directory not found” trus tak coba restart.. nah, abis restart malah gak bisa masuk GUI mas.. layar monitor item doang.. gak ada pesan error apapun.. T_T ada saran saya mesti ngapain mas aji??

    terimakasih sebelumnya.. :)

    Firefox 3.5.6 Firefox 3.5.6 Windows XP Windows XP
    Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.1.6) Gecko/20091201 Firefox/3.5.6
  16. mungkin bisa dicopas ke sini errornya.

    Firefox 3.5.8 Firefox 3.5.8 Ubuntu 9.10 Ubuntu 9.10
    Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.8) Gecko/20100214 Ubuntu/9.10 (karmic) Firefox/3.5.8
  17. garasinet says:

    maaf mas aji, gak kepikiran buat copy error nya waktu script di make & apply, karena udah gak ngerti mau diapain (blank screen) jadinya saya install ulang pake jaunty, sebelumnya saya pake karmic + desktop xpgnome, mungkin dalam waktu dekat saya bakal coba lagi.. makasih mas :)

    Firefox 3.0.8 Firefox 3.0.8 Ubuntu 9.04 Ubuntu 9.04
    Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.0.8) Gecko/2009033100 Ubuntu/9.04 (jaunty) Firefox/3.0.8
  18. Doni says:

    tutorial keren… makasih yah mas

    Firefox 3.6.2 Firefox 3.6.2 Mac OS X 10.5 Mac OS X 10.5
    Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.5; en-US; rv:1.9.2.2) Gecko/20100316 Firefox/3.6.2
  19. :) sama sama, sering2 aja maen kesini :D

    Google Chrome 5.0.356.2 Google Chrome 5.0.356.2 GNU/Linux GNU/Linux
    Mozilla/5.0 (X11; U; Linux i686; en-US) AppleWebKit/533.3 (KHTML, like Gecko) Chrome/5.0.356.2 Safari/533.3
  20. kurt says:

    mantep

    Opera 10.10 Opera 10.10 GNU/Linux GNU/Linux
    Opera/9.80 (X11; Linux i686; U; en) Presto/2.2.15 Version/10.10
  21. @kurt : tengkyu (worship)

    Google Chrome 5.0.356.2 Google Chrome 5.0.356.2 GNU/Linux GNU/Linux
    Mozilla/5.0 (X11; U; Linux i686; en-US) AppleWebKit/533.3 (KHTML, like Gecko) Chrome/5.0.356.2 Safari/533.3
  22. dion says:

    hmmm..tak copas nang gedit dadi setengahe warna pink kabeh ji, ono seng salah kayane…
    Untuk warnet urung cucok ji..tambahi maneh, keep trying bro!!

    Firefox 3.5.8 Firefox 3.5.8 Ubuntu 9.10 Ubuntu 9.10
    Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.8) Gecko/20100214 Ubuntu/9.10 (karmic) Firefox/3.5.8
  23. hmm…pink pie?
    ada log nya? aku minta sini. (goodluck)

    Google Chrome 5.0.356.2 Google Chrome 5.0.356.2 GNU/Linux GNU/Linux
    Mozilla/5.0 (X11; U; Linux i686; en-US) AppleWebKit/533.3 (KHTML, like Gecko) Chrome/5.0.356.2 Safari/533.3

Leave a Reply



Nice job!
You now have 30 lives.
Use them wisely, my friend.

Konami Easter Egg by Adrian3.com