Dash-to-dock: Feature request: "Show Desktop" icon

Created on 19 Apr 2015  路  10Comments  路  Source: micheleg/dash-to-dock

Is there a plan to add "show desktop" icon in in dash?

Feauture request

Most helpful comment

Temporary Solution:

  • Open a terminal and install _wmctrl_:

$ yaourt -S wmctrl

  • Create a shell script named _show-desktop.sh_:

$ gedit ~/.local/bin/show-desktop.sh

Place this code in there:

#!/bin/bash
status="$(wmctrl -m | grep "showing the desktop" | sed -r 's/(.*)(ON|OFF)/\2/g')"

if [ $status == "ON" ]; then
    wmctrl -k off
else
    wmctrl -k on
fi
  • Make it executable:

$ chmod +x ~/.local/bin/show-desktop.sh

  • Create a new file in _/usr/share/applications_ folder, called _show-desktop.desktop_ with this text:
[Desktop Entry]
Type=Application
Name=Show Desktop
Icon=show-desktop
Exec=/home/<your user>/.local/bin/show-desktop.sh
  • Open the dash, search for _show desktop_ and add it to the favorites.

All 10 comments

There's some work going on, not by me, to add additional widgets, included a show desktop one. Have a look at the video at the end of this post: http://micheleg.github.io/dash-to-dock/release/2015/03/08/new-release-v39.html. There's also an experimental branch with some preliminary code. I don't have a schedule of when such features will land in master. What would you think of an entry in the showapps button menu?

Cool widgets, hope you add some of them as soon as possible!
Sorry, I don't understand wht did you mean in the last question.

@micheleg Unless I am mistaken this still hasn't been done has it?

I confirm, it hasn't been done yet.

@micheleg Any updates on this?

@koxu1996: not yet, and I don't have a plan for this feature for the moment.

Temporary Solution:

  • Open a terminal and install _wmctrl_:

$ yaourt -S wmctrl

  • Create a shell script named _show-desktop.sh_:

$ gedit ~/.local/bin/show-desktop.sh

Place this code in there:

#!/bin/bash
status="$(wmctrl -m | grep "showing the desktop" | sed -r 's/(.*)(ON|OFF)/\2/g')"

if [ $status == "ON" ]; then
    wmctrl -k off
else
    wmctrl -k on
fi
  • Make it executable:

$ chmod +x ~/.local/bin/show-desktop.sh

  • Create a new file in _/usr/share/applications_ folder, called _show-desktop.desktop_ with this text:
[Desktop Entry]
Type=Application
Name=Show Desktop
Icon=show-desktop
Exec=/home/<your user>/.local/bin/show-desktop.sh
  • Open the dash, search for _show desktop_ and add it to the favorites.

@micheleg this code writed for dash to panel I think that can you help to develop this feature.

`_displayShowDesktopButton: function (isVisible) {
        if(isVisible) {
            if(this._showDesktopButton)
                return;

            this._showDesktopButton = new St.Bin({ style_class: 'showdesktop-button',
                            reactive: true,
                            can_focus: true,
                            x_fill: true,
                            y_fill: true,
                            track_hover: true });

            this._showDesktopButton.connect('button-press-event', Lang.bind(this, this._onShowDesktopButtonPress));

            this._showDesktopButton.connect('enter-event', Lang.bind(this, function(){
                this._showDesktopButton.add_style_class_name('showdesktop-button-hovered');
            }));

            this._showDesktopButton.connect('leave-event', Lang.bind(this, function(){
                this._showDesktopButton.remove_style_class_name('showdesktop-button-hovered');
            }));

            this.panel._rightBox.insert_child_at_index(this._showDesktopButton, this.panel._rightBox.get_children().length);
        } else {
            if(!this._showDesktopButton)
                return;

            this.panel._rightBox.remove_child(this._showDesktopButton);
            this._showDesktopButton.destroy();
            this._showDesktopButton = null;
        }
    },

    _onShowDesktopButtonPress: function() {
        if(this._focusAppChangeId){
            tracker.disconnect(this._focusAppChangeId);
            this._focusAppChangeId = null;
        }

        if(this._restoreWindowList && this._restoreWindowList.length) {
            let current_workspace = global.screen.get_active_workspace();
            let windows = current_workspace.list_windows();
            this._restoreWindowList.forEach(function(w) {
                if(windows.indexOf(w) > -1)
                    Main.activateWindow(w);
            });
            this._restoreWindowList = null;

            Main.overview.hide();
        } else {
            let current_workspace = global.screen.get_active_workspace();
            let windows = current_workspace.list_windows().filter(function (w) {
                return w.showing_on_its_workspace() && !w.skip_taskbar;
            });
            windows = global.display.sort_windows_by_stacking(windows);

            windows.forEach(function(w) {
                w.minimize();
            });

            this._restoreWindowList = windows;

            Mainloop.timeout_add(0, Lang.bind(this, function () {
                this._focusAppChangeId = tracker.connect('notify::focus-app', Lang.bind(this, function () {
                    this._restoreWindowList = null;
                }));
            }));

            Main.overview.hide();
        }
    },

    _dtpUpdateSolidStyle: function() {
        if (this.actor.has_style_pseudo_class('overview') || !Main.sessionMode.hasWindows) {
            this._removeStyleClassName('solid');
            return false;`

@Nebrit: thanks for pointing out at the code.

thanks for your time to develop @micheleg

Was this page helpful?
0 / 5 - 0 ratings