Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum. |
Notices |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
|
|
11-20-2007, 10:54 AM
|
#1
|
Member
Registered: Dec 2006
Location: New Delhi, India
Distribution: PCLinuxOS 2010
Posts: 246
Rep:
|
How to "Show desktop" in xfce4?
I know of the taskbar icon for that but i want to assign a keyboard shortcut for that.
What would be the command for showing desktop( minimize all toggle)
for xfce4?
|
|
|
Click here to see the post LQ members have rated as the most helpful post in this thread.
|
11-21-2007, 10:08 PM
|
#2
|
HCL Maintainer
Registered: Jan 2006
Distribution: (H)LFS, Gentoo
Posts: 2,450
Rep:
|
Quote:
Originally Posted by ciden
What would be the command for showing desktop( minimize all toggle)
for xfce4?
|
Unfortunately, the xfce4 Showdesktop is implemented as a panel plugin (which means the only way to toggle through xfce’s interface is to use the button). So there is no xfce command (of which I am aware) which will let you execute it to toggle the “show desktop” state). The reason this is unfortunate is that (for the most part) the targets of keyboard shortcuts are “commands” (i.e., something executable), but there is no command (that I know of) which will allow you to push a specific panel button.
Fortunately, if you know a little Xlib, it is pretty easy to make your own command which toggles the “show desktop” on all window managers which support it (to support the “show desktop” feature, a wm should conform to part of the EWMH document). And we’re in luck, because Xfce (among other WMs) does support this extension.
So here’s the code. First, it queries the root window as to the state of the “show desktop” property, then, it sends a request to make the “show desktop” property the opposite of whatever it was found to be.
Code:
#include <X11/Xatom.h>
#include <X11/Xlib.h>
#include <stdio.h>
#include <stdlib.h>
int main(int argc, char *argv[])
{
Display *d;
Window root;
Atom _NET_SHOWING_DESKTOP, actual_type;
int actual_format, error, current;
unsigned long nitems, after;
unsigned char *data = NULL;
/* Open the default display */
if(!(d = XOpenDisplay(NULL))) {
fprintf(stderr, "Cannot open display \"%s\".\n", XDisplayName(NULL));
exit(EXIT_FAILURE);
}
/* This is the default root window */
root = DefaultRootWindow(d);
/* find the Atom for _NET_SHOWING_DESKTOP */
_NET_SHOWING_DESKTOP = XInternAtom(d, "_NET_SHOWING_DESKTOP", False);
/* Obtain the current state of _NET_SHOWING_DESKTOP on the default root window */
error = XGetWindowProperty(d, root, _NET_SHOWING_DESKTOP, 0, 1, False, XA_CARDINAL,
&actual_type, &actual_format, &nitems, &after, &data);
if(error != Success) {
fprintf(stderr, "Received error %d!\n", error);
XCloseDisplay(d);
exit(EXIT_FAILURE);
}
/* The current state should be in data[0] */
if(data) {
current = data[0];
XFree(data);
data = NULL;
}
/* If nitems is 0, forget about data[0] and assume that current should be False */
if(!nitems) {
fprintf(stderr, "Unexpected result.\n");
fprintf(stderr, "Assuming unshown desktop!\n");
current = False;
}
/* Initialize Xevent struct */
XEvent xev = {
.xclient = {
.type = ClientMessage,
.send_event = True,
.display = d,
.window = root,
.message_type = _NET_SHOWING_DESKTOP,
.format = 32,
.data.l[0] = !current /* That’s what we want the new state to be */
}
};
/* Send the event to the window manager */
XSendEvent(d, root, False, SubstructureRedirectMask | SubstructureNotifyMask, &xev);
XCloseDisplay(d);
exit(EXIT_SUCCESS);
return 0;
}
So to compile the thing, first just copy-and-paste the code to a text file (for our purposes, I’ll call it sdtoggle.c). Then, compile it (you’ll have to have libX11 and its headers installed on your system):
Code:
gcc -o sdtoggle -lX11 sdtoggle.c
Now, you have an executable (namely, sdtoggle) which should toggle the “show desktop” property (try it out in a terminal and look for any error messages):
Code:
./sdtoggle; sleep 2; ./sdtoggle
Once you’ve verified that it works as intended (the above line should minimize all windows, pause for two seconds, and then reopen those windows which were minimized), you can go ahead and place it somewhere safe (e.g., /usr/local/bin). Then add a keyboard shortcut that executes the new command, and you should be set.
Last edited by osor; 11-23-2007 at 10:05 AM.
Reason: Add comments as requested
|
|
1 members found this post helpful.
|
11-23-2007, 08:30 AM
|
#3
|
Member
Registered: Dec 2006
Location: New Delhi, India
Distribution: PCLinuxOS 2010
Posts: 246
Original Poster
Rep:
|
I will try that out. Isnt there a target for the panel button?
btw fluxbox has command for show desktop toggle. I love fluxbox but KDE apps start very slowly. But I find it the besst if runnning any hevy program like GIMP or Blender.
|
|
|
11-23-2007, 08:32 AM
|
#4
|
Member
Registered: Dec 2006
Location: New Delhi, India
Distribution: PCLinuxOS 2010
Posts: 246
Original Poster
Rep:
|
btw could you plz put a few comments in the above code. I would like to understand it better.
|
|
|
11-23-2007, 10:05 AM
|
#5
|
HCL Maintainer
Registered: Jan 2006
Distribution: (H)LFS, Gentoo
Posts: 2,450
Rep:
|
Quote:
Originally Posted by ciden
Isnt there a target for the panel button?
|
I assume you mean a way to make a keyboard shortcut be the equivalent of clicking the panel button, and AFAICS, the answer is no.
Quote:
Originally Posted by ciden
btw fluxbox has command for show desktop toggle.
|
By “command” do you mean through something (e.g., fluxbox-remote) or an actual, window-manager-agnostic command? While searching for the command you referenced, the closest thing I could find was wmctrl (which does seem to implement “show desktop” support, but not as a toggle). So I guess if you want, you could use “ wmctrl -k on” and “ wmctrl -k off” instead.
Quote:
Originally Posted by ciden
btw could you plz put a few comments in the above code. I would like to understand it better.
|
Sure. I’ve also put in a small workaround for Xfce (which seems to set nitems to zero if it has never been toggled since it started—in that case, it is safe to assume the current desktop state is “unshown”). This document (and these sections of it) explain most of the reasons for the various settings.
|
|
1 members found this post helpful.
|
11-24-2007, 01:30 AM
|
#6
|
Member
Registered: Dec 2006
Location: New Delhi, India
Distribution: PCLinuxOS 2010
Posts: 246
Original Poster
Rep:
|
Well if you have used fluxbox, u must know the .fluxbox/keys file.
I have an entry there
Mod4 d :ShowDesktop
which maps WIN key + 'd' for toggle show desktop.
|
|
|
11-24-2007, 02:28 PM
|
#7
|
HCL Maintainer
Registered: Jan 2006
Distribution: (H)LFS, Gentoo
Posts: 2,450
Rep:
|
Yes, I am familiar with “fluxbox commands” (also called “fluxbox actions”). The only problem is that they work only on fluxbox. I was looking for a command-line “command” which works on both fluxbox and xfce. The closest I found was wmctrl. The commands “ wmctrl -k on” and “ wmctrl -k off” do in fact work on xfwm4 (from Xfce), metacity (from Gnome), Kwin (from KDE), E (from Enlightenment), icewm, and others. They do not work on fluxbox (as it does not implement the relevant part of the EWMH spec). On fluxbox (assuming you have allowRemoteActions enabled in your init), you have to do “ fluxbox-remote ShowDesktop” instead.
Quote:
Originally Posted by ciden
for toggle show desktop.
|
Not exactly toggle. The key combination you made shows the desktop. There is currently no way in fluxbox to unshow the desktop, but you can do something almost as good—deiconify all windows. E.g.,
Code:
Mod4 d :ToggleCmd {ShowDesktop} {DeIconify all originquiet}
does almost what you intended.
Bottom line:
In fluxbox, - If you want to “show the desktop” use the fluxbox action “ShowDesktop” (this can be in config files or directly with “fluxbox-remote ShowDesktop”).
- There is currently no way to “unshow” a shown desktop. You can, however, deiconify all windows in a workspace using the fluxbox action “DeIconify” applied to all windows in a workspace.
- You cannot ascertain the current state of the desktop showing, so you cannot send a single command for toggling its showing. What you can do to toggle showing of the desktop is to let fluxbox’s keygrabber manage keeping track of the state as in the sample above.
- The code from post 2, “wmctrl -k on”, and “wmctrl -k off” will have no effect until fluxbox decides to implement the relevant part of the EWMH standard.
In Xfce (and many other of the “mainstream” window managers), - You can show the desktop with “wmctrl -k on”.
- You can unshow a shown desktop with “wmctrl -k off”.
- You can toggle the state of showing a desktop using the code from post 2.
- You cannot use fluxbox actions.
Last edited by osor; 11-24-2007 at 06:01 PM.
|
|
|
11-26-2007, 09:25 AM
|
#8
|
Member
Registered: Dec 2006
Location: New Delhi, India
Distribution: PCLinuxOS 2010
Posts: 246
Original Poster
Rep:
|
Thank you very much. Will try it ASAP.
I have examinations going on, and they are not about computers.
I am Microbiology.
|
|
|
12-18-2007, 02:06 AM
|
#9
|
LQ Newbie
Registered: Dec 2007
Posts: 1
Rep:
|
Actually XFCE has this feature built in. The way to use it is to go to xfce's "Window manager" configuration and set a keybinding for the action "Show Desktop." I have it set to Super+D. It does not explicitly say this, but when I press super+d once, it minimizes all my windows. When I do it a second time, it restores all of my previously opened windows.
|
|
3 members found this post helpful.
|
01-03-2009, 11:02 AM
|
#10
|
LQ Newbie
Registered: Jan 2009
Posts: 1
Rep:
|
xprop tool
Also you can simply see the current value using the tool 'xprop':
example:
xprop -root _NET_SHOWING_DESKTOP
so you can probably do something like this in a bash script to toggle it:
Code:
if xprop -root _NET_SHOWING_DESKTOP|egrep '= 1' ; then
wmctrl -k off ;
else
wmctrl -k on ;
fi
|
|
|
12-13-2011, 07:17 PM
|
#11
|
LQ Newbie
Registered: Dec 2011
Posts: 2
Rep:
|
CNTL + ALT + D works to 'Show desktop' in my computer.
|
|
|
09-09-2012, 02:36 PM
|
#12
|
LQ Newbie
Registered: Sep 2012
Posts: 1
Rep:
|
Quote:
Originally Posted by AntonyDeepak
CNTL + ALT + D works to 'Show desktop' in my computer.
|
That's because this is the default keybinding in xfce
Quote:
Originally Posted by clark_kent
Actually XFCE has this feature built in. The way to use it is to go to xfce's "Window manager" configuration and set a keybinding for the action "Show Desktop." I have it set to Super+D. It does not explicitly say this, but when I press super+d once, it minimizes all my windows. When I do it a second time, it restores all of my previously opened windows.
|
You can edit the Window Manger settings by going to Settings->Settings Manger (or running xfce4-settings-manager then clicking Window Manager)
Access Xfce4 Window Manager settings
You can edit the Window Manger keybindings by foing to Settings->Settings Manager->Window Manager-> click keyboard tab (then type: show d[esktop] :: it will take you to the setting)
Show Desktop Setting /w default keybinding (primary is left Control key)
Last edited by neoh4x0r; 09-09-2012 at 02:45 PM.
|
|
1 members found this post helpful.
|
09-17-2017, 10:03 PM
|
#13
|
LQ Newbie
Registered: Sep 2017
Posts: 3
Rep:
|
Quote:
Originally Posted by ciden
I know of the taskbar icon for that but i want to assign a keyboard shortcut for that.
What would be the command for showing desktop( minimize all toggle)
for xfce4?
|
where is the taskbar icon for showing the desktop in xfce? I do not see one, nor does one appear to be in the panal config for it..
|
|
|
09-18-2017, 01:58 AM
|
#14
|
LQ Addict
Registered: Dec 2013
Posts: 19,872
|
Quote:
Originally Posted by jerome1872000
where is the taskbar icon for showing the desktop in xfce? I do not see one, nor does one appear to be in the panal config for it..
|
have you looked at the post date?
don't necrobump.
take the time to formulate a proper problem description.
take the time to search for a solution.
only when that doesn't help, start a new thread.
|
|
|
All times are GMT -5. The time now is 10:59 AM.
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|