mirror of
https://invent.kde.org/marcoa/shift-shell.git
synced 2026-08-04 10:44:46 +00:00
Add a shutdown button in the top drawer
it uses the PowerDevil data engine to request a shutdown from ksmserver. Since ksmserver is not yet running on the images this also prints a debug message. Tested to work on desktop neon.
This commit is contained in:
parent
7310f8282a
commit
3194b36952
2 changed files with 24 additions and 0 deletions
|
|
@ -9,6 +9,10 @@
|
||||||
<entry name="AppletOrder" type="String">
|
<entry name="AppletOrder" type="String">
|
||||||
<label>encoded order of items</label>
|
<label>encoded order of items</label>
|
||||||
</entry>
|
</entry>
|
||||||
|
<entry name="ShowPowerButton" type="Bool">
|
||||||
|
<default>true</default>
|
||||||
|
<label>optional power button</label>
|
||||||
|
</entry>
|
||||||
</group>
|
</group>
|
||||||
|
|
||||||
</kcfg>
|
</kcfg>
|
||||||
|
|
|
||||||
|
|
@ -33,6 +33,14 @@ Item {
|
||||||
plasmoid.nativeInterface.toggleTorch()
|
plasmoid.nativeInterface.toggleTorch()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function requestShutdown() {
|
||||||
|
print("Shutdown requested, depends on ksmserver running");
|
||||||
|
var service = pmSource.serviceForSource("PowerDevil");
|
||||||
|
//note the strange camelCasing is intentional
|
||||||
|
var operation = service.operationDescription("requestShutDown");
|
||||||
|
return service.startOperationCall(operation);
|
||||||
|
}
|
||||||
|
|
||||||
function addPlasmoid(applet) {
|
function addPlasmoid(applet) {
|
||||||
settingsModel.append({"icon": applet.icon,
|
settingsModel.append({"icon": applet.icon,
|
||||||
"text": applet.title,
|
"text": applet.title,
|
||||||
|
|
@ -107,6 +115,18 @@ Item {
|
||||||
"settingsCommand": "",
|
"settingsCommand": "",
|
||||||
"applet": null
|
"applet": null
|
||||||
});
|
});
|
||||||
|
if (plasmoid.configuration.ShowPowerButton) {
|
||||||
|
settingsModel.append({
|
||||||
|
"text": i18n("Shutdown"),
|
||||||
|
"icon": "system-shutdown-symbolic",
|
||||||
|
"enabled": false,
|
||||||
|
"settingsCommand": "",
|
||||||
|
"toggleFunction": "requestShutdown",
|
||||||
|
"plasmoidId": -1,
|
||||||
|
"applet": null
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
brightnessSlider.valueChanged.connect(function() {
|
brightnessSlider.valueChanged.connect(function() {
|
||||||
root.screenBrightness = brightnessSlider.value;
|
root.screenBrightness = brightnessSlider.value;
|
||||||
});
|
});
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue