@@ -95,12 +95,13 @@ function findWidgets(panelLayout, panelWidgets) {
95
95
// other situations
96
96
if ( ! child . applet ?. plasmoid ?. pluginName ) continue
97
97
// Utils.dumpProps(child.applet.plasmoid)
98
+ const id = child . applet . plasmoid . id
98
99
const name = child . applet . plasmoid . pluginName
99
100
const title = child . applet . plasmoid . title
100
101
const icon = child . applet . plasmoid . icon
101
- if ( panelWidgets . find ( ( item ) => item . name === name ) ) continue
102
+ if ( panelWidgets . find ( ( item ) => item . id === id ) ) continue
102
103
// console.error(name, title, icon)
103
- panelWidgets . push ( { "name" : name , "title" : title , "icon" : icon , "inTray" : false } )
104
+ panelWidgets . push ( { "id" : id , " name" : name , "title" : title , "icon" : icon , "inTray" : false } )
104
105
}
105
106
return panelWidgets
106
107
}
@@ -114,25 +115,28 @@ function findWidgetsTray(grid, panelWidgets) {
114
115
const model = item . children [ j ] . model
115
116
// App tray icons
116
117
if ( model . itemType === "StatusNotifier" ) {
117
- // dumpProps(model)
118
+ // in contrast with applet?.plasmoid.id, Id is not actually given by plasma,
119
+ // but since there should be only a single instance of StatusNotifier per app,
120
+ // model.Id _should_ be enough for any sane implementation of tray icon
118
121
const name = model . Id
119
122
const title = model . ToolTipTitle !== "" ? model . ToolTipTitle : model . Title
120
123
const icon = model . IconName
121
124
if ( panelWidgets . find ( ( item ) => item . name === name ) ) continue
122
125
// console.error(name, title, icon)
123
- panelWidgets . push ( { "name" : name , "title" : title , "icon" : icon , "inTray" : true } )
126
+ panelWidgets . push ( { "id" : - 1 , " name" : name , "title" : title , "icon" : icon , "inTray" : true } )
124
127
}
128
+ // normal plasmoids in tray
125
129
if ( model . itemType === "Plasmoid" ) {
126
130
const applet = model . applet ?? null
131
+ const id = applet ?. plasmoid . id ?? - 1
127
132
const name = applet ?. plasmoid . pluginName ?? ""
128
133
const title = applet ?. plasmoid . title ?? ""
129
134
const icon = applet ?. plasmoid . icon ?? ""
130
- if ( panelWidgets . find ( ( item ) => item . name === name ) ) continue
135
+ if ( panelWidgets . find ( ( item ) => item . id === id ) ) continue
131
136
// console.error(name, title, icon)
132
- panelWidgets . push ( { "name" : name , "title" : title , "icon" : icon , "inTray" : true } )
137
+ panelWidgets . push ( { "id" : id , " name" : name , "title" : title , "icon" : icon , "inTray" : true } )
133
138
}
134
139
}
135
- // panelWidgets.add(item)
136
140
}
137
141
}
138
142
// find the expand tray arrow
@@ -143,17 +147,19 @@ function findWidgetsTray(grid, panelWidgets) {
143
147
const name = "org.kde.plasma.systemtray.expand"
144
148
if ( panelWidgets . find ( ( item ) => item . name === name ) ) continue
145
149
const title = item . subText || "Show hidden icons"
146
- panelWidgets . push ( { "name" : name , "title" : title , "icon" : "arrow-down" , "inTray" : true } )
150
+ panelWidgets . push ( { "id" : - 1 , " name" : name , "title" : title , "icon" : "arrow-down" , "inTray" : true } )
147
151
}
148
152
}
149
153
}
150
154
return panelWidgets
151
155
}
152
156
153
- function getWidgetName ( item ) {
157
+ function getWidgetNameAndId ( item ) {
154
158
let name = null
159
+ let id = - 1
155
160
if ( item . applet ?. plasmoid ?. pluginName ) {
156
161
name = item . applet . plasmoid . pluginName
162
+ id = item . applet . plasmoid . id
157
163
} else {
158
164
for ( let i in item . children ) {
159
165
if ( ! ( item . children [ i ] . model ) ) continue
@@ -163,13 +169,14 @@ function getWidgetName(item) {
163
169
} else if ( model . itemType === "Plasmoid" ) {
164
170
const applet = model . applet ?? null
165
171
name = applet ?. plasmoid . pluginName ?? null
172
+ name = applet ?. plasmoid . id ?? - 1
166
173
}
167
174
}
168
175
}
169
176
// if (name) {
170
177
// console.error("@@@@ getWidgetName ->", name)
171
178
// }
172
- return name
179
+ return { name, id }
173
180
}
174
181
175
182
var themeColors = [
@@ -205,11 +212,19 @@ var themeScopes = [
205
212
"Header"
206
213
]
207
214
208
- function getCustomCfg ( widgetName , configurationOverrides ) {
209
- if ( ! widgetName ) return null
215
+ function getWidgetAsocIdx ( id , name , config ) {
216
+ console . log ( "getWidgetAsocIdx()" )
217
+ return config . findIndex ( ( item ) => item . id == id && item . name == name )
218
+ }
219
+
220
+ function getCustomCfg ( widgetName , widgetId , configurationOverrides ) {
221
+ if ( ! widgetId ) return null
210
222
var custom = { }
211
- if ( widgetName in configurationOverrides . associations ) {
212
- const overrideNames = configurationOverrides . associations [ widgetName ]
223
+ configurationOverrides . associations = clearOldWidgetConfig ( configurationOverrides . associations )
224
+ let asocIndex = getWidgetAsocIdx ( widgetId , widgetName , configurationOverrides . associations )
225
+ if ( asocIndex !== - 1 ) {
226
+
227
+ const overrideNames = configurationOverrides . associations [ asocIndex ] . presets
213
228
214
229
for ( let overrideName of overrideNames ) {
215
230
if ( ! ( overrideName in configurationOverrides . overrides ) ) continue
@@ -251,10 +266,10 @@ function getEffectiveSettings(customSettings, globalSettings) {
251
266
return effectiveSettings
252
267
}
253
268
254
- function getItemCfg ( itemType , widgetName , config , configurationOverrides ) {
269
+ function getItemCfg ( itemType , widgetName , widgetId , config , configurationOverrides ) {
255
270
let output = { override : false }
256
- let custom = getCustomCfg ( widgetName , configurationOverrides )
257
- let presetOverrides = getCustomCfg ( widgetName , config . configurationOverrides )
271
+ let custom = getCustomCfg ( widgetName , widgetId , configurationOverrides )
272
+ let presetOverrides = getCustomCfg ( widgetName , widgetId , config . configurationOverrides )
258
273
if ( presetOverrides ) {
259
274
if ( custom && custom . disabledFallback ) {
260
275
custom = getEffectiveSettings ( custom , presetOverrides )
@@ -460,3 +475,19 @@ for (var id of panelIds) {
460
475
function evaluateScript ( script ) {
461
476
runCommand . run ( "gdbus call --session --dest org.kde.plasmashell --object-path /PlasmaShell --method org.kde.PlasmaShell.evaluateScript '" + script + "'" )
462
477
}
478
+
479
+ function getForceFgWidgetConfig ( id , name , config ) {
480
+ return config . find ( ( item ) => item . id == id && item . name == name )
481
+ }
482
+
483
+ function clearOldWidgetConfig ( config ) {
484
+ if ( Array . isArray ( config ) ) {
485
+ return config
486
+ }
487
+ else return [ ]
488
+ }
489
+
490
+ function getWidgetConfigIdx ( id , name , config ) {
491
+ // console.log("getWidgetConfigIdx()")
492
+ return config . findIndex ( ( item ) => item . id == id && item . name == name )
493
+ }
0 commit comments