This is related to the previous post and is meant in part to demonstrate how great Linux is for doing “weird” stuff :). This is what we are
trying to do.
The circles in the background have been drawn by the python script below. To get the script running you should have python and pygame installed. If you are on Ubuntu do this to install both otherwise you can get the binaries for your distribution/OS.
sudo apt-get install python pygame
The code:
import pygame import sys import random import time pygame.init() window = pygame.display.set_mode((1280, 1024)) screen = pygame.display.get_surface() while 1: for event in pygame.event.get(): if event.type == pygame.QUIT: sys.exit(0) x = random.choice(range(640)) y = random.choice(range(480)) radius = random.choice(range(100)) col_r = random.choice(range(255)) col_g = random.choice(range(255)) col_b = random.choice(range(255)) time.sleep(.01) rect = pygame.draw.circle(screen, (col_r, col_g, col_b), (x,y), radius) pygame.display.update(rect)
Running the code:
This will set the environment variable “SDL_WINDOWID” so that the script will know what the root window is.
export SDL_WINDOWID=`xwininfo -root|grep "id:"|sed 's/^.*id: //'|sed 's/ (.*$//'`
We have to tell the window manager to stop drawing on the desktop. I use gnome where the “nautilus” process does the drawing. Let us ask it to stop drawing.
gconftool-2 --type bool --set /apps/nautilus/preferences/show_desktop false
Now run the script:
python desktop_circles.py
Tags: desktop, gnome, graphics, linux, programming, python














