( to ) ? be : ! be;
sidebar left sidebar right

Drawing on your Desktop (1,554 views)

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.

desktop circle graphics

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)

download code

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
subscribe to feed

Tags: , , , , ,

"Drawing on your Desktop" was published on August 24th, 2007 and is listed in linux, python.

Follow comments via the RSS Feed | Leave a comment | Trackback URL

Leave Your Comment

Subscribe without commenting

224,392 views

Prashanth Ellina is powered by WordPress

No Complaints Shifter Series Theme by Buzzdroid.com
Computers blogarama - the blog directory Blog Flux Directory Blog Directory & Search engine Computer Blogs - Blog Catalog Blog Directory Computers blogs Bloggeries Blog Directory blog directory Computers Blog Blog Search, Blog Directory p Listed in LS Blogs the Blog Directory and Blog Search Engine Blog Review Blog search - categorized blog directory Link With Us - Web Directory Find Blogs in the Blog
Directory Blog Directory