Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Swaybar tray #3249

Merged
merged 15 commits into from Dec 31, 2018
Merged

Swaybar tray #3249

merged 15 commits into from Dec 31, 2018

Conversation

ianyfan
Copy link
Contributor

@ianyfan ianyfan commented Dec 4, 2018

Now that this is nearing feature-completion, I would very much appreciate anyone who would like to help test this out and let me know which applications don't work to see what edge cases I haven't accounted for.
Electron apps require the environment variable XDG_CURRENT_DESKTOP=Unity so you may have to run apps like XDG_CURRENT_DESKTOP=Unity slack for example. ref: electron/electron#10427

Supersedes #2645 (thanks to @mckinney-subgraph for the jumping-off point)

Closes #1768, closes #1372

Refs:

I implemented the KDE protocol since I couldn't find any apps that implemented the XDG/freedesktop protocol to test it.

The watcher This is pretty much feature-complete. The rest is a barebones implementation that just about works with many bugs, especially in the rendering, since I'm not very knowledgeable about cairo, hopefully someone can give me a few tips? or I'll work it out eventually.

Notable bug: bus events sometimes aren't processed on startup. (I'm not sure if this is still happening)

I only realised right at the end that clicks are going to be quite haphazard since we can't get the global coordinates, which are needed to send to the app.

But since it basically works, I'm putting it here so that people know that this feature is not being ignored. :)

@4e554c4c let me know if I'm doing anything horribly wrong :P

Things that will definitely be done in this PR:

  • polish rendering and mouse events (did the best I could)
  • tidy commits
  • fallback rendering if icon is not found (we can't guarantee to know anything useful about the application, so I'm just drawing a sad face; please comment if you have a better suggestion)
  • add support for XDG protocol, at the very least, it will be a copy of the KDE code with the KDE-specific features stripped out
  • merge XDG & KDE code, since most of it is the same, want to reduce the amount of repeated code. I think the main features KDE allows that are different from XDG are: registering by object path; providing an IconThemePath property that specifies where the icon is, though the few programs that I have tested with have not required this. Hence, it might not be that difficult to merge them, but I am worried that I have missed some subtleties that would make this much more complicated.
  • Use IconPixmap as fallback, since this is used in apps like Telegram and Dropbox
  • Get item properties asynchronously, since currently, there is a deadlock that can occur if the process that registers the icon synchronously calls a method as the host synchronously requests the item properties
  • fix funny bug that occurs if there are multiple trays running and you restart the tray with the watcher
  • use IconThemePath property of KDE SNIs (though I currently only check if the icon is in the directory, for simplicity; I'm not sure whether any applications actually install entire themes through this, which would complicate matters a bit)

Things that may be done but not definitely:

Things that will probably be left for another PR:

  • XEmbed proxy
  • Canonical DBus menu
  • All the properties I've ignored, such as title and tooltip
  • Re-arrange icons: this theoretically could be done, but it not only requires a lot of extra input-handling code, but a decision on how to distinguish a regular click from a click to move the icon, so may not be practical

@ianyfan ianyfan self-assigned this Dec 4, 2018
@artizirk
Copy link

artizirk commented Dec 6, 2018

Build seems to fail on my Arch Linux machine with this error

tray_item_kde.c.o: undefined reference to symbol 'sd_bus_get_property_string@@LIBSYSTEMD_221'

Full build log:

arti@orav ~/code/sway (git)-[tray] % meson build -Denable-tray=true    
The Meson build system
Version: 0.48.2
Source dir: /home/arti/code/sway
Build dir: /home/arti/code/sway/build
Build type: native build
Project name: sway
Project version: undefined
Native C compiler: ccache cc (gcc 8.2.1 "cc (GCC) 8.2.1 20180831")
Build machine cpu family: x86_64
Build machine cpu: x86_64
Found pkg-config: /usr/bin/pkg-config (1.5.4)
Dependency json-c found: YES 0.13.1
Dependency libpcre found: YES 8.42
Dependency wlroots found: YES 0.2.0
Dependency wayland-server found: YES 1.16.0
Dependency wayland-client found: YES 1.16.0
Dependency wayland-cursor found: YES 1.16.0
Dependency wayland-egl found: YES 18.1.0
Dependency wayland-protocols found: YES 1.17
Dependency xkbcommon found: YES 0.8.2
Dependency cairo found: YES 1.16.0
Dependency pango found: YES 1.42.3
Dependency pangocairo found: YES 1.42.3
Dependency gdk-pixbuf-2.0 found: YES 2.38.0
Dependency pixman-1 found: YES 0.36.0
Dependency libinput found: YES 1.12.3
Library pam found: YES
Library crypt found: YES
Dependency libsystemd found: YES 239
Dependency libelogind found: NO (tried pkgconfig)
Library m found: YES
Library rt found: YES
Program git found: YES (/usr/bin/git)
Dependency xcb found: YES 1.13.1
Program scdoc found: YES (/usr/bin/scdoc)
Program sh found: YES (/usr/bin/sh)
Configuring config.h using configuration
Program wayland-scanner found: YES (/usr/bin/wayland-scanner)
Dependency threads found: YES 
Configuring config using configuration
WARNING: Output file "@BASENAME@" for configure_file() at meson.build:172 overwrites configure_file() output at meson.build:157
Configuring 00-defaults using configuration
Build targets in project: 21
Option werror is: True [default: true]
Found ninja-1.8.2 at /usr/bin/ninja
arti@orav ~/code/sway (git)-[tray] % ninja -C build 
ninja: Entering directory `build'
[273/281] Linking target swaybar/swaybar.
FAILED: swaybar/swaybar 
ccache cc  -o swaybar/swaybar 'swaybar/swaybar@@swaybar@exe/bar.c.o' 'swaybar/swaybar@@swaybar@exe/config.c.o' 'swaybar/swaybar@@swaybar@exe/i3bar.c.o' 'swaybar/swaybar@@swaybar@exe/input.c.o' 'swaybar/swaybar@@swaybar@exe/ipc.c.o' 'swaybar/swaybar@@swaybar@exe/main.c.o' 'swaybar/swaybar@@swaybar@exe/render.c.o' 'swaybar/swaybar@@swaybar@exe/status_line.c.o' 'swaybar/swaybar@@swaybar@exe/tray_host_kde.c.o' 'swaybar/swaybar@@swaybar@exe/tray_icon.c.o' 'swaybar/swaybar@@swaybar@exe/tray_item_kde.c.o' 'swaybar/swaybar@@swaybar@exe/tray_tray.c.o' 'swaybar/swaybar@@swaybar@exe/tray_watcher_kde.c.o' -Wl,--no-undefined -Wl,--as-needed -Wl,--start-group common/libsway-common.a client/libsway-client.a protocols/libclient_protos.a /usr/lib/libcairo.so /usr/lib/libgdk_pixbuf-2.0.so /usr/lib/libgobject-2.0.so /usr/lib/libglib-2.0.so /usr/lib/libjson-c.so -lm /usr/lib/libpango-1.0.so /usr/lib/libpangocairo-1.0.so -lrt /usr/lib/libwayland-client.so /usr/lib/libwayland-cursor.so /usr/lib/libwlroots.so -Wl,--end-group '-Wl,-rpath,$ORIGIN/../common:$ORIGIN/../client:$ORIGIN/../protocols' -Wl,-rpath-link,/home/arti/code/sway/build/common:/home/arti/code/sway/build/client:/home/arti/code/sway/build/protocols  
/usr/bin/ld: swaybar/swaybar@@swaybar@exe/tray_item_kde.c.o: undefined reference to symbol 'sd_bus_get_property_string@@LIBSYSTEMD_221'
/usr/bin/ld: /usr/lib/libsystemd.so.0: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status
[280/281] Linking target sway/sway.
ninja: build stopped: subcommand failed.
ninja -C build  8,70s user 1,55s system 1383% cpu 0,741 total
1 arti@orav ~/code/sway (git)-[tray] %

@progandy
Copy link
Contributor

progandy commented Dec 6, 2018

The swaybar meson build is probably missing the dependency for systemd / elogind.

@ianyfan
Copy link
Contributor Author

ianyfan commented Dec 6, 2018

@artizirk Has the latest commit (i.e. 8aa035a) fixed it?

@artizirk
Copy link

artizirk commented Dec 6, 2018

@ianyfan Yes, it compiles now, thank you!

Although it currently segmentation faults as soon as i have any programs running that provide a tray icon

/swaybar --bar_id bar-0 --debug
2018-12-06 16:13:00 - [swaybar/tray/icon.c:323] Loaded themes: (null)
2018-12-06 16:13:00 - [swaybar/tray/tray.c:35] Initialized tray
2018-12-06 16:13:00 - [swaybar/status_line.c:72] Using i3bar protocol.
2018-12-06 16:13:00 - [swaybar/status_line.c:78] Enabling click events.
2018-12-06 16:13:00 - [swaybar/i3bar.c:199] Received i3bar json: '[]'
2018-12-06 16:13:00 - [swaybar/i3bar.c:199] Received i3bar json: '[{"full_text":""}]'
2018-12-06 16:13:00 - [swaybar/i3bar.c:199] Received i3bar json: '[{"full_text":""},{"":"","full_text":"2018-12-06 16:13:00","name":"time","separator_block_width":15,"markup":"none"}]'
2018-12-06 16:13:00 - [swaybar/i3bar.c:199] Received i3bar json: '[{"full_text":""},{"":"","full_text":"2018-12-06 16:13:00","name":"time","separator_block_width":15,"markup":"none"}]'
2018-12-06 16:13:00 - [swaybar/i3bar.c:199] Received i3bar json: '[{"full_text":""},{"":"","full_text":"SWAP 0.0G","name":"memory","instance":"swap","separator":false,"separator_block_width":15,"markup":"none"},{"":"","full_text":"2018-12-06 16:13:00","name":"time","separator_block_width":15,"markup":"none"}]'
2018-12-06 16:13:00 - [swaybar/i3bar.c:199] Received i3bar json: '[{"full_text":""},{"":"","full_text":"SWAP 0.0G","name":"memory","instance":"swap","separator":false,"separator_block_width":15,"markup":"none"},{"":"","full_text":"HOME 158G","short_text":"158G","name":"disk","separator_block_width":15,"markup":"none"},{"":"","full_text":"2018-12-06 16:13:00","name":"time","separator_block_width":15,"markup":"none"}]'
2018-12-06 16:13:00 - [swaybar/i3bar.c:199] Received i3bar json: '[{"full_text":""},{"":"","full_text":"MEM 26.6G","name":"memory","separator":false,"separator_block_width":15,"markup":"none"},{"":"","full_text":"SWAP 0.0G","name":"memory","instance":"swap","separator":false,"separator_block_width":15,"markup":"none"},{"":"","full_text":"HOME 158G","short_text":"158G","name":"disk","separator_block_width":15,"markup":"none"},{"":"","full_text":"2018-12-06 16:13:00","name":"time","separator_block_width":15,"markup":"none"}]'
2018-12-06 16:13:00 - [swaybar/i3bar.c:199] Received i3bar json: '[{"full_text":""},{"":"","full_text":"MEM 26.6G","name":"memory","separator":false,"separator_block_width":15,"markup":"none"},{"":"","full_text":"SWAP 0.0G","name":"memory","instance":"swap","separator":false,"separator_block_width":15,"markup":"none"},{"":"","full_text":"HOME 158G","short_text":"158G","name":"disk","separator_block_width":15,"markup":"none"},{"":"","full_text":"IN 15K OUT 0K","name":"bandwidth","separator_block_width":15,"markup":"none"},{"":"","full_text":"2018-12-06 16:13:00","name":"time","separator_block_width":15,"markup":"none"}]'
2018-12-06 16:13:00 - [swaybar/i3bar.c:199] Received i3bar json: '[{"full_text":""},{"":"","full_text":"MEM 26.6G","name":"memory","separator":false,"separator_block_width":15,"markup":"none"},{"":"","full_text":"SWAP 0.0G","name":"memory","instance":"swap","separator":false,"separator_block_width":15,"markup":"none"},{"":"","full_text":"HOME 158G","short_text":"158G","name":"disk","separator_block_width":15,"markup":"none"},{"":"","full_text":"172.26.1.168","short_text":"172.26.1.168","color":"#00FF00","name":"iface","separator":false,"separator_block_width":15,"markup":"none"},{"":"","full_text":"IN 15K OUT 0K","name":"bandwidth","separator_block_width":15,"markup":"none"},{"":"","full_text":"2018-12-06 16:13:00","name":"time","separator_block_width":15,"markup":"none"}]'
2018-12-06 16:13:00 - [swaybar/i3bar.c:199] Received i3bar json: '[{"full_text":""},{"":"","full_text":"MEM 26.6G","name":"memory","separator":false,"separator_block_width":15,"markup":"none"},{"":"","full_text":"SWAP 0.0G","name":"memory","instance":"swap","separator":false,"separator_block_width":15,"markup":"none"},{"":"","full_text":"HOME 158G","short_text":"158G","name":"disk","separator_block_width":15,"markup":"none"},{"":"","full_text":"172.26.1.168","short_text":"172.26.1.168","color":"#00FF00","name":"iface","separator":false,"separator_block_width":15,"markup":"none"},{"":"","full_text":"IN 15K OUT 0K","name":"bandwidth","separator_block_width":15,"markup":"none"},{"":"","full_text":"2018-12-06 16:13:00","name":"time","separator_block_width":15,"markup":"none"}]'
2018-12-06 16:13:00 - [swaybar/i3bar.c:199] Received i3bar json: '[{"full_text":""},{"":"","full_text":"♪ 100%","name":"volume","instance":"Master","separator_block_width":15,"markup":"none"},{"":"","full_text":"MEM 26.6G","name":"memory","separator":false,"separator_block_width":15,"markup":"none"},{"":"","full_text":"SWAP 0.0G","name":"memory","instance":"swap","separator":false,"separator_block_width":15,"markup":"none"},{"":"","full_text":"HOME 158G","short_text":"158G","name":"disk","separator_block_width":15,"markup":"none"},{"":"","full_text":"172.26.1.168","short_text":"172.26.1.168","color":"#00FF00","name":"iface","separator":false,"separator_block_width":15,"markup":"none"},{"":"","full_text":"IN 15K OUT 0K","name":"bandwidth","separator_block_width":15,"markup":"none"},{"":"","full_text":"2018-12-06 16:13:00","name":"time","separator_block_width":15,"markup":"none"}]'
2018-12-06 16:13:00 - [swaybar/i3bar.c:253] Rendering last received json
2018-12-06 16:13:00 - [swaybar/tray/watcher_kde.c:74] Registering Status Notifier Item ':1.20432/org/ayatana/NotificationItem/blueman'
2018-12-06 16:13:00 - [swaybar/tray/watcher_kde.c:96] Registering Status Notifier Host 'org.kde.StatusNotifierHost-30413'
2018-12-06 16:13:00 - [swaybar/tray/host_kde.c:20] Registering Status Notifier Item ':1.20432/org/ayatana/NotificationItem/blueman'
2018-12-06 16:13:00 - [swaybar/tray/item_kde.c:24] TODO remove - IconName: blueman-active
[1]    30413 segmentation fault (core dumped)  ./swaybar --bar_id bar-0 --debug

@ianyfan
Copy link
Contributor Author

ianyfan commented Dec 6, 2018

No themes are being found, even though looking at the blueman package, it does install icons into /usr/share/icons/hicolor. My guess is either your $XDG_DATA_DIRS variable is malformed, which means that /usr/share isn't being searched for icons, or your hicolor directory does not contain the file index.theme (or the file is corrupted), in which case you should reinstall it from https://www.freedesktop.org/software/icon-theme/releases/

I should probably add a warning message if the "Hicolor" is not found, since it is required to be present as a fallback.

@artizirk
Copy link

artizirk commented Dec 6, 2018

On My machine default is this

XDG_DATA_DIRS=/home/arti/.local/share/flatpak/exports/share/:/var/lib/flatpak/exports/share/:/usr/local/share/:/usr/share/

so /usr/share is in the search path

I reinstalled hicolor-icon-theme package from arch linux repo so index.theme file should be fine (it exists and doesn't look corrupted).

Forcing XDG_DATA_DIRS to be only /usr/share/ doesn't do much but setting it to /usr/share/icons/hicolor/scalable/status/ (witch is quite wrong, i know) and running swaybar with strace shows that it finds some icons.

Im not really sure how to debug this more.

edit:

setting export XDG_DATA_DIRS=/usr/share/icons seems to help swaybar tray to find my themes

arti@orav ~/code/sway_tray/build/swaybar (git)-[tray] % export XDG_DATA_DIRS=/usr/share/icons
arti@orav ~/code/sway_tray/build/swaybar (git)-[tray] % ./swaybar --bar_id bar-0 --debug
2018-12-06 18:02:25 - [swaybar/tray/icon.c:323] Loaded themes: Hicolor, Adwaita, HighContrast
2018-12-06 18:02:25 - [swaybar/tray/tray.c:35] Initialized tray
2018-12-06 18:02:25 - [swaybar/status_line.c:72] Using i3bar protocol.
2018-12-06 18:02:25 - [swaybar/status_line.c:78] Enabling click events.
2018-12-06 18:02:25 - [swaybar/i3bar.c:199] Received i3bar json: '[]'
2018-12-06 18:02:25 - [swaybar/i3bar.c:199] Received i3bar json: '[{"full_text":""}]'
2018-12-06 18:02:25 - [swaybar/i3bar.c:199] Received i3bar json: '[{"full_text":""},{"":"","full_text":"2018-12-06 18:02:25","name":"time","separator_block_width":15,"markup":"none"}]'
2018-12-06 18:02:25 - [swaybar/i3bar.c:199] Received i3bar json: '[{"full_text":""},{"":"","full_text":"2018-12-06 18:02:25","name":"time","separator_block_width":15,"markup":"none"}]'
2018-12-06 18:02:25 - [swaybar/i3bar.c:199] Received i3bar json: '[{"full_text":""},{"":"","full_text":"MEM 26.6G","name":"memory","separator":false,"separator_block_width":15,"markup":"none"},{"":"","full_text":"2018-12-06 18:02:25","name":"time","separator_block_width":15,"markup":"none"}]'
2018-12-06 18:02:25 - [swaybar/i3bar.c:199] Received i3bar json: '[{"full_text":""},{"":"","full_text":"MEM 26.6G","name":"memory","separator":false,"separator_block_width":15,"markup":"none"},{"":"","full_text":"SWAP 0.0G","name":"memory","instance":"swap","separator":false,"separator_block_width":15,"markup":"none"},{"":"","full_text":"2018-12-06 18:02:25","name":"time","separator_block_width":15,"markup":"none"}]'
2018-12-06 18:02:25 - [swaybar/i3bar.c:199] Received i3bar json: '[{"full_text":""},{"":"","full_text":"MEM 26.6G","name":"memory","separator":false,"separator_block_width":15,"markup":"none"},{"":"","full_text":"SWAP 0.0G","name":"memory","instance":"swap","separator":false,"separator_block_width":15,"markup":"none"},{"":"","full_text":"HOME 158G","short_text":"158G","name":"disk","separator_block_width":15,"markup":"none"},{"":"","full_text":"2018-12-06 18:02:25","name":"time","separator_block_width":15,"markup":"none"}]'
2018-12-06 18:02:25 - [swaybar/i3bar.c:199] Received i3bar json: '[{"full_text":""},{"":"","full_text":"MEM 26.6G","name":"memory","separator":false,"separator_block_width":15,"markup":"none"},{"":"","full_text":"SWAP 0.0G","name":"memory","instance":"swap","separator":false,"separator_block_width":15,"markup":"none"},{"":"","full_text":"HOME 158G","short_text":"158G","name":"disk","separator_block_width":15,"markup":"none"},{"":"","full_text":"172.26.1.168","short_text":"172.26.1.168","color":"#00FF00","name":"iface","separator":false,"separator_block_width":15,"markup":"none"},{"":"","full_text":"2018-12-06 18:02:25","name":"time","separator_block_width":15,"markup":"none"}]'
2018-12-06 18:02:25 - [swaybar/i3bar.c:199] Received i3bar json: '[{"full_text":""},{"":"","full_text":"MEM 26.6G","name":"memory","separator":false,"separator_block_width":15,"markup":"none"},{"":"","full_text":"SWAP 0.0G","name":"memory","instance":"swap","separator":false,"separator_block_width":15,"markup":"none"},{"":"","full_text":"HOME 158G","short_text":"158G","name":"disk","separator_block_width":15,"markup":"none"},{"":"","full_text":"172.26.1.168","short_text":"172.26.1.168","color":"#00FF00","name":"iface","separator":false,"separator_block_width":15,"markup":"none"},{"":"","full_text":"IN 21K OUT 0K","name":"bandwidth","separator_block_width":15,"markup":"none"},{"":"","full_text":"2018-12-06 18:02:25","name":"time","separator_block_width":15,"markup":"none"}]'
2018-12-06 18:02:25 - [swaybar/i3bar.c:199] Received i3bar json: '[{"full_text":""},{"":"","full_text":"MEM 26.6G","name":"memory","separator":false,"separator_block_width":15,"markup":"none"},{"":"","full_text":"SWAP 0.0G","name":"memory","instance":"swap","separator":false,"separator_block_width":15,"markup":"none"},{"":"","full_text":"HOME 158G","short_text":"158G","name":"disk","separator_block_width":15,"markup":"none"},{"":"","full_text":"172.26.1.168","short_text":"172.26.1.168","color":"#00FF00","name":"iface","separator":false,"separator_block_width":15,"markup":"none"},{"":"","full_text":"IN 21K OUT 0K","name":"bandwidth","separator_block_width":15,"markup":"none"},{"":"","full_text":"2018-12-06 18:02:25","name":"time","separator_block_width":15,"markup":"none"}]'
2018-12-06 18:02:25 - [swaybar/i3bar.c:199] Received i3bar json: '[{"full_text":""},{"":"","full_text":"♪ 100%","name":"volume","instance":"Master","separator_block_width":15,"markup":"none"},{"":"","full_text":"MEM 26.6G","name":"memory","separator":false,"separator_block_width":15,"markup":"none"},{"":"","full_text":"SWAP 0.0G","name":"memory","instance":"swap","separator":false,"separator_block_width":15,"markup":"none"},{"":"","full_text":"HOME 158G","short_text":"158G","name":"disk","separator_block_width":15,"markup":"none"},{"":"","full_text":"172.26.1.168","short_text":"172.26.1.168","color":"#00FF00","name":"iface","separator":false,"separator_block_width":15,"markup":"none"},{"":"","full_text":"IN 21K OUT 0K","name":"bandwidth","separator_block_width":15,"markup":"none"},{"":"","full_text":"2018-12-06 18:02:25","name":"time","separator_block_width":15,"markup":"none"}]'
2018-12-06 18:02:25 - [swaybar/i3bar.c:253] Rendering last received json
2018-12-06 18:02:25 - [swaybar/tray/watcher_kde.c:74] Registering Status Notifier Item ':1.21809/org/ayatana/NotificationItem/blueman'
2018-12-06 18:02:25 - [swaybar/tray/watcher_kde.c:96] Registering Status Notifier Host 'org.kde.StatusNotifierHost-20364'
2018-12-06 18:02:25 - [swaybar/tray/host_kde.c:20] Registering Status Notifier Item ':1.21809/org/ayatana/NotificationItem/blueman'
2018-12-06 18:02:25 - [swaybar/tray/item_kde.c:24] TODO remove - IconName: blueman-active
2018-12-06 18:02:25 - [common/background-image.c:32] Failed to load background image (Couldn’t recognize the image file format for file “/usr/share/icons/hicolor/16x16/status/blueman-active.png”).
2018-12-06 18:02:26 - [swaybar/i3bar.c:199] Received i3bar json: '[{"full_text":""},{"":"","full_text":"♪ 100%","name":"volume","instance":"Master","separator_block_width":15,"markup":"none"},{"":"","full_text":"MEM 26.6G","name":"memory","separator":false,"separator_block_width":15,"markup":"none"},{"":"","full_text":"SWAP 0.0G","name":"memory","instance":"swap","separator":false,"separator_block_width":15,"markup":"none"},{"":"","full_text":"HOME 158G","short_text":"158G","name":"disk","separator_block_width":15,"markup":"none"},{"":"","full_text":"172.26.1.168","short_text":"172.26.1.168","color":"#00FF00","name":"iface","separator":false,"separator_block_width":15,"markup":"none"},{"":"","full_text":"IN 21K OUT 0K","name":"bandwidth","separator_block_width":15,"markup":"none"},{"":"","full_text":"CPU 9.69%","short_text":"9.69%","min_width":"CPU: 100.00%","name":"cpu_usage","separator_block_width":15,"markup":"none"},{"":"","full_text":"2018-12-06 18:02:25","name":"time","separator_block_width":15,"markup":"none"}]'
2018-12-06 18:02:26 - [swaybar/i3bar.c:253] Rendering last received json
[1]    20364 segmentation fault (core dumped)  ./swaybar --bar_id bar-0 --debug
139 arti@orav ~/code/sway_tray/build/swaybar (git)-[tray] % file /usr/share/icons/hicolor/16x16/status/blueman-active.png    
/usr/share/icons/hicolor/16x16/status/blueman-active.png: PNG image data, 16 x 16, 16-bit/color RGBA, non-interlaced

@ianyfan
Copy link
Contributor Author

ianyfan commented Dec 6, 2018

The latest commit should fix this, though I think it makes the function a bit less elegant

@artizirk
Copy link

artizirk commented Dec 7, 2018

Looks like tray doesn't like something in my XDG_DATA_DIRS path

arti@orav ~/code/sway_tray (git)-[tray] % build/swaybar/swaybar --bar_id bar-0 --debug
ERROR block_reap:328: [bandwidth] bad exit code 1
2018-12-07 11:21:26 - [swaybar/tray/icon.c:323] Loaded themes: Hicolor, Hicolor, Adwaita, HighContrast
2018-12-07 11:21:26 - [swaybar/tray/tray.c:36] Initialized tray
2018-12-07 11:21:26 - [swaybar/status_line.c:72] Using i3bar protocol.
2018-12-07 11:21:26 - [swaybar/status_line.c:78] Enabling click events.
2018-12-07 11:21:26 - [swaybar/i3bar.c:199] Received i3bar json: '[]'
2018-12-07 11:21:26 - [swaybar/i3bar.c:199] Received i3bar json: '[{"full_text":""}]'
2018-12-07 11:21:26 - [swaybar/i3bar.c:199] Received i3bar json: '[{"full_text":""},{"":"","full_text":"2018-12-07 11:21:26","name":"time","separator_block_width":15,"markup":"none"}]'
2018-12-07 11:21:26 - [swaybar/i3bar.c:199] Received i3bar json: '[{"full_text":""},{"":"","full_text":"2018-12-07 11:21:26","name":"time","separator_block_width":15,"markup":"none"}]'
2018-12-07 11:21:26 - [swaybar/i3bar.c:199] Received i3bar json: '[{"full_text":""},{"":"","full_text":"HOME 158G","short_text":"158G","name":"disk","separator_block_width":15,"markup":"none"},{"":"","full_text":"2018-12-07 11:21:26","name":"time","separator_block_width":15,"markup":"none"}]'
2018-12-07 11:21:26 - [swaybar/i3bar.c:199] Received i3bar json: '[{"full_text":""},{"":"","full_text":"SWAP 0.0G","name":"memory","instance":"swap","separator":false,"separator_block_width":15,"markup":"none"},{"":"","full_text":"HOME 158G","short_text":"158G","name":"disk","separator_block_width":15,"markup":"none"},{"":"","full_text":"2018-12-07 11:21:26","name":"time","separator_block_width":15,"markup":"none"}]'
2018-12-07 11:21:26 - [swaybar/i3bar.c:199] Received i3bar json: '[{"full_text":""},{"":"","full_text":"MEM 25.4G","name":"memory","separator":false,"separator_block_width":15,"markup":"none"},{"":"","full_text":"SWAP 0.0G","name":"memory","instance":"swap","separator":false,"separator_block_width":15,"markup":"none"},{"":"","full_text":"HOME 158G","short_text":"158G","name":"disk","separator_block_width":15,"markup":"none"},{"":"","full_text":"2018-12-07 11:21:26","name":"time","separator_block_width":15,"markup":"none"}]'
2018-12-07 11:21:26 - [swaybar/i3bar.c:199] Received i3bar json: '[{"full_text":""},{"":"","full_text":"MEM 25.4G","name":"memory","separator":false,"separator_block_width":15,"markup":"none"},{"":"","full_text":"SWAP 0.0G","name":"memory","instance":"swap","separator":false,"separator_block_width":15,"markup":"none"},{"":"","full_text":"HOME 158G","short_text":"158G","name":"disk","separator_block_width":15,"markup":"none"},{"":"","full_text":"2018-12-07 11:21:26","name":"time","separator_block_width":15,"markup":"none"}]'
2018-12-07 11:21:26 - [swaybar/i3bar.c:199] Received i3bar json: '[{"full_text":""},{"":"","full_text":"MEM 25.4G","name":"memory","separator":false,"separator_block_width":15,"markup":"none"},{"":"","full_text":"SWAP 0.0G","name":"memory","instance":"swap","separator":false,"separator_block_width":15,"markup":"none"},{"":"","full_text":"HOME 158G","short_text":"158G","name":"disk","separator_block_width":15,"markup":"none"},{"":"","full_text":"172.26.1.168","short_text":"172.26.1.168","color":"#00FF00","name":"iface","separator":false,"separator_block_width":15,"markup":"none"},{"":"","full_text":"2018-12-07 11:21:26","name":"time","separator_block_width":15,"markup":"none"}]'
2018-12-07 11:21:26 - [swaybar/i3bar.c:199] Received i3bar json: '[{"full_text":""},{"":"","full_text":"MEM 25.4G","name":"memory","separator":false,"separator_block_width":15,"markup":"none"},{"":"","full_text":"SWAP 0.0G","name":"memory","instance":"swap","separator":false,"separator_block_width":15,"markup":"none"},{"":"","full_text":"HOME 158G","short_text":"158G","name":"disk","separator_block_width":15,"markup":"none"},{"":"","full_text":"172.26.1.168","short_text":"172.26.1.168","color":"#00FF00","name":"iface","separator":false,"separator_block_width":15,"markup":"none"},{"":"","full_text":"2018-12-07 11:21:26","name":"time","separator_block_width":15,"markup":"none"}]'
2018-12-07 11:21:26 - [swaybar/i3bar.c:199] Received i3bar json: '[{"full_text":""},{"":"","full_text":"♪ 0%","name":"volume","instance":"Master","separator_block_width":15,"markup":"none"},{"":"","full_text":"MEM 25.4G","name":"memory","separator":false,"separator_block_width":15,"markup":"none"},{"":"","full_text":"SWAP 0.0G","name":"memory","instance":"swap","separator":false,"separator_block_width":15,"markup":"none"},{"":"","full_text":"HOME 158G","short_text":"158G","name":"disk","separator_block_width":15,"markup":"none"},{"":"","full_text":"172.26.1.168","short_text":"172.26.1.168","color":"#00FF00","name":"iface","separator":false,"separator_block_width":15,"markup":"none"},{"":"","full_text":"2018-12-07 11:21:26","name":"time","separator_block_width":15,"markup":"none"}]'
2018-12-07 11:21:26 - [swaybar/i3bar.c:253] Rendering last received json
2018-12-07 11:21:26 - [swaybar/tray/watcher_kde.c:96] Registering Status Notifier Host 'org.kde.StatusNotifierHost-19700'
2018-12-07 11:21:26 - [swaybar/tray/watcher_kde.c:74] Registering Status Notifier Item ':1.37312/org/ayatana/NotificationItem/blueman'
2018-12-07 11:21:26 - [swaybar/tray/host_kde.c:20] Registering Status Notifier Item ':1.37312/org/ayatana/NotificationItem/blueman'
2018-12-07 11:21:26 - [swaybar/tray/item_kde.c:24] TODO remove - IconName: blueman-tray
[2]    19700 segmentation fault (core dumped)  build/swaybar/swaybar --bar_id bar-0 --debug
139 arti@orav ~/code/sway_tray (git)-[tray] % 

Unsetting XDG_DATA_DIRS gets it further

arti@orav ~/code/sway_tray (git)-[tray] % XDG_DATA_DIRS='' build/swaybar/swaybar --bar_id bar-0 --debug
ERROR block_reap:328: [bandwidth] bad exit code 1
2018-12-07 11:22:21 - [swaybar/tray/icon.c:323] Loaded themes: Hicolor, Adwaita, HighContrast
2018-12-07 11:22:21 - [swaybar/tray/tray.c:36] Initialized tray
2018-12-07 11:22:21 - [swaybar/status_line.c:72] Using i3bar protocol.
2018-12-07 11:22:21 - [swaybar/status_line.c:78] Enabling click events.
2018-12-07 11:22:21 - [swaybar/i3bar.c:199] Received i3bar json: '[]'
2018-12-07 11:22:21 - [swaybar/i3bar.c:199] Received i3bar json: '[{"full_text":""}]'
2018-12-07 11:22:21 - [swaybar/i3bar.c:199] Received i3bar json: '[{"full_text":""},{"":"","full_text":"2018-12-07 11:22:21","name":"time","separator_block_width":15,"markup":"none"}]'
2018-12-07 11:22:21 - [swaybar/i3bar.c:199] Received i3bar json: '[{"full_text":""},{"":"","full_text":"2018-12-07 11:22:21","name":"time","separator_block_width":15,"markup":"none"}]'
2018-12-07 11:22:21 - [swaybar/i3bar.c:199] Received i3bar json: '[{"full_text":""},{"":"","full_text":"SWAP 0.0G","name":"memory","instance":"swap","separator":false,"separator_block_width":15,"markup":"none"},{"":"","full_text":"2018-12-07 11:22:21","name":"time","separator_block_width":15,"markup":"none"}]'
2018-12-07 11:22:21 - [swaybar/i3bar.c:199] Received i3bar json: '[{"full_text":""},{"":"","full_text":"SWAP 0.0G","name":"memory","instance":"swap","separator":false,"separator_block_width":15,"markup":"none"},{"":"","full_text":"HOME 158G","short_text":"158G","name":"disk","separator_block_width":15,"markup":"none"},{"":"","full_text":"2018-12-07 11:22:21","name":"time","separator_block_width":15,"markup":"none"}]'
2018-12-07 11:22:21 - [swaybar/i3bar.c:199] Received i3bar json: '[{"full_text":""},{"":"","full_text":"MEM 25.4G","name":"memory","separator":false,"separator_block_width":15,"markup":"none"},{"":"","full_text":"SWAP 0.0G","name":"memory","instance":"swap","separator":false,"separator_block_width":15,"markup":"none"},{"":"","full_text":"HOME 158G","short_text":"158G","name":"disk","separator_block_width":15,"markup":"none"},{"":"","full_text":"2018-12-07 11:22:21","name":"time","separator_block_width":15,"markup":"none"}]'
2018-12-07 11:22:21 - [swaybar/i3bar.c:199] Received i3bar json: '[{"full_text":""},{"":"","full_text":"MEM 25.4G","name":"memory","separator":false,"separator_block_width":15,"markup":"none"},{"":"","full_text":"SWAP 0.0G","name":"memory","instance":"swap","separator":false,"separator_block_width":15,"markup":"none"},{"":"","full_text":"HOME 158G","short_text":"158G","name":"disk","separator_block_width":15,"markup":"none"},{"":"","full_text":"172.26.1.168","short_text":"172.26.1.168","color":"#00FF00","name":"iface","separator":false,"separator_block_width":15,"markup":"none"},{"":"","full_text":"2018-12-07 11:22:21","name":"time","separator_block_width":15,"markup":"none"}]'
2018-12-07 11:22:21 - [swaybar/i3bar.c:199] Received i3bar json: '[{"full_text":""},{"":"","full_text":"MEM 25.4G","name":"memory","separator":false,"separator_block_width":15,"markup":"none"},{"":"","full_text":"SWAP 0.0G","name":"memory","instance":"swap","separator":false,"separator_block_width":15,"markup":"none"},{"":"","full_text":"HOME 158G","short_text":"158G","name":"disk","separator_block_width":15,"markup":"none"},{"":"","full_text":"172.26.1.168","short_text":"172.26.1.168","color":"#00FF00","name":"iface","separator":false,"separator_block_width":15,"markup":"none"},{"":"","full_text":"2018-12-07 11:22:21","name":"time","separator_block_width":15,"markup":"none"}]'
2018-12-07 11:22:21 - [swaybar/i3bar.c:199] Received i3bar json: '[{"full_text":""},{"":"","full_text":"MEM 25.4G","name":"memory","separator":false,"separator_block_width":15,"markup":"none"},{"":"","full_text":"SWAP 0.0G","name":"memory","instance":"swap","separator":false,"separator_block_width":15,"markup":"none"},{"":"","full_text":"HOME 158G","short_text":"158G","name":"disk","separator_block_width":15,"markup":"none"},{"":"","full_text":"172.26.1.168","short_text":"172.26.1.168","color":"#00FF00","name":"iface","separator":false,"separator_block_width":15,"markup":"none"},{"":"","full_text":"2018-12-07 11:22:21","name":"time","separator_block_width":15,"markup":"none"}]'
2018-12-07 11:22:21 - [swaybar/i3bar.c:199] Received i3bar json: '[{"full_text":""},{"":"","full_text":"♪ 0%","name":"volume","instance":"Master","separator_block_width":15,"markup":"none"},{"":"","full_text":"MEM 25.4G","name":"memory","separator":false,"separator_block_width":15,"markup":"none"},{"":"","full_text":"SWAP 0.0G","name":"memory","instance":"swap","separator":false,"separator_block_width":15,"markup":"none"},{"":"","full_text":"HOME 158G","short_text":"158G","name":"disk","separator_block_width":15,"markup":"none"},{"":"","full_text":"172.26.1.168","short_text":"172.26.1.168","color":"#00FF00","name":"iface","separator":false,"separator_block_width":15,"markup":"none"},{"":"","full_text":"2018-12-07 11:22:21","name":"time","separator_block_width":15,"markup":"none"}]'
2018-12-07 11:22:21 - [swaybar/i3bar.c:253] Rendering last received json
2018-12-07 11:22:21 - [swaybar/tray/watcher_kde.c:74] Registering Status Notifier Item ':1.37312/org/ayatana/NotificationItem/blueman'
2018-12-07 11:22:21 - [swaybar/tray/watcher_kde.c:96] Registering Status Notifier Host 'org.kde.StatusNotifierHost-21135'
2018-12-07 11:22:21 - [swaybar/tray/host_kde.c:20] Registering Status Notifier Item ':1.37312/org/ayatana/NotificationItem/blueman'
2018-12-07 11:22:21 - [swaybar/tray/item_kde.c:24] TODO remove - IconName: blueman-tray
2018-12-07 11:22:21 - [common/background-image.c:32] Failed to load background image (Couldn’t recognize the image file format for file “/usr/share/icons/hicolor/16x16/status/blueman-tray.png”).
2018-12-07 11:22:22 - [swaybar/i3bar.c:199] Received i3bar json: '[{"full_text":""},{"":"","full_text":"♪ 0%","name":"volume","instance":"Master","separator_block_width":15,"markup":"none"},{"":"","full_text":"MEM 25.4G","name":"memory","separator":false,"separator_block_width":15,"markup":"none"},{"":"","full_text":"SWAP 0.0G","name":"memory","instance":"swap","separator":false,"separator_block_width":15,"markup":"none"},{"":"","full_text":"HOME 158G","short_text":"158G","name":"disk","separator_block_width":15,"markup":"none"},{"":"","full_text":"172.26.1.168","short_text":"172.26.1.168","color":"#00FF00","name":"iface","separator":false,"separator_block_width":15,"markup":"none"},{"":"","full_text":"CPU 12.80%","short_text":"12.80%","min_width":"CPU: 100.00%","name":"cpu_usage","separator_block_width":15,"markup":"none"},{"":"","full_text":"2018-12-07 11:22:21","name":"time","separator_block_width":15,"markup":"none"}]'
2018-12-07 11:22:22 - [swaybar/i3bar.c:253] Rendering last received json
[2]    21135 segmentation fault (core dumped)  XDG_DATA_DIRS='' build/swaybar/swaybar --bar_id bar-0 --debug
139 arti@orav ~/code/sway_tray (git)-[tray] %

If I set HAVE_GDK_PIXBUF to false in meson.build so that it falls back to cairo and rebuild then it loads the icon.
tray icon

This is the icon that GDK_PIXBUF fails to load
blueman-tray

/usr/share/icons/hicolor/16x16/status/blueman-tray.png: PNG image data, 16 x 16, 16-bit/color RGBA, non-interlaced
sha256sum 594792bf6ad8961f204e40d8a41dadbf1fa143b2f343976084d0a30e98113880

@ianyfan
Copy link
Contributor Author

ianyfan commented Dec 7, 2018

@artizirk If it still crashes with the latest changes, could you provide a backtrace? Thanks.

@artizirk
Copy link

artizirk commented Dec 7, 2018

@ianyfan It works now without crashes or local hacks. Awesome!

@cedws
Copy link
Contributor

cedws commented Dec 12, 2018

Just a quick reminder to remove

### Where are my tray icons?

Swaybar does not currently support tray icons.

from here upon merge.

@ianyfan
Copy link
Contributor Author

ianyfan commented Dec 31, 2018

Welp.

I'm happy with the commits as they are, I just rebased it onto the latest master.

@ddevault ddevault merged commit 3d7c20f into swaywm:master Dec 31, 2018
@ddevault
Copy link
Member

Thanks!

@ghost
Copy link

ghost commented Jan 1, 2019

Is there a reason for not enabling tray by default?

@electrickite
Copy link

Posting this here because there seems to be discussion in this thread about specific apps' tray support.

I tried the new system tray with both Dropbox and nm-applet. Dropbox worked pretty well, although the context menu appeared in the middle of the screen rather than near the tray icon.

nm-applet did not work as well. It was built ad run with Appindicator support. The icon did appear in the tray, but did not respond to any type of click; no menus appeared. Even stranger, when nm-applet was showing in the tray, no other tray icons could be clicked either. Once the nm-applet process was killed, the other icons began responding to clicks again.

@ianyfan
Copy link
Contributor Author

ianyfan commented Jan 17, 2019

@electrickite Is this still an issue?

@electrickite
Copy link

@ianyfan Yes it still seems to happen on the latest build.

@ianyfan
Copy link
Contributor Author

ianyfan commented Jan 28, 2019

I believe I had the dropbox issue when I was testing this, so I'm not sure if there's anything I can do about it.

As for nm-applet, the menu doesn't show up because it hasn't been implemented yet. However, I'm still able to click on other tray icons, so I can't seem to replicate your problem. Maybe there's a clue in the (swaybar) debug logs?

@ianyfan
Copy link
Contributor Author

ianyfan commented Feb 3, 2019

Can you list the python packages required in a virtual environment to get this script to run? Thanks.

@ianyfan
Copy link
Contributor Author

ianyfan commented Feb 5, 2019

Could you attach the debug logs for when you try to register steam's icon?

@ianyfan
Copy link
Contributor Author

ianyfan commented Feb 6, 2019

That's strange. Can you get any icons working?

@onny
Copy link

onny commented Feb 25, 2019

@ianyfan: I'm also not able to click on nm-applet --indicator nor blueman-applet. Is there any working example?

@ianyfan
Copy link
Contributor Author

ianyfan commented Feb 26, 2019

I think they use the dbus menu, which has not been implemented yet.

@progandy
Copy link
Contributor

@onny: Can you try with Waybar? It should include support for dbusmenu, but it depends on libdbusmenu which probably isn't an option for swaybar.

By the way, QT5 with QSystemTrayIcon creates a dbus menu as well. (example).

@ianyfan
Copy link
Contributor Author

ianyfan commented Feb 26, 2019

@progandy the current blocker is implementing layer shell popups

@varac
Copy link

varac commented Feb 26, 2019

I think they use the dbus menu, which has not been implemented yet.

Is there any issue that tracks this ?

@ywalterh
Copy link

@progandy with Waybar nm-applet --indicator responds to right click, the context menu shows up center of the screen.

@ianyfan ianyfan mentioned this pull request Feb 27, 2019
@ianyfan
Copy link
Contributor Author

ianyfan commented Feb 28, 2019

Missing features are now being tracked in #3799

@fdutheil
Copy link

fdutheil commented Mar 13, 2019

Hi,
As lots of people using i3, I'm testing sway 1.0 (quite successfully) :)
It seems that the tray feature requires elogind or systemd (on Gentoo), or am I wrong? Is this on purpose?
If the answer is yes, is there a plan for an alternative not requiring systemd?

@progandy
Copy link
Contributor

progandy commented Mar 13, 2019

@fdutheil The tray uses sd-bus as the dbus library. You could try building with basu or libsystemd That would require some patches to the meson configuration for sway.

@ddevault
Copy link
Member

It's blocked on the general lack of availability of a good sd-bus alternative, which I would love to see but don't have time to write.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

Backport swaybar tray support KDE's SNI implementation is noncompliant