Monday, August 29, 2011

system tray icon hiding

To all application developers who create a KStatusNotifierItem in their application, please consider making your icon as friendly to the user through automatic hiding as possible. The system tray is a very valuable bit of real estate and unless your application's entry there is actually useful to the user, it ought to be hidden. KStatusNotifierItem allows you to set the status of your icon to Passive, Active or NeedsAttention. Setting it to Passive will automatically signal the system tray to hide the icon automatically. The user may always override this in the settings, so if they always want it shown .. they can!

Of course, what is the meaning of "useful"? That's the trick here. We're trying to make the system tray as "quiet" as possible for the user so that the entries that do show up are a good signal to the user that they actually matter.

So now the battery icon goes away when the system is plugged in and the battery is at 100% charge and the information icon (jobs and announcements) goes away when it is empty. I've patched a few other applications such a konversation and ktorrent to also go Passive when they aren't actively downloading or there are no message alerts (respectively).

If your application doesn't have something to actually tell the user: set the icon to Passive. The system tray icon is not a replacement for the task bar. (In fact, in 4.8 it is quite likely that application entries will appear in the tasks widget instead of the system tray by default!) There is an exception (as usual ;) which is applications which provide user interface in their system tray entry, such as media players. We generally discourage such usage, but it can make sense in specific cases. Over time, we'd like to see these uses also phased out in favour of merging those interfaces with the relevant UI; media player controls and the volume control, for instance, or instant messaging accesses and a proper presence Plasmoid.

24 comments:

jjark said...

This is great reminder.

Any easy way that I can add/change this on to the existing apps/icons on my current tray?

J

Pinheiro said...

YOU ROCK

Thijs said...

Yes, please :)
I may sometimes be a bit agressive with this, as I like to have many windows open and a single row taskbar. Currently (KDE 4.6) I have KRandr, Battery, Bluetooth, KMix and Network Management hidden. KMix is clearly my own choice (the keyboard shortcuts work well enough for me), but battery, KRandr and Network are a fine balance for me between real estate and clicking like mad when I need them.
For me (== me) your Battery settings sound very sane and would cause me to move it to auto again.
Bluetooth may be hidden as long as no connection is being made (like device notifier or so).
Network Management is a tricky one.... I'd be inclined to say to show it only when there are network connections available (wired or wireless), but no connections are used.
KRandr is also tough....

BTW, KMail, Kopete and Amarok simply sit on the taskbar, not the systray. If they want my attention, they can flag the taskbar, and Ctrl+Alt+A is a perfect short cut. If I want their attention, I'm at the "Main" Activity within 2 or three Win+Tabs.

To me, the hiding of the Notifier would be very useful, but in practice it is quite often full for me. So to have that working, it would probably beneficial to make sure that e.g. PIM, IM, file management and so forth clean up there notifier back log whenever possible. As an example: A new mail notification can be removed as soon as I've clicked on KMail after the notification.

This may be useless info, but it is a KDE user's workflow... so then again, may be not ;) And sorry if I come across as directive in a mere blogcomment.

Tuukka said...

Well, how about klipper? Why does it always have its icon visible in the system tray? Is the system tray a right place for it in the first place?

I used to always tell it to quit because I don't need to browse my clipboard contents. I only recently realized that it actually has a very essential function: it prevents clipboard contents from disappearing when the application where the contents are from is closed (and saves you from endless frustration). I only wish there was a way to keep it storing my copied text but make the icon go out of my sight...

Aaron J. Seigo said...

@jjark: for it to happen automatically, you need to change the source code for the respective apps.

you can, however, as a user, configure the default behaviour by opening up the system tray configuration dialog and going into the "entries" page.

@Thijs: the issues you highlight are all tings we're working towards slowly sorting out. we don't have someone who works exclusively on this area of the UI, so we sort of take turns pecking away at issues such as autohide behaviours and notifiaction expiration. more hands will make it go faster, but even with the hands we whave we'll get their eventually.

@Tuukka: klipper is a hard one, indeed. the reason it is always shown is that it provides access to clipboard actions. i'm ont sure if that's a good enough excuse, but it is the reasoning behind it.

you can, as a user, make it always hidden by setting it to Hidden on the Entries page of the system tray configuration dialog.

mark-wege said...

I filled a wish for Kmix in order to only show the icon only when sound is playing. Unfortunataly the author has no way of detecting when a sound is playing.
https://bugs.kde.org/show_bug.cgi?id=203199
May be someone here knows a solution?

ChALkeR said...

So, can you please have a look at bluedevil icon?

It is always visible in auto mode, even when there are no active devices or bluetooth is disabled.

ChALkeR said...

@mark-wege PulseAudio? Take a look at pavucontrol.

Also, there are two things to think about: do you plan on showing the kmix icon on system notifications? That would lead to «blinking» of kmix icon in the system tray.

The second one is audio recording, i would want to see kmix active when some program is recording audio, too. That also could be done via PulseAudio.

Naproxeno said...

I've notice that Nepomuk's icon is permanently shown in system tray since 4.7 (at least in Kubuntu).

In previous releases, it autohid when it wasn't indexing something and I think that should be its behaviour. Someone should restore that functionality.

Kai Uwe said...

Great :) Sounds great.
Do the applications publish their systray context menu to Plasma/tray Applet (via dbus or so?) So that one can add additional entries to the menu?
Adding a "Always Show this icon" entry might make this functionality more easily discoverable than the plasmoid's config ui?

renoX said...

@mark-wege: I'm not sure that it is a good idea: if I want to play a movie, I want to setup the volume *before* starting the application, otherwise
-if the volume is set to zero I will have to make the player reread from the beginning
-if it's too loud, it's annoying.
So if you change the default, please provide an easy way to revert the configuration to something less annoying for those of us who doesn't have ultra-small screens.

