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

systray: add :visible-empty property for systray widget #1097

Draft
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

vnva
Copy link
Contributor

@vnva vnva commented May 5, 2024

Description

Issue

Added the :visible-empty property for the systray widget. By default, an empty tray is displayed.

I also noticed a problem that tray elements are not removed from systray.items.

Usage

(systray :visible-empty false)

Showcase

2024-05-05.22-14-11.mp4

Additional Notes

This is my first time writing in rust, so I might have made mistakes, please check carefully to see. I'm ready to correct mistakes.

As far as I understand, the documentation for widgets is generated automatically.

Checklist

Please make sure you can check all the boxes that apply to this PR.

  • All widgets I've added are correctly documented.
  • I added my changes to CHANGELOG.md, if appropriate.
  • The documentation in the docs/content/main directory has been adjusted to reflect my changes.
  • I used cargo fmt to automatically format all code before committing

@vnva vnva changed the title systray: add property systray: add :visible-empty property May 5, 2024
@vnva vnva changed the title systray: add :visible-empty property systray: add :visible-empty property for systray widget May 5, 2024
@vnva
Copy link
Contributor Author

vnva commented May 5, 2024

Most likely this is not the best solution, I think it’s worth passing a condition on the number of elements in the tray in :visible, you don’t have to merge this PR. But it’s certainly worth fixing removing elements from the tray. This also conflicts with the :visible property.

@vnva vnva marked this pull request as draft May 5, 2024 18:24
@vnva
Copy link
Contributor Author

vnva commented May 5, 2024

@jlo62, i wrote a stupid script to count the number of elements in the tray, you can use it together with deflisten and :visible

#!/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}")

@vnva
Copy link
Contributor Author

vnva commented May 5, 2024

@elkowar, perhaps this method should be added to the docs or add a magic variable with the number of elements in the systray. Perhaps it’s generally worth disabling the widget’s display by default if there are no elements in it.

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

Successfully merging this pull request may close these issues.

None yet

1 participant