Previous Page
PCLinuxOS Magazine
Article List
Next Page

Tip Top Tips: Create a Tray Toggle Icon

Editor's Note: Tip Top Tips is a new monthly column in The PCLinuxOS Magazine. Each month, we will feature -- and possibly even expand upon -- one tip from the PCLinuxOS forum. The magazine will not accept independent tip submissions specifically intended for inclusion in the Tip Top Tips column. Rather, if you have a tip, share it in the PCLinuxOS forum's "Tips & Tricks" section. Your tip just may be selected for publication in The PCLinuxOS Magazine.

This month's tip comes from PCLinuxOS forum member Bill Grubbs.

Add a tray closing icon on the desktop.

Right click the desktop, and choose Create New --> Link to Application.

A Properties box opens, with "Link to Application" in the title box, highlighted for you to create a new name for the link.

Type "Tray Door" (without the quotes) as the new title.

Click the gearwheel icon, and in the pop up, click the Applications button and choose Devices from the drop down menu. Choose a CDROM or DVD icon, whichever best describes your device. (Note: did not work for me.)

Next click the Application tab.

In the box next to Command type, "eject -T" (without the quotes). Click OK.

Alter permissions if necessary.

If you have more than one optical drive, you'll need an icon for each. Label them as you feel appropriate, and type the command as:

eject -T cdrom
eject -T dvdrecorder
eject -T dvdrom (see additional explanation below)

The -T is for toggle. The tray link both opens and closes the tray.

How you call the appropriate drive depends on what your /etc/fstab shows the device to be named. If you don't like the icon on the desktop proper, or like having it available even when the desktop is covered, drag it to the kicker panel, or the "quick launcher" on the panel, if you like really small, space saving, icons. You can then delete the original desktop icon, if you wish.

When your cat or dog walks by, toggle the tray door and watch the fun.


If you take a look at the command line options for the eject command, this is what you will find:

Running eject -n at a command line will list all the devices the command recognizes and finds. On the laptop I'm writing on, it lists the DVD-RW drive as /dev/sr0. On my desktop, it lists my DVD-RW drives as /dev/sr0 and /dev/sr1.

So, on my laptop, the command to open the DVD-RW tray would be eject -T /dev/sr0. Since the laptop has a spring loaded tray door, the actual "toggle" command doesn't work except to open the tray. The tray has to be manually closed by pressing it firmly in, against the spring pressure until it latches in the closed position. On my desktop, which has drives with motorized trays, the "toggle" command will both open and close the drive tray. Thus, on a laptop -- or any computer with the spring loaded drive tray -- the eject -r /dev/sr0 command works equally well.

Also, to change the icon for the shortcut, (as pointed out by forum member pags) go back in and edit the shortcut after you save it initially (at least on KDE). Then, the icon will change to whatever icon you select.

Previous Page              Top              Next Page