Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature request: "Show Desktop" icon #163

Open
chamfay opened this issue Apr 19, 2015 · 10 comments
Open

Feature request: "Show Desktop" icon #163

chamfay opened this issue Apr 19, 2015 · 10 comments

Comments

@chamfay
Copy link
Contributor

chamfay commented Apr 19, 2015

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

@micheleg
Copy link
Owner

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?

@chamfay
Copy link
Contributor Author

chamfay commented Apr 19, 2015

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.

@fusion809
Copy link

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

@micheleg
Copy link
Owner

I confirm, it hasn't been done yet.

@koxu1996
Copy link

koxu1996 commented Sep 1, 2017

@micheleg Any updates on this?

@micheleg
Copy link
Owner

micheleg commented Sep 5, 2017

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

@btd1337
Copy link

btd1337 commented Oct 27, 2017

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.

@Nebrit
Copy link

Nebrit commented Jan 3, 2018

@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;`
  

@micheleg
Copy link
Owner

@Nebrit: thanks for pointing out at the code.

@Nebrit
Copy link

Nebrit commented Jan 18, 2018

thanks for your time to develop @micheleg

This was referenced Nov 29, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants