从 KDE Plasma 5 锁屏暂停 linux

lun*_*ndi 11 kde arch-linux screen-lock plasma5

TLDR:如何从 KDE LockScreen 挂起?

我正在使用 KDE 的默认锁屏,您可以对其进行一些配置 kde锁屏配置 但是我还没有找到从锁屏挂起我的电脑的方法,所以我必须输入我的密码,然后在每次需要它时挂起,这非常不方便。

目前我修改了 KDE 等离子锁屏文件(特别是 LockScreenUi.qml)以添加暂停按钮。但也许这是一种更简单的方法来做到这一点?

同样是的,我在 kde 论坛上看到了reddit 帖子和一些帖子,但没有任何解决方案。

我的配置:

uname -a
Linux neko 4.15.14-1-ARCH #1 SMP PREEMPT Wed Mar 28 17:34:29 UTC 2018 x86_64 GNU/Linux

kded5 --version
kded5 5.45.0

plasmashell --version
plasmashell 5.12.5
Run Code Online (Sandbox Code Playgroud)

补丁本身,它基本上添加了带有默认图标的Suspend按钮并使用PowerDevil KDE服务暂停(找到这个使用注销文件)

使用风险自负:

--- /usr/share/plasma/look-and-feel/org.kde.breeze.desktop/contents/lockscreen/LockScreenUi.qml 2018-05-01 16:03:40.000000000 +0300
+++ backups/kde-plasma-lockscreen/LockScreenUi.qml  2018-05-05 19:56:59.764353585 +0300
@@ -31,6 +31,18 @@

     colorGroup: PlasmaCore.Theme.ComplementaryColorGroup

+    function performOperation(what) {
+        var service = dataEngine.serviceForSource("PowerDevil");
+        var operation = service.operationDescription(what);
+        service.startOperationCall(operation);
+    }
+
+    PlasmaCore.DataSource {
+      id: dataEngine
+      engine: "powermanagement"
+      connectedSources: ["PowerDevil"]
+    }
+
     Connections {
         target: authenticator
         onFailed: {
@@ -174,6 +186,11 @@
                         onClicked: mainStack.push(switchSessionPage)
                         // the current session isn't listed in the model, hence a check for greater than zero, not one
                         visible: (sessionsModel.count > 0 || sessionsModel.canStartNewSession) && sessionsModel.canSwitchUser
+                    },
+                    ActionButton {
+                      text: i18nd("plasma_lookandfeel_org.kde.lookandfeel", "Suspend")
+                      iconSource: "system-suspend"
+                      onClicked: performOperation("suspendToRam")
                     }
                 ]
Run Code Online (Sandbox Code Playgroud)

编辑1:

KDE bugtracker上已经有该功能的报告(感谢Lekensteyn提供链接)

Ana*_*sch 5

感谢您的补丁,它就像一个魅力!

同样处理物理电源键:

      Keys.onPressed: {
+            if (event.key == 16777399) performOperation("suspendToRam")
Run Code Online (Sandbox Code Playgroud)

确认在kded5 5.67.0plasmashell 5.17.5(Gentoo) 上工作。

2020-06 更新:kde-plasma/plasma-workspace-5.18.5 的更新补丁

--- /usr/share/plasma/look-and-feel/org.kde.breeze.desktop/contents/lockscreen/LockScreenUi.qml.orig    2020-06-25 00:50:49.181771074 +0300
+++ /usr/share/plasma/look-and-feel/org.kde.breeze.desktop/contents/lockscreen/LockScreenUi.qml 2020-06-25 00:56:23.750323655 +0300
@@ -38,6 +38,18 @@
 
     colorGroup: PlasmaCore.Theme.ComplementaryColorGroup
 
+    function performOperation(what) {
+        var service = dataEngine.serviceForSource("PowerDevil");
+        var operation = service.operationDescription(what);
+        service.startOperationCall(operation);
+    }
+
+    PlasmaCore.DataSource {
+      id: dataEngine
+      engine: "powermanagement"
+      connectedSources: ["PowerDevil"]
+    }
+
     Connections {
         target: authenticator
         onFailed: {
@@ -125,6 +137,8 @@
             }
         }
         Keys.onPressed: {
+            if (event.key == 16908292) performOperation("suspendToRam")
+            if (event.key == 16777399) performOperation("suspendToRam")
             uiVisible = true;
             event.accepted = false;
         }
@@ -279,6 +293,11 @@
                         anchors{
                             verticalCenter: parent.top
                         }
+                    },
+                    ActionButton {
+                        text: i18nd("plasma_lookandfeel_org.kde.lookandfeel", "Suspend")
+                        iconSource: "system-suspend"
+                        onClicked: performOperation("suspendToRam")
                     }
                 ]
 
Run Code Online (Sandbox Code Playgroud)


小智 0

非常感谢!效果很好。

我的笔记本电脑也有一个睡眠键,所以我又添加了一行:

      Keys.onPressed: {
+            if (event.key == 16908292) performOperation("suspendToRam")
            uiVisible = true;
            event.accepted = false;
Run Code Online (Sandbox Code Playgroud)