Fedora notes

Sunday, November 20, 2005

an idea of showing/hiding a window

someday i found i need a global shortcut to activate a program window, dictionary lookup, for example. but it's not easily achieved to my surprise because the app itself does not provide a shortcut. asking for it from the author is unexpected and not my flavor. i don't wanna make my hands dirty on the original code either. after all, it's really a window management problem. i tried following approaches but dissatisfactory:

1. considering put the app into systray: kde has a very cool tool called ksystraycmd which can make *any* app with a main window into the systray. after that, you just click the trayicon to toggle showing/hiding. well, it's good enough, if you only want showing/hiding an app. to me, i expect a global shortcut!

2. considering using DCOP of KDE: this dcop is cool again, but cool only to kde apps. you can invoke commandline dcop calls to show/hide kde apps that provide DCOP interfaces. two deadly issues: 1) non-kde apps get no bless 2) i have to configure two shortcuts to show and hide, no toggle function typically available for dcop call.

3. my natural thought to the above problem is to find a proper window control tool. this was proved to be TOO HARD! luckily i found wmctrl, which is a very neat tool at the first glance. the exciting hope quickly turned into desperation. it works great BUT for "hidden or minimize"! come on...the only thing i need is not working. f**K

today i thought of a solution that temporarily comforts me:) , though i still have to code a little in perl. the idea is to move a window into a special desktop as hiding and to bring it out to the current desktop as showing. assuming i use more than two, and one of them is used as a special one hiding all windows to be toggled. i made a small perl script to do toggling, i.e. do activating when the window is at the special desktop, and do moving when it's not. thus, i am now able to use this script in KHotKeys to make global shortcuts for specific apps I want to toggle.

so, to realize a global shortcut for a specific window, i use a combination of wmctrl + a toggling script + khotkeys.
there may be better ways, though. hopefully, wmctrl could finally solve the "hidden or minimize" problem so that the script will not be necessary. another possibility is, kde itself will offer a similar feature in future.

6 Comments:

Post a Comment

<< Home