Help getting Conky to work with LXDE & PCManFM

8.9k views Asked by At

As some of you might be aware, there's a bug with either Conky or PCManFM (the desktop manager aspect of it) that makes the Conky window disappear in one of these situations:

  • Setting "own_window_type override" in .conkyrc (the usual configuration for Nautilus) flat out doesn't show the Conky window at all.
  • Setting "own_window_type desktop" in .conkyrc shows the Conky window, but it disappears if you click on the desktop.
  • Setting "own_window_type normal" in .conkyrc shows the Conky window, it doesn't disappear when clicking on the desktop, BUT... it disappears if you use LXPanel's "Minimize all windows" plugin ("Show desktop" equivalent). This happens if using the keyboard shortcut as well.

There are some workarounds to this, such as deactivating PCManFM's desktop management (and using feh for setting the wallpaper and, presumably, iDesk for the icons) or using another file manager altogether, but I've come to notice these are all subpar solutions. I really like PCManFM and I really like Conky. What's a guy to do? :-/

So I dug in LXPanel's source and found a relevant piece of code that might house my fix. The file is src/plugins/wincmd.c .

The idea I have is that when the "Minimize all windows" button is clicked, all windows (class) names would be compared to a static string "Conky" and if it matches, it simply wouldn't minimize that window. Simple, and it should work. But the problem is it has been a few years since I've touched any C code and I haven't really played with Xlib that much.

So far, I have done the following changes:

19a20
> #include <string.h>
77a79,82
>             
>             /* Getting window's class name */
>             XClassHint class;
>             XGetClassHint(GDK_DISPLAY(), client_list[i], &class);
81c88
<             if (((task_desktop == -1) || (task_desktop == current_desktop))
---
>             if (((task_desktop == -1) || (task_desktop == current_desktop) || strcmp(class.res_name, "Conky") != 0)

This compiles correctly, but when I run the new lxpanel and click on "Minimize all windows", Conky still disappears as before.

If someone can look into this file and see if my changes make sense, I'd be very grateful.

Thanks SO! :)

7

There are 7 answers

0
minj On

Simplifying @imiric's answer:

Openbox RC.xml (e.g. ~/.config/openbox/lxde-rc.xml):

<keybind key="W-d">
  <action name="ToggleShowDesktop"/>
  <action name="Execute">
    <command>wmctrl -a "Conky (hostname)"</command>
  </action>
</keybind>

~/.conkyrc:

own_window yes
own_window_type normal
own_window_class conky-semi
own_window_transparent yes
own_window_hints undecorated,sticky,skip_taskbar,skip_pager
own_window_argb_visual yes
0
sputnick On

To build on Redsandro's solution:

Follow Redsandro's advice and sudo apt-get install xdotool and create some conky-remap.sh (or whatever) script in your /usr/local/bin (or wherever) directory. Also, install wmctrl if you do not already have it. We will be using this to make Conky active (I know this is different than mapping, but it behaves as I expect it to, so I'm not worried.)

run wmctrl -l to list all windows while Conky is running and take note of Conky's title (mine was something like Conky (<my-machine-name>).

While you're at it create another file in which we will save the current state of the desktop (0=not show-desktop-mode, 1=show-desktop-mode... almost) called something like .conky_desktop_state. I have put this into /usr/local/bin as well. Now back to conky-remap.sh:

#!/usr/bin/env bash

state=$(cat /usr/local/bin/.conky_desktop_state)
dt=$(xdotool get_desktop)

if (( $state == 1 )) ; then
        echo 0 > /usr/local/bin/.conky_desktop_state
        wmctrl -a "Conky (<my-machine-name>)"
else
        echo 1 > /usr/local/bin/.conky_desktop_state
        wmctrl -a "Conky (<my-machine-name>)"
        xdotool search --desktop $dt . windowmap %@
fi

wmctrl's command to activate a window doesn't care about the desktop being in focus or not, so we don't need to sleep or flash a dialog window to the screen. $state and $dt are the variables which hold the current state of the desktop (again, kind of) and the current desktop id number.

xdotool search --desktop $dt . windowmap %@ maps all of the windows from the current desktop back to the screen and leaves other desktops alone.

Edit ~/.config/openbox/lubuntu-rc.xml or wherever to execute the script when Win+D is pressed.

<keybind key="W-d">
  <action name="ToggleShowDesktop"/>
  <action name="Execute">
    <command>conky-remap.sh</command>
  </action>
</keybind>

openbox --reconfigure to refresh keybindings and you should be good to go.

With Win-D to show desktop, the desktop is focused, so you may use arrow keys to navigate desktop icons.

This solution does have its own set of quirks:

  • A second pressing of Win+D brings up all windows of the current desktop, not just the ones which were active before showing the desktop.
  • A toggle is stored in .conky_desktop_state, but it doesn't really match up with show-desktop-mode since it only toggles when the script is executed. This means it is possible to have one desktop shown and the other not. In this case, the desktop will be shown briefly and then all windows will be brought active. One more pressing Win+D will show the desktop.
  • Sometimes the whole thing fails and Conky disappears with all of the other windows, albeit rarely. Just cat /usr/.../.conky_desktop_state and toggle the opposite value in (ie- echo 1 > /usr/.../.conky_desktop_state)
  • Although most of the time the last active window before Win+D is on top after a second Win+D, it is not necessarily active, meaning you may have to click in the window or Alt+Tab to it to start typing in it. This generally is the case with terminal windows.

