/linux config/icon-X




This pygtk script displays an icon on the background screen.
Download the script. You have to make it executable.
Browse the bin/icon-x/ directory.



Screen shots:
A set of icon-X applications: floppy, cdrom, dvd, zip and modem.
If icons are transparents, under windows are visibles.

The popup menu over the DVD icon:
status, swap, mount/umount, remove the icon-X.

The DVD is now mounted, the icon has changed.



How it works
The script takes 3 parameters:
- the configuration script: a .py file
- the icon to set it ON
- the icon to set it OFF

Example: (look at the file iconX-dvd)
$> /home/julien/bin/icon-x/icon-x dvd /home/julien/.fvwm2/icons/48/dvd.xpm /home/julien/.fvwm2/icons/48/dvd-locked.xpm



How to configure
The first parameter is a .py file. This file MUST be placed in the same directory of the 'icon-x.py' file.
Example (look at the file dvd.py):
# Icon-X config file:
# "dvd"
#        by JC
# --------------------
# Place this file in the same directory of "icon-x.py"
#
# usage:
# [prompt]> /find/the/path/icon-x.py dvd icon1 icon2

import gtk, os

class IconXConfig:

    def __init__(self, app, aPath_on, aPath_off):
	self.path_on = aPath_on
	self.path_off = aPath_off
        self.mainApp = app
    
    def pos_x(self):
        return 10

    def pos_y(self):
        return 130
    
    def get_pixmap_and_mask(self, aPath):
        import GdkImlib
        newImage = GdkImlib.Image(aPath)
        newImage.render(newImage.rgb_width, newImage.rgb_height)
        gdkpixmap, mask = newImage.get_pixmap()
        self.mainApp.window.shape_combine_mask(mask, 0, 0)
        return (gdkpixmap, mask)
        
    def pixmapWidget(self):
        aPath = self.path_off
        if (os.system("mount | grep /mnt/dvd")) != 0:
            aPath = self.path_on
        pixmap_and_mask = self.get_pixmap_and_mask(aPath)
        return gtk.GtkPixmap(pixmap_and_mask[0], pixmap_and_mask[1])

    def change_pixmap(self):
        aPath = self.path_off
        if (os.system("mount | grep /mnt/dvd")) != 0:
            aPath = self.path_on
        pixmap_and_mask = self.get_pixmap_and_mask(aPath)
        
        self.mainApp.pixmap.set(pixmap_and_mask[0], pixmap_and_mask[1])

    def swap(self, w, data):
        os.system("swap-dvd")
        self.change_pixmap()

    def status(self, w, data):
        os.system("status-dvd")

    def mount(self, w, data):
        os.system("mount /mnt/dvd")
        self.change_pixmap()

    def umount(self, w, data):
        os.system("umount /mnt/dvd")
        self.change_pixmap()

    def menu_items(self):
        return (
         # label / shortcut key / method / ? / type
         ( "/Status",         None, self.status,  0, None ),
         ( "/Swap",           None, self.swap,    0, None ),
         ( "/sep1",           None, None,         0, "" ),
         ( "/Mount",          None, self.mount,   0, None ),
         ( "/U-Mount",        None, self.umount,  0, None ),
         ( "/sep2",           None, None,         0, "" ),
         ( "/Remove",         None, None,         0, "" ),
         ( "/Remove/Confirm", None, gtk.mainquit, 0, None ),
        )
Configurations:
def pos_x(self): Returns the position in X.
def pos_y(self): Returns the position in Y.
def menu_items(self): Returns the popup menu. Methods (like 'self.swap') are defined before the popup menu.




Also applications
Icons for NFS drives, applications running in background, everything that may have 2 status...




Home