[fbpanel] hide on click
Brought to you by:
aanatoly
From: Daniel G. <da...@ms...> - 2007-08-17 06:43:40
|
Thanks very much for the auto-hide feature! It occurred to me that sometimes it is also helpful to have panel hiding triggered by a mouse click. (The panel in KDE allows either autohiding or clicking on the sides of the panel to trigger hiding, for example.) I don't want to seem ungrateful for the work that went into fbpanel's autohide! So rather than just asking for hide-on-click to be added to fbpanel, I thought it would be proper to offer a workaround that can be used in the meantime to accomplish the same goal. Here's a simple way to accomplish this with fbpanel: This is based on wmctrl, "a UNIX/Linux command line tool to interact with an EWMH/NetWM compatible X Window Manager." (http://www.sweb.cz/tripie/utils/wmctrl/) wmctrl can resize a window from the command line or from within a script. On my system, for example, the following command slides fbpanel almost completely off the screen to the left, leaving only a small region visible on the left of the screen: "wmctrl -r panel -e 0,-1,-1,26,-1". (The "-r panel" identifies the fbpanel window by the title assigned to it by the window manager, while the "-e 0,-1,-1,26-1" indicates the new dimensions when the window is mostly hidden.) Similarly, the following command slides the fbpanel window back across the screen, making it fully visible: "wmctrl -r panel -e 0,-1,-1,1305,26". I place each of these commands in their own files, labeled fbpanel_hide and fbpanel_show respectively. Of course these exact dimension may not work for you, depending on screen resolution, etc. You will have to experiment with the "wmctrl -e" parameters to find what works. ("man wmctrl" is helpful.) The next step is to add two launchbar plugins to the ~/.fbpanel/default file. I place one launchbar plugin early in my default config file, so that the image associated with this plugin will appear on the leftmost portion of my panel. (So in my case I place my launchbar before the menu plugin.) Here's what it looks like Plugin { type = launchbar config { button { image = ~/image_files/left_arrow.png tooltip = hide action = ~/fbpanel_hide } } } The second launchbar plugin needs to be near the end of the file, so that the image associated with it will be placed on the rightmost part of the panel: Plugin { type = launchbar config { button { image = ~/image-files/right_arrow.png tooltip = show action = ~/fbpanel_show } } } When you click on the left arrow ("hide"), wmctrl slides the panel all the way to the left, leaving only the right arrow visible. (The right arrow appears in the left corner of the screen.) Click the right arrow ("show") and the panel is restored again. A nice touch is to make sure that when you restore the panel, the right arrow moves all the way off the right edge of the screen. This ensures that the "show" button will only appear when the panel is hidden. All this works pretty well, but there is a complication that should be mentioned: On startup, fbpanel assigns the title "panel" to its window. When wmctrl resizes a window it does so by looking for the first window with a title that includes the string "panel." If some window other than fbpanel's has a title that includes "panel" then it may get resized when you press the hide or show buttons. I found this out when I was editing my ~/fbpanel/default file. I pressed the "hide" arrow on my panel and my xterm window disappeared! Why? Because I had the name of my current directory included in the window title for each of my xterms. Since my xterm window title - "~/fbpanel" - includes the string "panel" it got resized instead of fbpanel's window. There are a couple ways to deal with this problem. 1) wmctrl lets you change the name of a window to something unique that is unlikely to be included in any other window title. E.g., "wmctrl -r panel -T use_a_unique_string_here" will allow you to direct the wmctrl window resize commands to a window called "use_a_unique_string_here." If you change "panel" to something unique right after fbpanel starts, then you can ensure that your window show and window hide commands always go to this unique window. 2) A simpler and more direct approach is to modify the two lines in fbpanel's panel.c code that sets the window title to "panel." line 389: gtk_window_set_wmclass(GTK_WINDOW(p->topgwin), "panel", "fbpanel"); line 390: gtk_window_set_title(GTK_WINDOW(p->topgwin), "panel"); Replace "panel" with your unique string, recompile fbpanel, and then you can direct your wmctrl resize commands to this unique window title without having to use wmctrl to rename the window. |