elkowar / eww

ElKowars wacky widgets
https://elkowar.github.io/eww
MIT License
8.78k stars 366 forks source link

[FEATURE] Add systray class when it is empty #1093

Open jlo62 opened 2 months ago

jlo62 commented 2 months ago

Description of the requested feature

This would allow to completely hide the systray (via css) if it is empty.

I have not been able to do this otherwise, also not via reveal.

Proposed configuration syntax

.systray_empty {padding: 0}

Additional context

No response

vnva commented 2 months ago

I think that instead of the class it is worth adding the visible-empty property, I wanted to do this but could not install the dependencies с:

error: could not compile `winnow` (lib) due to 3149 previous errors
vnva commented 2 months ago

I implemented it in this PR

vnva commented 2 months ago
#!/bin/bash

count=0

dbus-monitor --session "interface='org.kde.StatusNotifierWatcher'" |
while read -r signal; do
    if [[ $signal == *"StatusNotifierItemRegistered"* ]]; then
      count=$(($count + 1))
    elif [[ $signal == *"StatusNotifierItemUnregistered"* ]] then
      count=$(($count - 1))
    fi

    echo $count
done
(deflisten systray-items-count :initial 0 "path-to-script")
(systray :visible "${systray-items-count > 0}")