Naproxeno said...

@renoX As far as I know, it's always possible to force a tray icon to be always shown or hidden (the option it's in system tray preferences).

That way, if you want to have the sound control always in your system tray it's just a matter of changing a setting, even if the default behaviour is modified.

Shiva said...

nice article but why do you using a KDE ! It is so slow and too fancy not neet enough for developers ! I personally run and develop Xfce

toddrme2178 said...

Yes, please! My pet peeves in this case are KAlarm and Akregator. Kalarm should not show itself if there are no alarms active, and Akregator should not show itself if there are no unread feeds. Akregator already has a bug report about this from 2005.

For klipper, maybe by default it can show itself for a certain amount of time after something is copied or cut, and then hide itself? Although this would require that resizing of panels be made a lot smoother since the panel might resize a lot.

I agree that bluedevil should be hidden when there are no connections.

Networkmanager should probably be hidden if it is on a wired connection and there are no errors, or if it is any system connection.

For your description of the plans for KDE SC 4.8, am I reading it right that you are not planning to support integrating controls and indicators into the task manager? (like media player controls in thumbnails or progress meters in thumbnails or entries) That is a feature I have been really looking forward to.

Jaroslav "Rezza" Reznik said...

I usually hide not needed tray icons and makes sense for a lot of stuff that's not active but on the other hand this leads to disappearing and reappearing of icons - sometimes it feels strange and sometimes icons appears on different place (and behaves strangely...).

MarkoK said...

What if we would move the notification system from a system tray to better place? So every notification would be somewhere else than system tray?
I can see system tray as a "second hand" place for multitasking system where some kind background service need to sit but still be accessible and that service does not have a own window.

kde brainstorm had great idea of that but I can not find it now.

Two things I think should be changed radically in KDE. A notification system and a activities.

MarkoK said...

@Shiva

A great developer/engineer/designer/... use the product what she or he is manufacturing/coding/designing etc.

If you design cell phones, you better use it as your only phone. If you code a software, you better use it daily.

The problem is that you easily come blinded from your own work. You easily don't want to throw away the work what you have done if someone else suggest better idea than what you have done. That is the hard part to express yourself and swallow your pride and jump to the better idea as later it just comes harder and harder.

If you dont use your own production, then you dont care so much about it and you dont even know it so well than you think.

Great product is such what you can suggest to everyone.
And it must be such what you can use in daily purposes.

You can not be a great coder if you say that your produced software is best but you do not use it yourself.
It is same thing as you would give critic of the software (like Visual Studio) how bad and terrible it is and no one should use it. And then in late hours you boot to Windows and continue working with it.

The mantra "Don't as I do, do as I say" does not help to develop a better world.

Better mantra is "You need to sleep on the bed what you made".

Hans said...

Maybe I'm late to the party, but I have a question regarding exactly this that I've been thinking about. Hope I can get an answer here. :)

I've made a plasmoid that can sit in the system tray[1]. Normally it doesn't do anything nor provide the user with information, but it's supposed to be easily accessible, similar to Klipper. The rationale is that if it's hidden users won't use it (the purpose of the widget is to keep you from procrastinating; now it's visible all the time, constantly reminding you that you can activate it with just one click).

Sure, I could do as this blog post suggests and then people can simply set it to always visible if they want. But I want this (i.e., visible all the time) to be the default behavior, while letting people who want it to autohide to set it to "Auto". Is this possible other than having an extra option in the widget?

-
[1] http://kde-apps.org/content/show.php/Procrastinate+No+More?content=142783

Aaron J. Seigo said...

@Hans: just call setStatus(Plasma::ActiveStatus) in your applet and never change it. voila! :)

Hans said...

@Aaron: Thanks for answering! I still don't quite understand, though: what difference does it make if I set it to Active compared to not setting the status at all?

Maybe I wasn't clear enough in my previous post. I want the widget to offer three options: "Auto", "Always visible" and "Always hidden". This can already be set in the system tray settings. However, I haven't implemented an "Auto" behavior (i.e., the widget is set to Passive if it's not active) because "Auto" is the default setting, while I want "Always visible" to be the default. So currently "Auto" = "Always visible".

Kai Uwe said...

@ChALkeR:
I just yesterday hat the same idea, I bought myself a bluetooth stick for the PC and the BlueDevil icon somehow annoyed me in the System Tray.

At the moment the BlueDevil icon only disappears if either BlueDevil is disabled or if there are now bluetooth adapters found at all. But once there is a bluetooth adapter there, it will remain in system tray.

I changed the behaviour yesterday that it auto-hides if there is no adapter enabled, i. e. if you choose "Disable Bluetooth" from the Bluetooth tray icon context menu. However, as many (or at least the one in my notebook :P) still drain power if they are only disabled by software and not e.g. via Fn keys, the bluetooth icon will stay there if your system is running on battery (but the icon will be dimmed).

Hope this satisfies you as well :P
I was not yet able to test if it actually not hides if battery because I screwed up my notebook, so I will re-install it tomorrow, do some testing and then I will finally commit it. But it will definitly be in 4.8 then :)

Thijs said...

Just installed KDE-master last week to see whether my contributions could move beyond blog comments.... to find out that as far as my VirtualBox is concerned, all is hiding and showing cleverly, even including LionMail it seems. Kudos!

Fraz said...

What about things like Weather Forecast?

. said...

Hello, i use kde since v4.3 and i look online for problem with icon size. no making possible of bigger icons in system tray? why not?
system tray is thing most watching people on the computer, no?
then why not me make icon big like I want?
I can make everithing big and bigger how I like but no system tray. can not do in taskbar and can not do when system tray is wiget on dekstop.
everything about kde is able to customice as i like but system tray icons. with svg graphics is not this small problem?
curious.