LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Desktop
User Name
Password
Linux - Desktop This forum is for the discussion of all Linux Software used in a desktop context.

Notices


Reply
  Search this Thread
Old 01-10-2014, 07:19 AM   #1
Vinter
Member
 
Registered: Feb 2005
Location: Germany
Distribution: Aptosid
Posts: 148

Rep: Reputation: 19
[PROJECT] minmon: Start and close _anything_ to tray


Hi!

After I was fed up with the horrible state of tray support in many applications and the buggy and extremely limited nature of alltray, kdocker and the likes, I decided to roll my own set of scripts that handles tray icons, minimized startup and catches close events. Here's how it works:

* A daemon, minmond, is started at login. It reads from a fifo in /tmp and idles when nothing happens.
* A client, minmon-start, feeds commands to minmond through the fifo.
* minmond executes the command, which then becomes a child process of minmon, and creates a tray icon for it.
* The WM's "close" action is deactivated and replaced with a script that checks if a window that should be closed belongs to a process that is a child of minmon. If it is, the window is unmapped instead of closed.
* Clicking the tray icon allows you to restore / hide all windows belonging to its process.

I know that replacing the close action is sort of the crucial point; this is easy if you're using a shortcut like Alt+F4 or a mouse button like me, but may not be possible if you're used to clicking the little Xs in the window decoration. Normal "Close" actions from the window's menu still work as intended, of course.

My repo is here:

https://github.com/Pikaro/minmon

Download the scripts here:

https://github.com/Pikaro/minmon/archive/master.zip

Dependencies, just about any average desktop will have those:
*bash
*xdotool
*wmctrl
*python2
*gtk for python2
*xprop
*a tray

Unzip the files inside minmon-master/ in your home directory and you should be good to go. (Place minmon in your PATH if you like, otherwise just start it with ./minmon .) Usage: Run "minmon start", then "minmon launch xterm". You will see an xterm pop up, along with a systray icon. If you click the icon, the xterm vanishes; if you click it again, it reappears. (Had you issued "minmon launch -min xterm, it would have started minimized.) Run ~/.minmon/minmon-close in the xterm, and it vanishes again; but it's not closed, clicking the icon brings it back. Open another xterm without minmon, run ~/.minmon/minmon-close again, and it will exit normally. If you bind ~/.minmon/minmon-close to a hotkey, it will minimize or close the currently active window depending on if it was started with "minmon launch". That's basically it!

This is very hacky and bound to be unstable, but I hope I haven't made too many assumptions that a standard system will not satisfy. It was never intended for release, actually, but once I saw how beautifully those few lines of code worked, I thought someone might be interested. (I use it for firefox and evolution now, the latter of which doesn't have tray support. Tests with other applications haven't been extensive.)

Limits:

*VERY IMPORTANT: DO NOT USE THIS AS ROOT OR IN A SECURE ENVIRONMENT. minmond just executes whatever you tell it. This isn't _that_ bad if you're just the standard single user on a desktop machine, but it's still a huge security hole that an attacker could exploit. If minmond runs as root, a single echo 0:rm -rf /\* > /tmp/minmon/minmon.fifo will erase your entire system. I'll get to fixing that, but I'll have to learn more about fifos and properly using permissions first. ONLY use this program if you're confident that nobody would / could exploit it to escalate their privileges.

*IMPORTANT: This will only work for applications that are being nice to the WM and set their _NET_WM_PID property. So far, that was true for all that I tested, but I heard that some aren't that nice. You're out of luck in that case.

*It will also not work if the windows are spawned by another parent, of course. For instance, rox-filer won't work with it because the command just tells rox to open a new filer window. Furthermore, this will confuse minmond and result in unspecified behavior.

*This is intended to be used with a lightweight WM - I'm running compiz standalone without any UI elements except for stalonetray, so this functionality was vital to me. I have no idea what the likes of Unity will do.

*Id doesn't work well with applications that implement the functionality themselves. It tried to use it for spotify because its systray support sucks, but couldn't restore hidden windows.

*The functionality is very basic, logs don't work properly, communication between the scripts is a mess, and so on. Plus there is no error handling, so it ends up in an undefined state very quickly with unforeseen problems. I will work on that when I'm motivated to do so; for now, I'm fed up with what has become of a simple google search for "evolution tray"...

*Icons are currently just looked up by the name of your command, which makes them depend on your theme etc. So chances are that you'll end up with a row of "icon not found" icons in your status bar.

*I have no idea if I'm using git properly. I sincerely hope that this will just work if you download the scripts.

So, tell me if this is a project that's worth pursuing, what's wrong with the premise, how many bugs there are, how awful my code is, etc.

Thanks!
V

Last edited by Vinter; 01-10-2014 at 08:17 AM.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
LXer: Fedora Project's Robyn Bergeron: The Linux Desktop Is Almost Ready for Its Close-Up LXer Syndicated Linux News 0 03-12-2013 09:20 PM
CD tray doesn't close with command X.Cyclop Linux - Hardware 2 08-11-2010 03:13 PM
function use to determine if a dvd-driver tray is close jaepi Linux - Hardware 2 05-30-2007 08:46 PM
error: Could not start the printer tray Bahmanf Debian 2 10-05-2004 04:32 AM
Start program minimize and as a tray icon in IceWM GT_Onizuka Linux - Software 1 03-21-2004 03:17 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Desktop

All times are GMT -5. The time now is 04:12 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration