This forum has been archived. All content is frozen. Please use KDE Discuss instead.

KDE 4.2 Default widget and desktop restore

Tags: None
(comma "," separated)
vahid
Registered Member
Posts
32
Karma
0
If you are new to KDE or if you have recently helped someone move over to KDE, you may find from time to time getting used to environment can cause issues, i.e. unusable desktop, menus all missing etc etc..
Or if widgets have crashed and you have never managed to get them back on and wish to go back to the beginning like a new profile without removing all your useful information menus etc then I have written a script that does this for you.
open a shell
in your home folder
mkdir scripts
cd scripts
vi restore-plasma.sh
copy and paste below code into it
chmod 755 restore-plasma.sh
then at any point run (as the user not root or other user but user with messed up config) run :
cd ~/scripts
./restore-plasma.sh
[if you wish to restore back the config that was last backed up from the last time the script was ran] run
./restore-plasma.sh -restore

Hope it is of some use - you may have a family member who consistently messes up their desktop and having this script accessible on their desktop or sym linked to home-folder so its viewable can mean they can fix their own desktop..

Code: Select all
#!/bin/sh                                     
#PLEASE ENSURE YOU RUN THIS SCRIPT AS YOUR USERNAME DO NOT SUDO OR RUN AS ROOT
#If you are new to KDE you like others will probably                           
#messup desktop and will not know how to restore it to its defaults           
#use this script which to backup current plasma config and restore it to how it was when you first loaded up.
# Two variables $plasmarc and $appletrc replaces .kde/share/config/plasmarc  .kde/share/config/plasma-appletrc

#Your current files - please  READ FIRST LINE RUN AS YOU SO WHOAMI HAS CORRECT USER
user=`whoami`                                                                     
if [ $user = "root" ]; then echo "error root can not run this, run as normal user"; exit; fi;


home="/home/$user";
plasmarc="$home/.kde/share/config/plasmarc"
appletrc="$home/.kde/share/config/plasma-appletsrc"
overlay="$home/.kde/share/config/plasma-overlayrc"
appoverlay="$home/.kde/share/config/plasma-overlay-appletsrc"
dest="$home/.kde/share/config/"                             
backup="$home/scripts/backup"                               
current=`date +%Y%m%d+%H%M%S`                               

if [ "$1" = "" ]
then           
mkdir -p $home/scripts/backup


if test -e $plasmarc
then                 
  if  test -e $backup/plasmarc
  then                       
   echo "_________________________________________________________________________"
   echo "err already backed up some config I will not overwrite your original work"
   echo "_________________________________________________________________________"
   echo "Current backup folder listing:"                                           
   ls -l $backup/plasma*                                                           
   echo "_________________________________________________________________________"
  else                                                                             
  mv $plasmarc $backup/                                                           
  mv $appletrc $backup/                                                           
  mv $overlay $backup/                                                             
  mv $appoverlay $backup/                                                         
  echo "copied $plasmarc $appletrc $overlay $appover to -> $backup"               
  fi                                                                               
fi                                                                                 

             

plasmarcn="[PlasmaViews][2]npanelVisibility=0nn[ViewIds]n1=1n3=2"

appletrcn="[Containments][1]n activity=n desktop=0n formfactor=0n geometry=0,0,1280,800n
immutability=1n location=0n plugin=desktopn screen=0n wallpaperplugin=imagen
wallpaperpluginmode=SingleImagen zvalue=0n n [Containments][1][Applets][2]n
activity=n desktop=-1n formfactor=0n  geometry=4,4,600,400n
immutability=1n location=0n plugin=folderviewn screen=-1n zvalue=-4n n
[Containments][1][Applets][2][Configuration]n activity=n desktop=-1n formfactor=0n
geometry=4,4,600,400n immutability=1n location=0n plugin=folderviewn screen=-1n
url=desktop:/n zvalue=0n n[Containments][1][Wallpaper][image]n
slideTimer=600n slidepaths=/usr/share/wallpapers/n userswallpapers=n 
wallpaper=/usr/share/wallpapers/Airn wallpapercolor=56,111,150n wallpaperposition=0n n
[Containments][3]n activity=n desktop=-1n formfactor=2n geometry=0,-41,1280,35n
immutability=1n location=4n plugin=paneln screen=0n  zvalue=150n n
[Containments][3][Applets][10]n geometry=1074,3,32,32n immutability=1n plugin=notifiern
 zvalue=0n n [Containments][3][Applets][11]n geometry=1110,3,32,32n immutability=1n
