plasmabac – When plasma solidifys.

Plasma being a new technology for KDE it can still, at times, behave like a bad child. Alot of you may have noticed that plasma from time to time will have the tendency to cause the desktop to freeze or crash. This usually happens with widgets that have bugs in them or if there are errors in the plasma configuration files. Instead of losing all my plasma configurations anytime plasma goes rogue, I’ve made it a routine to back them up regularly. I decided to build a script that can backup the current plasma configs and then automate it to run once a week. The script will both backup and restore:

plasmabac b
plasmabac r

When you choose to restore, it will give you a list of saved plasma configs by date:

plasmabac r
 0) plasmarcs-2009-10-13.tar.gz
 1) plasmarcs-2009-10-18.tar.gz
 2) plasmarcs-2009-10-23.tar.gz
 3) plasmarcs-2009-10-24.tar.gz
 4) plasmarcs-2009-10-25.tar.gz
 5) plasmarcs-2009-10-29.tar.gz
 6) plasmarcs-2009-11-01.tar.gz
 7) plasmarcs-2009-11-02.tar.gz
Choose the plasma configuration to restore: 

To backup on a weekly basis, add it to the cron jobs:

  57  00  *   *   0       ~/.bin/root/backup/plasmabac b    # w - plsm cnfgs
# |   |   |   |   |   user
# |   |   |   |   weekday (0-6) (Sunday=0)
# |   |   |   month (1-12)
# |   |   day (0-31)
# |   hour (0-23)
# minute (0-59)

The script will automaticaly delete configurations older than two months to prevent overflow.

Enjoy :)

# plasmabac - backup and restore local plasma config


# Use filename as program name

# Text color variables
txtbld=$(tput bold)       # bold
txtund=$(tput sgr 0 1)    # underline
bldblu='\e[1;34m'         # blue
bldred='\e[1;31m'         # red
bldwht='\e[1;37m'         # white
txtrst='\e[0m'            # text reset

plasmarcs=($(find "$userdir"/.kde4/share/config -type f -name "plasma*"))
bkpplasmarcs=($(find "$backdir" -type f -name "plasma*" | sort))
date=$(date +%F)

# Display usage if full argument isn't given
if [[ -z "$@" ]]; then
  echo " $prog b|r - backup or restore plasma configurations"

# Check if the directory exists and user has access to it
if [[ -n $(ls "$backdir" 2>&1 | grep denied) ]]; then
  echo -e "$warn User doesn't have access to the backup directory"
  if [[ ! -d "$backdir" ]]; then
    mkdir "$backdir"
    echo -e "${bldblu}*${txtrst} KDE 4 plasma config backup directory doesn't exist.  Created."

# Delete backups older than two months
if [[ -n "$(find "$backdir" -mtime +60)" ]]; then
  find "$backdir" -mtime +60 -exec rm {} \;
  echo -e "$pass Configurations older than two months deleted"

case $1 in
  b | backup )  tar -czpf "$backdir"/plasmarcs-"$date".tar.gz ${plasmarcs[@]}
                echo -e "$pass Plasma configurations backed up. (${bldwht}$date${txtrst})"
  r | restore ) for((i=0;i<${#bkpplasmarcs[@]};i++)) ; do
                  echo -e " ${txtbld}${i}) ${bkpplasmarcs[$i]##*/}${txtrst}"
                echo -n "Choose the plasma configuration to restore: "
                read restore
                tar -xvf "$selection" -C /
                echo -e "$pass Restored plasma configs: ${txtbld}${bkpplasmarcs[$restore]##*/}${txtrst}"

About Gen2ly

<3's linux

Posted on 2009-11-04, in Linux, Timely. Bookmark the permalink. 2 Comments.

  1. It would take hours, if not downright impoossible to continue their weight loss is by eating a
    portion of fresh grapefruit before each meal 7. A
    lot if how youu die pill has been proven scientifically via ORAC rating.
    If you eat mindlessly without taking charge of your calorie and fat intake each and very
    meal for you to maintain a healthy weight and stay fit.

    It may seem counter-intuitive, but eating fat can help you diet pill.

  1. Pingback: Plasmabac: uno script per il backup delle impostazioni di plasma « Crismon's Blog

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s


Get every new post delivered to your Inbox.

Join 58 other followers

%d bloggers like this: