KDE includes a nifty program named “ksystraycmd”:
ksystraycmd - Allows any application to be kept in the system tray
Perhaps the most used way to start something in tray is to execute (for example, via alt-F2):
ksystraycmd program
The desktop icons also have an option for tray: right click → properties → application → Advanced options → [x] Place in system tray (now which one was more simple again, CLI or GUI?
)
However, you can also move an already running program into the tray, by specifying –wid and the window id for ksystraycmd. This is not very useful by itself, until you combine it with xwininfo to allow creation of a shortcut that can tray-iconize a clicked window.
This is the content for kde-iconize (a script part of the scripts package):
kde-iconize
#!/bin/bash # Click on a window make it go into the tray ksystraycmd --wid $(xwininfo |grep 'Window id:' |cut -d' ' -f4)
Saving that in a file and creating a desktop shortcut (or maybe even creating a global hotkey) allows you to decide at runtime when to put a program in the tray, with a single click.