Sunday, June 28, 2009

Xubuntu desktop wallpaper from a website (NOAA Radar)

This post has been superseded by a newer post. Much of this information is still valid, but the newer post has more detail amd examples, and includes more services.

Living in the midwest, I check the weather radar a lot to protect my laundry drying outside from lots of pesky thunderstorms. So I want to make the radar image my desktop picture in Xubuntu, and to have it automatically update.

To get the image: I'm using It is from the United States National Weather Service and updates every 5-6 minutes.

A shell script to refresh the radar image as the desktop picture:

# This is the path of the final output files that get read by other processes.
# Working files show up here, too. You may wish to create your own directory.
Username=<your username>

# This is the closest weather station for observations. Find your weather 
# station: Format is four letters. 
# All UPPER CASE. For example, 'KMKE' for Mitchell Field in Milwaukee, WI

# This is the closest weather radar. Find your radar:
# Check the link to your weather radar, for example:
# The radar name is in the 'rid=' field. In this example, mkx is Milwaukee, WI
# Format is UPPER CASE. For example, 'MKX' for Milwaukee.

# (OPTIONAL) The height of your top menu bar, in pixels.
# The radar image is padded by this amount on the top edge so the menu doesn't
# block the timestamp in the image.

# Download the radar image.
echo "Weather Update: Downloading the most recent radar image available..."
curl -o $Local_Name $Radar_Url

# (OPTIONAL) Use imagemagick to pad the image top so the timestamp is not 
# blocked by the menu bar.
#convert $Local_Name -background none -splice 0x${Radar_Image_Top_Padding} $Local_Name

# Refresh desktop background with 'xfdesktop -reload'. NOTE - some versions 
# of XFCE flicker all the icons brighter when this occurs, providing visual 
# feedback that the refresh occurred. An Alternate method to avoid the 
# flicker is below.
# The 'DISPLAY=:0.0' prefix is required so root processes like cron and 
# Upstart can process it.
# The 'sudo -u $Username' is required because a root process (like an Upstart 
# trigger) may be trying to change a user's desktop. Sudo changes the command 
# to run as user instead of root. Use your username, of course.
DISPLAY=:0.0 sudo -u $Username xfconf-query -v -c xfce4-desktop -p /backdrop/screen0/monitor0/image-path -s $Local_Name
DISPLAY=:0.0 sudo -u $Username xfdesktop -reload

# Alternate method to avoid the flicker by changing desktop pictures for 
# just a moment, then changing it back.
#DISPLAY=:0.0 sudo -u $Username xfconf-query -v -c xfce4-desktop -p /backdrop/screen0/monitor0/image-path -s /usr/share/xfce4/backdrops/xfce4logo.png
#DISPLAY=:0.0 sudo -u $Username xfconf-query -v -c xfce4-desktop -p /backdrop/screen0/monitor0/image-path -s $Local_Name

I'll save this script as, and make it executable with sudo chmod +x

  1. The DISPLAY=:0.0 element is explained here.
  2. The xfconf-query command, and how to change the background using DBus, are discussed in the XFCE forums

Updating the desktop picture manually:

Since we have it in a shell script already, we can create a .bashrc alias to run the script manually.
nano .bashrc opens the .bashrc for editing.
Add the line alias radar='/home/me/' to the bottom of the file and save it.
Open a new terminal window (terminals only read the .bashrc upon starting) and try the command radar.

Updating the desktop picture automatically: Since we can update the desktop image using bash commands, let's make a crontab entry to update the desktop image automatically. Here's what it looks like - a crontab entry with just the shell command:

# m h  dom mon dow   command
*/20 * * * * /home/me/
Note that the desktop picture will refresh every 20 minutes.

Explaining the cron instructions:

# m h dom mon dow command - That's just part of the crontab

*/20 * * * * - tells the machine to run the script every 20 minutes. */5 * * * * will run the script every five minutes.

> /dev/null at the end (optional) - tells the machine to not e-mail me every time the script runs.

Make sure the command is all on one line (not wrapped), or you'll get crontab errors.

Saturday, June 27, 2009

Watching a DVD in Xubuntu 9.04

After the previous reinstall two months ago, DVDs stopped working.

Here's how I got it to work:

  1. Add the medibuntu repository, if you haven't already
    sudo cp /etc/apt/sources.list /etc/apt/sources.list~   # Backup the sources.list file
    sudo mousepad /etc/apt/sources.list &                  # Open the sources.list file in an editing window
      ## In sources.list, append the following two lines at the bottom, then save (don't close it)
      ## Medibuntu
      deb jaunty free non-free
      ## If you use debtorrent, use: deb debtorrent://localhost:9988/ jaunty free non-free
    sudo apt-get update
    sudo sudo apt-get install medibuntu-keyring
    sudo apt-get update
  2. Use these two terminal commands to add the correct software (source):
    sudo apt-get install totem-xine libxine1-ffmpeg libdvdread4
    sudo /usr/share/doc/libdvdread4/
    # Note - this installs the libdvdcss2 package, which is *not* in the repositories.
    # If you use this list of packages to rebuild your system, for example by using a 
    # Jablicator metapackage, it will fail due to this missing dependency.
  3. I installed ubuntu-restricted-extras for unrelated reasons. So I don't *think* it's necessary.
    sudo apt-get install ubuntu-restricted-extras
  4. Finally, I got an error message when I put in a dvd:
    "Could not open location; you might not have permission to open the file." This is indeed a permission issue. Fix it with:
    sudo chmod 755 /media/cdrom0
    And then try opening the DVD from within your player application (Totem).

Reinstalling Xubuntu 9.04

About a month ago, audio suddenly stopped working. Rather than troubleshoot, I decided to might be faster. Unlike last time, this time was a complete reinstall to get rid of certain dependency problems that had also cropped up.

  • Wireless networking worked immediately.
  • Oops. I didn't backup any of my *hidden* files - suddenly all of my e-mail and web caches are...gone. Lesson - keep older backups. Lesson - copy hidden files, too.
  • I tried using Jablicator to save my package list, but hit a failure - it couldn't resolve libdvdcss2 because it didn't come from the Ubuntu repositories.
  • Audio works in the Listen player - except wma files. Totem plays the wma, so it's not a codec or dependency issue. Streaming .pls works.
  • Video works. Added Flash, and YouTube and Hulu work. DVD read works after just a bit of tweaking