plugin=batteryn zvalue=0n n[Containments][3][Applets][12]n geometry=1146,3,32,32n immutability=1n
plugin=networkmanagementn zvalue=0n n[Containments][3][Applets][13]n geometry=1182,3,76,32n
immutability=1n plugin=digital-clockn zvalue=0n n[Containments][3][Applets][13][Configuration]
[PopupApplet]n  DialogHeight=273n DialogWidth=269n n
[Containments][3][Applets][4]n geometry=0,3,32,32n immutability=1n plugin=launchern
zvalue=0n n[Containments][3][Applets][4][Shortcuts]n global=Alt+F1n n
[Containments][3][Applets][5]n geometry=36,3,32,32n immutability=1n
plugin=quickaccessn zvalue=0n n
[Containments][3][Applets][6]n geometry=72,3,751,32n immutability=1n
plugin=tasksn zvalue=0n n
[Containments][3][Applets][7]n geometry=827,3,39,32n immutability=1n
plugin=pagern zvalue=0n n
[Containments][3][Applets][8]n geometry=870,3,32,32n immutability=1n
plugin=showdashboardn zvalue=0n n
[Containments][3][Applets][9]n geometry=906,3,164,32n immutability=1n
plugin=systemtrayn zvalue=0n n
[Containments][3][Applets][9][Configuration][PopupApplet]n DialogHeight=11n
DialogWidth=0n n Containments][3][Configuration]n maximumSize=1280,35n
minimumSize=1280,35n n"                                   

echo $plasmarcn > $plasmarc
echo $appletrcn > $appletrc

echo "KDE DEFAULT DESKTOP WIDGETS INSTALLED !!"
echo "run this script with -restore after it i.e.:"
echo "$0  -restore"
echo "this should put back your widgets as it was before reverting it"
echo;echo
echo "KDM ABOUT TO RESTART Press any key to continue - using kdmctl suicide "
read input
#This will restart KDE like the old ctrl alt backspace
kdmctl suicide;

else

if [ "$1" = "-restore" ]
then
echo "ok restoring"
cp -p $backup/plasmarc  $backup/plasma-appletsrc $backup/plasma-overlayrc
cp -p $backup/plasma-overlay-appletsrc $dest/
mv $backup/plasmarc  $backup/plasmarc.$current
mv $backup/plasma-appletsrc  $backup/plasma-appletsrc.$current
mv $backup/plasma-overlayrc $backup/plasma-overlayrc.$current
mv $backup/plasma-overlay-appletsrc $backup/plasma-overlay-appletsrc.$current
echo "OLD FILES restored;
echo;echo
echo "KDM ABOUT TO RESTART Press any key to continue - using kdmctl suicide "
read input
kdmctl suicide;

else
echo "nothing to do "
fi
fi



I have been testing it and it seems to work fine for me ....

Last edited by vahid on Mon Jun 22, 2009 10:36 pm, edited 1 time in total.
User avatar
toad
Global Moderator
Posts
1258
Karma
7
OS
Good stuff. However, disappearing settings should not occur unless you are using ext4


Debian testing
vahid
Registered Member
Posts
32
Karma
0
toad wrote:Good stuff. However, disappearing settings should not occur unless you are using ext4


make that two items
ext4 and kids using KDE on ext3 :)

seriously I got handed a machine running kde obvious novice users and somehow the kid had managed to destroy dekstop, when I finally got in after resetting their pass to blank.. i found that it was totally unusuable two widgets locked and not responding to any mouse clicks the task bar was well half there and not responding
It was a mess I just made a new user for them and didnt look back, hence the reason for writing this script.
ehlenfeld
Registered Member
Posts
1
Karma
0
I tried running your script but got this error;

./restore-plasma.sh: line 115: unexpected EOF while looking for matching `"'
./restore-plasma.sh: line 118: syntax error: unexpected end of file

I've tried to edit it in Kate but still get the same message, not sure if it's the html that is messing up the script or what.

Any ideas?
Thanks
totem
Registered Member
Posts
1
Karma
0
OS
You got these error messages because the closing '"' is missing in line 108.

Thanks for the script vahid, it saved me lots of time.
User avatar
einar
Administrator
Posts
3402
Karma
7
OS
Notice that in versions >= 4.4 Plasma comes with "templates" that can be used to restore the default layouts.


"Violence is the last refuge of the incompetent."
Image
Plasma FAQ maintainer - Plasma programming with Python


Bookmarks



Who is online

Registered users: Bing [Bot], Evergrowing, Google [Bot]