Skip to content

Ignore Tray items by service name and when dbus properties load#4826

Open
AntGarSil wants to merge 1 commit intoAlexays:masterfrom
AntGarSil:agd/ignore-tray-applets
Open

Ignore Tray items by service name and when dbus properties load#4826
AntGarSil wants to merge 1 commit intoAlexays:masterfrom
AntGarSil:agd/ignore-tray-applets

Conversation

@AntGarSil
Copy link

@AntGarSil AntGarSil commented Feb 8, 2026

Description

Implements configuration-based filtering of system tray (StatusNotifierItem) icons in Waybar. Users can now specify patterns to hide unwanted tray items via the ignore-list configuration option.

Problem Statement

Some applications (e.g., blueman, network managers) show system tray icons that cannot be disabled through the application's own settings. Users need a way to filter these unwanted icons at the Waybar level.

Solution

Added ignore-list functionality that filters SNI items based on pattern matching against service names, object paths, and item properties.

Changes

src/modules/sni/host.cpp

New Methods:

  • checkIgnoreList() - Filters and removes items matching ignore patterns
    • Iterates through all registered items
    • Matches patterns against: bus_name, category, icon_name, id, title
    • Calls on_remove callback and erases matched items
    • Comprehensive debug/info logging

Modified Methods:

  • Host::Host() constructor - Added ignore_list parameter
  • itemRegistered() - Added logging for item registration events
  • addRegisteredItem() - Enhanced debug logging

Constructor Signature Change:

Host::Host(const std::size_t id, const Json::Value& config, const Bar& bar,
           const std::vector<std::string>& ignore_list,  // NEW
           const std::function<void(std::unique_ptr<Item>&)>& on_add,
           const std::function<void(std::unique_ptr<Item>&)>& on_remove)

src/modules/sni/tray.cpp

New Methods:

  • parseIgnoreList() - Static helper to parse JSON config array

    • Validates array type
    • Extracts string patterns
    • Logging for configuration transparency
  • checkIgnoreList() - Public wrapper delegating to Host's method

New Member Variables:

  • std::vector<std::string> ignore_list_ - Stores ignore patterns

Modified Methods:

  • Tray::Tray() constructor - Initializes ignore_list_ from config
  • onAdd() - Calls deferred ignore check after adding item, enhanced logging
  • update() - Periodic ignore list check to catch late-loading properties

Configuration Usage

{
  "tray": {
    "ignore-list": ["blueman", "nm-applet", "spotify"]
  }
}

Patterns are matched using substring search (std::string::find()) against multiple item fields.

Technical Details

  • Pattern Matching: Substring-based (not regex or wildcards)
  • Scope: Module-level (per tray instance)

Logging Added

  • Config parsing: Shows ignore-list items being loaded
  • Item registration: Logs all registered items with properties
  • Filtering: Info-level logs when items are ignored with matched pattern

Known Problems

⚠️ Asynchronous Property Loading Issue:

The current implementation has a timing problem:

  • SNI items load D-Bus properties asynchronously
  • When onAdd() is called, properties (category, icon_name, title) are empty strings
  • Pattern matching against empty strings fails
  • Items briefly flash in the UI before properties load

Example from logs:

[info] Tray::onAdd - item bus_name=':1.628', category='', icon_name='', title=''

The code now checks patterns against the service parameter (e.g., :1.628/org/blueman/sni) in addRegisteredItem() before Item construction, as this value is immediately available.

Testing

  • ✅ Config parsing validated with multiple patterns
  • ✅ Logging confirms items are detected
  • ✅ Arch
  • ⚠️ Pattern matching fails due to empty properties (timing issue). Workaround implemented.
  • ⏳ Needs full fix for async property loading

Breaking Changes

None - added functionality is opt-in via configuration.

Related Issues

#2842

@AntGarSil AntGarSil changed the title Ignore Tray entries by service name and when dbus properties load Ignore Tray items by service name and when dbus properties load Feb 8, 2026
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.

1 participant