Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions v3/UNRELEASED_CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ After processing, the content will be moved to the main changelog and this file

## Fixed
<!-- Bug fixes -->
- Fix `SystemTray.SetTooltip()` doing nothing on Linux: the StatusNotifierItem tooltip description is now set (#6017)

## Deprecated
<!-- Soon-to-be removed features -->
Expand Down
24 changes: 21 additions & 3 deletions v3/pkg/application/systemtray_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -449,8 +449,24 @@ func (s *linuxSystemTray) run() {
s.setMenu(s.menu)
}

func (s *linuxSystemTray) setTooltip(_ string) {
// TBD
func (s *linuxSystemTray) setTooltip(text string) {
s.tooltip = text
s.updateToolTip()
}

// updateToolTip republishes the ToolTip property. Its title is the item's name
// and its description is what SetTooltip was given, which is the line a desktop
// shows under the name on hover. The property is declared with prop.EmitTrue,
// so setting it is what tells the host to re-read it.
func (s *linuxSystemTray) updateToolTip() {
if s.props == nil {
return
}

if err := s.props.Set("org.kde.StatusNotifierItem", "ToolTip",
dbus.MakeVariant(tooltip{V2: s.label, V3: s.tooltip})); err != nil {
globalApplication.error("systray error: failed to set ToolTip prop: %w", err)
}
}

func (s *linuxSystemTray) setIcon(icon []byte) {
Expand Down Expand Up @@ -521,6 +537,9 @@ func (s *linuxSystemTray) setLabel(label string) {
return
}

// The tooltip repeats the name as its title, so it follows the label.
s.updateToolTip()

if s.conn == nil {
return
}
Expand All @@ -532,7 +551,6 @@ func (s *linuxSystemTray) setLabel(label string) {
globalApplication.error("systray error: failed to emit new title signal: %w", err)
return
}

}

func (s *linuxSystemTray) destroy() {
Expand Down
Loading