Goals of this library:
Temporary limitations:
Future:
Prerequisits:
sudo apt install cmake
sudo apt install pkgconf
sudo apt-get install libdbus-1-dev
Building:
git clone https://github.com/encharm/libsystemtray.git
cd libsystemtray && mkdir build && cd build
cmake ..
make
sudo make install
Note, the examples set icon from name, but you can also use:
KDETrayIcon::setIconPixmap(int w, int h, const uint8_t* data);
or the equivalent in C API
void kdetrayicon_set_overlay_icon_pixmap(kdetrayicon* handle, int w, int h, const uint8_t* data);
The data
needs to be a in 32-bit RGBA format.
As per tests/iconbyname.cpp
:
#include <systemtray/kde.h>
#include <cstdio>
int main(void)
{
KDETrayIcon icon("test");
icon.setIconName("mail-client");
icon.setTitle("Mail Client Icon Test");
// left click
icon.onActivate([=](int x, int y) {
printf("Activate %i %i\n", x, y);
});
// middle click
icon.onSecondaryActivate([=](int x, int y) {
printf("Secondary activate %i %i\n", x, y);
});
// right click
icon.onContextMenu([=](int x, int y) {
printf("Context menu %i %i\n", x, y);
});
// scroll over icon
icon.onScroll([=](int offset, std::string orientation) {
printf("Scroll %i %s\n", offset, orientation.c_str());
});
while(icon.process(10));
return 0;
}
#include <systemtray/kde.h>
#include <stdio.h>
static void handler(int x, int y, void* label) {
printf("%s %i %i\n", (char*)label, x, y);
}
static void scroll_handler(int scroll, const char* orientation, void* label) {
printf("%s %i %s\n", (char*)label, scroll, orientation);
}
int main(void)
{
kdetrayicon* handle = kdetrayicon_create("test");
kdetrayicon_set_icon_name(handle, "mail-client");
kdetrayicon_set_title(handle, "Mail Client Icon Test");
// left click
kdetrayicon_on_activate(handle, handler, "Activate");
// middle click
kdetrayicon_on_secondary_activate(handle, handler, "Secondary activate");
// right click
kdetrayicon_on_context_menu(handle, handler, "Secondary activate");
// scroll over icon
kdetrayicon_on_scroll(handle, scroll_handler, "Scroll");
while(kdetrayicon_process(handle, 10));
return 0;
}
Copyright (c) 2014 Code Charm Ltd
Licensed under the MIT license, see LICENSE
for details.