Results 1 to 7 of 7

Thread: Replace Your Show Desktop Button

  1. #1
    Join Date
    Jul 2005
    Location
    Remote Desert, USA
    Beans
    683

    Replace Your Show Desktop Button

    For all you "modders" out there, I found a great way to replace your GNOME Show Desktop button. This is more than just merely replacing the image -- you can eliminate the button altogether and replace it with a launcher that doesn't have any button-like border around it, then place that on the panel. This might not sound so spectacular, but there's another reason too why this is so special. In this forum, I mention how to create a wide GNOME main menu, wider than one that GNOME normally provides:

    Wide GNOME Main Menu

    In this link, you can see that I have an Ubuntu icon that pops up the real GNOME Main Menu, and then beside it, which almost looks attached, is the "ubuntu" label that does nothing.

    Therefore, you can replace the static functionality of the "ubuntu" label part of the "main menu" that you create with the ability to minimize all windows and show the desktop.

    Here's how:

    1. Temporarily enable your universe setting in /etc/apt/sources.list, then do apt-get update.

    2. Type the following command to install xmacro, which is necessary for this. xmacro is a set of 4 small, simplistic C++ programs put up on SourceForge.net that let you record and playback XWindows keystrokes, mouse clicks, moves, and drags. They appear to be poorly documented at this time, so I help you wade through this here.

    Code:
    apt-get install xmacro
    3. Comment back out your universe setting in /etc/apt/sources.list, followed by an apt-get update, so that you make certain you are more in-line with the way the makers of Ubuntu would rather you have your settings as to lower risk of potential harm.

    4. Create a text file "showdesk.macro" with GNOME Text Editor that looks like this:

    Code:
    KeyStrPress Control_L
    KeyStrPress Alt_L
    KeyStrPress d
    KeyStrRelease d
    KeyStrRelease Alt_L
    KeyStrRelease Control_L
    5. Open GIMP and create a transparent PNG file that's like 48x48 pixels, like this:

    a. Open Gimp.
    b. File, New.
    c. Type in 48x48 on Width x Height.
    d. Click Advanced Options.
    e. Change Fill With to Transparency.
    f. Click OK.
    g. File, Save As, clear.png, Save.
    h. Exit out of Gimp.

    6. Create a new Bash script file "showdesk.sh" with GNOME Text Editor that looks like this:

    Code:
    #!/bin/bash
    cat showdesk.macro | xmacroplay ":0.0"
    7. Create a new custom launcher on your desktop and set it to this command:

    Code:
    /bin/bash ~/showdesk.sh
    ...and for the icon, set it to clear.png.
    ...and for the label, set it to "Show Desktop".

    8. Drag the custom launcher right where you want it on your GNOME panel. In my case, I drag it over the top of the "ubuntu" label, right in the middle.

    9. Remove the custom launcher from your desktop since you have it on the GNOME panel.

    And that's it! Now when you click the launcher, it runs this macro script, minimizing all windows. In my case, when I click the word "ubuntu", I see my desktop with all windows minimized.

    Some further explanation...

    Q. What else can you do with xmacro in this case?
    A. Anything accessible from GNOME keyboard shortcuts can now be mapped to a launcher with xmacro. You can also use it for programmer testing, or use it to record and playback keystrokes and mouse events. In some cases you might even find that you can make a fancier "pager" tool, or augment the existing one you have on the GNOME panel.

    Q. How do I use xmacro to record and playback keystrokes and mouse events?
    A. The short answer is that you use

    Code:
    xmacrorec2 > mymacro.macro
    at a command prompt, press the Scroll Lock key, do your little keystroke thing that you want to record, then press the Scroll Lock key again to stop the recording.

    Now that you have your macro, edit it and remove anything referring to mouse movements unless you need to use that too.

    To play your new macro back, this is not so apparent. You have to cat this file through a pipe to xmacroplay ":0.0" like:

    Code:
    cat mymacro.macro | xmacroplay ":0.0"
    Note that if you have more than one display, then in some cases you might want to change ":0.0" to either ":1.0" or ":0.1", etc., until this works.
    SuperMike
    When in doubt, follow the penguins.
    Evil Kitty is watching you

  2. #2
    Join Date
    Mar 2007
    Beans
    Hidden!

    Re: Replace Your Show Desktop Button

    Sorry to ask Im a total newbie... where exactly should I save the text file and the bash file?

    Thanks a lot, I've been looking for this for days.

  3. #3
    Join Date
    Jul 2005
    Location
    Remote Desert, USA
    Beans
    683

    Re: Replace Your Show Desktop Button

    Oh, I simply created a "bash" folder in my home directory, but you can do other things as you wish. I put the files there.
    SuperMike
    When in doubt, follow the penguins.
    Evil Kitty is watching you

  4. #4
    Join Date
    May 2006
    Location
    NH, USA
    Beans
    58
    Distro
    Ubuntu 7.04 Feisty Fawn

    Re: Replace Your Show Desktop Button

    I've been trying to make a launcher for this command:
    cat macro | xmacroplay :0
    but can't get it to run from the launcher (works in term & run app.)
    I tried your way above too. any ideas?

    PS. the file just types my web address with a 3 sec delay so I can focus my target like gedit
    8.10 on Compaq Presario, P4,1.50GHz, 512 ram, Desktop, lan, HP D4160 printer

    mikemason.org + mikemason.us

  5. #5
    Join Date
    Apr 2006
    Beans
    Hidden!

    Re: Replace Your Show Desktop Button

    Hi, it's an old thread, but I just had a little fight getting the button work... so to get the macro functioning from the panel you need (or I needed) to add the full path to the xxx.macro file in the script file... so I had to do it like this::

    Code:
    #! /bin/bash
    cat /home/ukkonen/bash/showdesk.macro | xmacroplay ":0.0"
    It works from the terminal, because you are in the same directory where your xxxx.macro file is... I guess...

  6. #6
    Join Date
    May 2007
    Beans
    Hidden!

    Re: Replace Your Show Desktop Button

    I'd suggest using xte from the xautomation package instead of xmacros.
    You could simply create a launcher for the following command:
    Code:
    xte "keydown Control_L" "keydown Alt_L" "key d" "keyup Control_L" "keyup Alt_L"

  7. #7
    Join Date
    Jan 2008
    Beans
    113

    Re: Replace Your Show Desktop Button

    great guide!
    I was able to create a button that will tile my windows in compiz
    thank you

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •