Add clamshell plugin#821
Conversation
This comment was marked as resolved.
This comment was marked as resolved.
spiros132
left a comment
There was a problem hiding this comment.
Some feedback about the PR! :D
| @@ -0,0 +1,33 @@ | |||
| { | |||
| "id": "clamshell", | |||
There was a problem hiding this comment.
Since this is specifically for niri, I would suggest renaming the plugin to niri-clamshell to make it more clear.
| "ipc": { | ||
| "target": "plugin:clamshell", | ||
| "functions": ["enable", "disable", "toggle", "status", "refresh"] | ||
| } |
There was a problem hiding this comment.
This ipc field in the manifest doesn't do anything.
| ``` | ||
|
|
||
| Register and enable the plugin in Noctalia, then add the bar widget or control | ||
| center widget from Noctalia settings. |
There was a problem hiding this comment.
The installation part isn't correct since the user can just press install on the plugin.
|
|
||
| property bool editEnabled: cfg.enabled !== undefined | ||
| ? cfg.enabled | ||
| : (defaults.enabled !== undefined ? defaults.enabled : true) |
There was a problem hiding this comment.
Prefer to use the following syntax instead of this:
property bool foo: cfg?.foo ?? defaults?.foo ?? true| : (defaults.alwaysShowBarWidget !== undefined ? defaults.alwaysShowBarWidget : false) | ||
| property bool editNotify: cfg.notify !== undefined | ||
| ? cfg.notify | ||
| : (defaults.notify !== undefined ? defaults.notify : true) |
There was a problem hiding this comment.
Prefer to use that syntax on all of these as well.
| ?? "^(eDP|LVDS|DSI)" | ||
| readonly property bool notifyEnabled: cfg.notify !== undefined | ||
| ? cfg.notify | ||
| : (defaults.notify !== undefined ? defaults.notify : true) |
There was a problem hiding this comment.
As before, use the other syntax for this property.
| // because widgets and IPC mutate this property directly. | ||
| property bool enabled: (cfg.enabled !== undefined) | ||
| ? cfg.enabled | ||
| : (defaults.enabled !== undefined ? defaults.enabled : true) |
There was a problem hiding this comment.
As before the same thing here. Also I would suggest making this property readonly and when you need to change it, change it through the pluginApi.pluginSettings.enabled which will update the property automatically.
| function applySettings() { | ||
| root.enabled = (cfg.enabled !== undefined) | ||
| ? cfg.enabled | ||
| : (defaults.enabled !== undefined ? defaults.enabled : true); |
There was a problem hiding this comment.
As before this isn't needed if you use the reactive properties of qml instead of manually setting enabled every time.
| Logger.w(root.logTag, "niri msg outputs exited with code", exitCode); | ||
| } | ||
| } | ||
| } |
There was a problem hiding this comment.
Do you need this Process specifically? Quickshell already provides a way to know which monitors exists with the Quickshell.screens.
| // (niri generates WorkspacesChanged etc. when monitor topology changes). | ||
| // The debounce timer coalesces rapid bursts into a single fetch. | ||
| outputsDebounce.restart(); | ||
| } |
There was a problem hiding this comment.
Another thing as well, I believe that noctalia has a built-in way to get the outputs in the NiriService. That way you don't need to have more boilerplate code that does the exact same thing as noctalia.
|
Thanks for feedback. Its my first PR to such big project) So I fix this issues as soon as possible |
Summary
Adds
clamshell, a Noctalia plugin for automatic laptop clamshell mode on niri.When an external display is connected and the plugin is enabled, it starts a single
systemd-inhibitprocess to blockhandle-lid-switch. This lets niriturn off the internal display on lid close without the system suspending. When no external display is present, or the user disables the plugin, the
inhibitor is stopped and normal lid behavior returns.
Features
niri msg --json event-streamniri msg --json outputswithout pollingplugin:clamshell/etc/systemd/logind.confIPC
qs -c noctalia-shell ipc call plugin:clamshell status qs -c noctalia-shell ipc call plugin:clamshell toggle qs -c noctalia-shell ipc call plugin:clamshell enable qs -c noctalia-shell ipc call plugin:clamshell disable qs -c noctalia-shell ipc call plugin:clamshell refreshTesting
Tested locally on:
Verified:
Notes
The plugin intentionally uses systemd-inhibit --mode=block and does not change logind configuration. Users should keep normal lid behavior in logind.conf, typically HandleLidSwitch=suspend.