从 KDE Plasma 5 锁屏中暂停 Linux

从 KDE Plasma 5 锁屏中暂停 Linux

TLDR:如何从 KDE LockScreen 挂起?

我使用的是 KDE 的默认锁屏,你可以对其进行一些配置Kde 锁屏配置 但我还没有找到一种方法可以从锁屏状态下暂停我的电脑,所以我必须输入密码,然后每次需要时都暂停,这非常不方便。

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

也是的,我见过红迪网帖子以及 kde 论坛上的一些帖子,没有任何解决方案。

我的配置:

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

补丁本身,它基本上添加了带有默认图标的挂起按钮,并使用 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")
                     }
                 ]

编辑1:

已经有关于该功能的报告KDE 错误追踪器(谢谢莱肯斯坦对于链接)

答案1

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

与处理物理电源键相同:

      Keys.onPressed: {
+            if (event.key == 16777399) performOperation("suspendToRam")

确认可以在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")
                     }
                 ]
 

答案2

非常感谢!效果很好。

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

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

相关内容