diff --git a/v3/UNRELEASED_CHANGELOG.md b/v3/UNRELEASED_CHANGELOG.md index 33638e7fc86..d9af53063f5 100644 --- a/v3/UNRELEASED_CHANGELOG.md +++ b/v3/UNRELEASED_CHANGELOG.md @@ -23,6 +23,7 @@ After processing, the content will be moved to the main changelog and this file ## Fixed +- Fix `SystemTray.SetTooltip()` doing nothing on Linux: the StatusNotifierItem tooltip description is now set (#6017) ## Deprecated diff --git a/v3/pkg/application/systemtray_linux.go b/v3/pkg/application/systemtray_linux.go index fc8307ee88f..7ef806636d9 100644 --- a/v3/pkg/application/systemtray_linux.go +++ b/v3/pkg/application/systemtray_linux.go @@ -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) { @@ -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 } @@ -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() {