Skip to content

Commit 18ba13a

Browse files
lucorandydotxyz
authored andcommitted
ensure ID is not empty on linux
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
1 parent 88df1e0 commit 18ba13a

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

systray_unix.go

+6-2
Original file line numberDiff line numberDiff line change
@@ -298,7 +298,11 @@ type tray struct {
298298

299299
func (t *tray) createPropSpec() map[string]map[string]*prop.Prop {
300300
t.lock.Lock()
301-
t.lock.Unlock()
301+
defer t.lock.Unlock()
302+
id := t.title
303+
if id == "" {
304+
id = fmt.Sprintf("systray_%d", os.Getpid())
305+
}
302306
return map[string]map[string]*prop.Prop{
303307
"org.kde.StatusNotifierItem": {
304308
"Status": {
@@ -314,7 +318,7 @@ func (t *tray) createPropSpec() map[string]map[string]*prop.Prop {
314318
Callback: nil,
315319
},
316320
"Id": {
317-
Value: t.title,
321+
Value: id,
318322
Writable: false,
319323
Emit: prop.EmitTrue,
320324
Callback: nil,

0 commit comments

Comments
 (0)