PDA

View Full Version : [SOLVED] Script: update your skydome hourly


chewearn
May 15th, 2008, 12:06 PM
I run my desktop with compiz fusion cube set at 100% transparency. I put a nice picture as the skydome, which serve as the wallpaper in this set-up.

However, I got tired of looking at the same old desktop background all the time, and I'm too lazy to change it, so I wrote a bash script that update the skydome hourly.

Tweak the first part of the script to match your pictures and files location.


#!/bin/bash

# -------- Set the following variables to your own config ----------------

# Note: filenames must be 00, 01, ..., 12; 00 is midnight, 12 is noon
FILEEXT=.jpg
FILEPATH=$HOME/arts/skydome/

# ------------------------------------------------------------------------


GCONFPATH=/apps/compiz/plugins/cube/screen0/options/skydome_image

sleep 30

while [ 1 ]; do
HOUR=`date +"%H"`

# convert 24 hours time to "hours to/from noon"
if [ $HOUR -gt '12' ]; then
HOUR1=$[24-$HOUR]
if [ $HOUR1 -lt '10' ]; then
HOUR1=0$HOUR1
fi
else
HOUR1=$HOUR
fi

gconftool-2 -s -t string $GCONFPATH $FILEPATH$HOUR1$FILEEXT

# sleep until next hour
while [ 1 ]; do
MIN=$[60-$[`date +"%M"`]]m
HOUR1=`date +"%H"`
if [ $HOUR -ne $HOUR1 ]; then
break;
fi

sleep $MIN
done
done

Here is a set of pictures:
http://chew4097.googlepages.com/home

Note:
The original pictures are png, but googlepages converted it to jpg. :(
It's not ground breaking, but I'm not an artist either. :mrgreen:

If you find bug please tell me.
If you created your own set of pictures, I would love to download them. :mrgreen:

.

dustoulis
April 29th, 2010, 03:52 PM
Hello there. I was searching throughout google for a plugin or something that would change automatically the skydome. Obviously you were trying the same thing and therefore u created the script. Unfortunatelly im a newbie on Linux and i would really apreciate a guide on how i can make this script work for me, cause i have no idea. And which value i need to change to make it change in different period of time?

Thnx.

chewearn
April 30th, 2010, 07:49 AM
hi dustoulis
Mmm, has it been two years since I wrote this script? How time flies.

When I wrote this script I have very limited knowledge of Linux. The timing for changing the skydome is hardcoded and I used "sleep" command to set the interval. That's not a good solution as it turned out. A better solution is to use built-in Linux anacron function (anacron is this is similar to the Scheduler in Windows).

By default, anacron is accessed from the command line. But a GUI is available to be installed separately, called the "gnome-schedule". You can find this application via the Synaptic Package Manager. Using gnome-schedule, it should be self-explanatory how to set-up to run a recurring task.

As to the task itself, you will still need a script (but should be simpler that the one I had previously, because there is no need to fiddle with the timing). Here is a sample, bearing in mind I hacked this out in 10 minutes without testing. :mrgreen:


#!/bin/bash

# -------- Set the following variables to your own config ----------------

# Note: filenames must be 00, 01, ..., 12; 00 is midnight, 12 is noon
FILEEXT=.jpg
FILEPATH=$HOME/arts/skydome/

# ------------------------------------------------------------------------

GCONFPATH=/apps/compiz/plugins/cube/screen0/options/skydome_image

HOUR=`date +"%H"`

# convert 24 hours time to "hours to/from noon"
if [ $HOUR -gt '12' ]; then
HOUR1=$[24-$HOUR]
if [ $HOUR1 -lt '10' ]; then
HOUR1=0$HOUR1
fi
else
HOUR1=$HOUR
fi

gconftool-2 -s -t string $GCONFPATH $FILEPATH$HOUR1$FILEEXT
Copy/paste the script to a text file, save the file somewhere out of the way (e.g. "$HOME/bin"). Set the executable bit for the file, then set the task to run recurrently.