Skip to content

Commit

Permalink
ensure ID is not empty on linux
Browse files Browse the repository at this point in the history
Some desktop environments like the one provided by Ubuntu 22.04 requires the systray ID to be not empty to be displayed.
This commit ensure the ID is always set trying to use the title and fallback to a default ID based on the pid.

Fixes fyne-io/fyne#3678
  • Loading branch information
lucor authored and andydotxyz committed Nov 5, 2023
1 parent 88df1e0 commit 18ba13a
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions systray_unix.go
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,11 @@ type tray struct {

func (t *tray) createPropSpec() map[string]map[string]*prop.Prop {
t.lock.Lock()
t.lock.Unlock()
defer t.lock.Unlock()
id := t.title
if id == "" {
id = fmt.Sprintf("systray_%d", os.Getpid())
}
return map[string]map[string]*prop.Prop{
"org.kde.StatusNotifierItem": {
"Status": {
Expand All @@ -314,7 +318,7 @@ func (t *tray) createPropSpec() map[string]map[string]*prop.Prop {
Callback: nil,
},
"Id": {
Value: t.title,
Value: id,
Writable: false,
Emit: prop.EmitTrue,
Callback: nil,
Expand Down

0 comments on commit 18ba13a

Please sign in to comment.