Ideally, we would be able to look at all active (mapped) windows on each desktop individually and execute one or the other command based on if Conky is the only active window, but I wasn't smart (dedicated) enough to do that, so here is my contribution. Please build on it and reply.

0
Redsandro On

This is still impossible afaik. I made this quirky workaround. Just use the own_window_type normal mode where you cannot use the Win+D desktop shortcut, and fix conky on show desktop.

First I thought, just remapping the conky window will do the trick. But I found out that as long as the desktop is focussed, nothing will get drawn over it. Then I thought, just kill and restart conky. But while in show desktop mode, it will get created in the background.

So in order to get conky back:

  • The desktop must be unfocussed
  • restart conky or remap the window

Install xdotool; apt-get install xdotool
Create a script, e.g. /usr/local/bin/conky-remap.sh:

#!/usr/bin/env bash
zenity --info --text "Remapping Conky..." &
pid=$!
sleep 0.3
kill $pid
xdotool windowmap `xdotool search --classname 'conky'`

Edit ~/.config/openbox/lxde-rc.xml (or wherever shortcuts are in your distro).

Find:

<keybind key="W-d">
  <action name="ToggleShowDesktop"/>
</keybind>

Change to:

<keybind key="W-d">
  <action name="ToggleShowDesktop"/>
  <action name="Execute">
    <execute>conky-remap.sh</execute>
  </action>
</keybind>

Activate the new keyboard shortcut configuration:
openbox --reconfigure

Press Win+D. You'll see a flash and conky is back!

This quirky solution is the only solution in the universe according to a week of google, so improving on it is encouraged.


Explanation:

  • zenity --info --text "Remapping Conky..." &
    • We need to create a random window to unfocus the desktop. Conky itself doesn't work. :(
    • We also need the script to continue, so use &
  • pid=$!
    • Get the pid of that last process
  • sleep 0.3
    • Sleep any less (slow HTPC) and the window is killed before it is created.
  • kill $pid
    • Kill the window as soon as it has performed its function.
  • xdotool windowmap xdotool search --classname 'conky'
    • Now finally, we can raise (remap) conky.

Quirks:

  • Desktop is not focussed, so you cannot use the arrows to navigate desktop icons
    • Can we refocus the desktop? As long as the windows are not programatically minimized, conky will stay put.
  • 300 ms delay, and a flash of the dialog box.
  • Pressing Win+D for a second time to go back ('unshow desktop')
    • We would need a way to detect if the desktop is already in show-desktop-mode, in which case the script should exit 0
0
JanD On

got success with conky transparency in LXDE on debian squeezy, with pcmanfm running.

In the conky config file (i.e. .conkyrc) I removed all 'own_window' lines, except the following:

own_window yes
own_window_class conky
own_window_transparent yes
own_window_hints undecorated,below,skip_taskbar,sticky,skip_pager

Adding again some often used lines caused transparency to fail, or conky wouldn't start at all. Very strange...

0
osser On

The solution is:

NetWMState nws;
guint task_desktop = get_net_wm_desktop(client_list[i]);
get_net_wm_state(client_list[i], &nws);

if (((task_desktop == -1) || (task_desktop == current_desktop))
&& ( ( ! nwwt.dock) && ( ! nwwt.desktop) && ( ! nwwt.splash)
&& ( ! nws.skip_pager) )
3
yaeuge On

The simplest solution working perfectly with Openbox (and should work with other WMs too):

  1. In your .conkyrc file:

     own_window yes
     own_window_type desktop
     own_window_class Conky
    

    The "desktop" window type prevents conky from being minimized when show desktop is executed. Moreover your windows will be restored by executing "show desktop" again

  2. Install xdotool package (it's very lightweight, don't worry), in terminal emulator run the following:

    xdotool search --class "Pcmanfm" behave %@ focus windowraise $(xdotool search --class "Conky")

    and make sure your conky doesn't hide when you focus a desktop

  3. If everything is okay, interrupt xdotool by pressing Ctrl+C in your terminal and place the code above in autostart. It probably won't start right away, so you have to create a simple script (e.g. "show_conky.sh") containing

    #!/bin/sh sleep 5 xdotool search --class "Pcmanfm" behave %@ focus windowraise $(xdotool search --class "Conky")

    The minimal required sleep time should be defined accordingly to your system. To be sure, conky won't hide at the first launch before "show_conky.sh" is executed, you can also create another script with xdotool focus windowraise $(xdotool search --class "Conky") command and proper sleep time in it (or try to add it between "sleep" and "xdotool behave" commands it "show_conky.sh").

  4. Restart your Xorg server. Enjoy! :)

    I personally advice you using SpaceFM for managing desktop icons. It allows you to set margins for the desktop area, so conky never covers icons. Pcmanfm looks more friendly as an explorer, but you can use both of them: spacefm can open directories located on the desktop with other application. Its desktop behavior is identical to pcmanfm, so you should simply replace "Pcmanfm" in the code above with the "Spacefm"

2
Dɑvïd On

This is an old "question", but it came up fairly high in Google hits when I searched for "Conky LXDE", because I couldn't get Conky to work in Lubuntu. But there is no need to hack LXPanel!

After MUCH searching and false trials and trails, I found a .conkyrc file in the "PCLinuxOS-Forums" that Just Worked™. It has proved to be an excellent base to tweak from on Lubuntu 11.10.

I now use the same set up on Linux Mint 13 LTS "Maya" Xfce (based on Ubuntu 12.04), and it continues to meet my (very simple) Conky requirements. The current form of my .conkyrc file is saved in a Gist if anyone is thinks it might help them. (The original source link for the forum is commented into the rc file.)