Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for custom containments / system tray #126

Closed
gkaklas opened this issue Apr 13, 2024 · 4 comments · Fixed by #164
Closed

Support for custom containments / system tray #126

gkaklas opened this issue Apr 13, 2024 · 4 comments · Fixed by #164

Comments

@gkaklas
Copy link
Contributor

gkaklas commented Apr 13, 2024

Hello, thank you for your work!

I think it would be a nice feature to be able to configure the system tray the same way it is now possible with the rest of the panel applets. I looked at the module's code but I didn't find a way to do this, so of course you can close this if it's already possible 😅

In order to achieve this, it seems like there would just need to be support for containments of any type, which will probably also allow configuring desktop widgets or maybe even other things.

Unfortunately I'm new to nix so I didn't manage to understand how to change the code to make a PR 😅 But here are some thoughts on what I was looking for to maybe change, in case they help 🤔

  • Maybe the panel module could be renamed/extended/aliased to/from containment
  • Allow it to have plugin={org.kde.panel/org.kde.plasma.private.systemtray/org.kde.plasma.folder}
  • Specifically for the system tray, we would need to have access to the containments' ids while generating the configuration, as it is needed for SystrayContainmentId

Here is a minimal example of a system tray configuration to demonstrate the schema for this use case (if I have understood it correctly):

# Panel
[Containments][1]
plugin=org.kde.panel

## Panel widget #1
[Containments][1][Applets][1]
plugin=org.kde.plasma.icontasks

## Panel widget #2
[Containments][1][Applets][2]
plugin=org.kde.plasma.systemtray

[Containments][1][Applets][2][Configuration]
SystrayContainmentId=2

# System tray
[Containments][2]
plugin=org.kde.plasma.private.systemtray

## Tray icon #1
[Containments][2][Applets][1]
plugin=org.kde.plasma.devicenotifier

## Tray icon #2
[Containments][2][Applets][2]
plugin=org.kde.plasma.volume

[Containments][2][Applets][2][Shortcuts]
global=Meta+A
@NotChristianGarcia
Copy link

NotChristianGarcia commented Apr 14, 2024

Here's an example of a config which modifies system tray that I found and use.

Notable the panel.nix file above calls a JS script in extraSettings which allows modification of the tray. So give that a try for now and see if that helps!

I'm non-knowledgeable. However, I believe this containment schema in appletsrc is a thorn in the foot. There was a user that mentioned hard-coded values maybe working, however, they don't consistently work for me when modifying monitors regularly. Whereas other config files are static and make sense, this one is a bit of a development hell with constant changing and containment number skew causing missing elements.

@lgoette
Copy link

lgoette commented Apr 29, 2024

That js script works great. Thank you :D
But I still hope that this feature will be included in plasma-manager. :)

@pluiedev
Copy link
Contributor

pluiedev commented May 1, 2024

After experimenting with this a bit, I find that this approach is significantly easier:

for (const wid of panel.widgets(["org.kde.plasma.systemtray"])) {
  const tray = desktopById(wid.readConfig("SystrayContainmentId"));
  if (!tray) continue; // if somehow the containment doesn't exist
  
  tray.writeConfig("hiddenItems", [
    "org.kde.plasma.brightness",
    "org.kde.plasma.clipboard",
  ]);
  
  const battery = tray.addWidget("org.kde.plasma.battery");
  battery.writeConfig("showPercentage", true);
}

Also found out how to customize specific sub-widgets: you literally just create them manually and configure them the normal way, which is good news, since we can reuse the same widget config logic as we'd used for normal widgets.

@lgoette
Copy link

lgoette commented May 2, 2024

Thats way cleaner. Neat :D

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants