Package: plasma-workspace
Version: 5.21.5-3
Severity: wishlist
Tags: patch

The attached patch creates additional session definitions for X and
Wayland that launch Plasma in a locked state.  Using them with
auto-login makes for a great combination.  I had been looking for
something like this for years.

The patch applies against 5.21.5-3, but I have only tested it with
5.20.5-6.

Locked auto-login under X works nicely and it's what I'll be using.
Locked auto-login under Wayland works, too, but is a rather rocky
experience IMO.  I also recommend using throwaway user accounts for
testing (to not mess up your saved session) and running top/htop on a
separate VT during the familiarization phase and keeping an eye on CPU
usage.  Notable observations from my testing:

* kwin_wayland pegs the CPU to ~385% until you unlock the session
  (with DRM backend on nouveau).  I guess disabling some effects could
  reduce that, but I haven't looked into that.

* Consequently mouse movement is choppy, and you have to put the
  pointer directly over the password field for it to retain focus.

* The window dimensions of the kscreenlocker_greet window change once
  Plasma launches the Task Manager leaving a black bar at the position
  where the Task Manager would be.

* Also upon logout sometimes stray processes (korgac,
  kactivitymanager, kded5) stay around which consume ~200 % CPU till
  killed.  I can't reliably reproduce this yet, though, so it might be
  nothing.

Regards,
Dennis Filder
--- a/debian/rules
+++ b/debian/rules
@@ -11,6 +11,18 @@ include /usr/share/pkg-kde-tools/qt-kde-team/2/library-packages.mk
 override_dh_auto_configure:
 	dh_auto_configure -Skf5 -- -DBUILD_TESTING=OFF
 
+override_dh_auto_install:
+	dh_auto_install --buildsystem=kf5 -i -O--buildsystem=kf5
+	rm -f debian/tmp/usr/share/xsessions/plasmalocked.desktop debian/tmp/usr/share/wayland-sessions/plasmawaylandlocked.desktop
+	cp -a debian/tmp/usr/share/xsessions/plasma.desktop debian/tmp/usr/share/xsessions/plasmalocked.desktop
+	cp -a debian/tmp/usr/share/wayland-sessions/plasmawayland.desktop debian/tmp/usr/share/wayland-sessions/plasmawaylandlocked.desktop
+	sed -f debian/genlockedplasma.sed -i debian/tmp/usr/share/xsessions/plasmalocked.desktop
+	sed -f debian/genlockedplasma.sed -i debian/tmp/usr/share/wayland-sessions/plasmawaylandlocked.desktop
+# Test if the above actually took effect and error out if it didn't
+	grep -q -e DESKTOP_LOCKED=true debian/tmp/usr/share/xsessions/plasmalocked.desktop
+	grep -q -e --lockscreen debian/tmp/usr/share/wayland-sessions/plasmawaylandlocked.desktop
+	grep -q -e '^Name=.*(Wayland)$$' debian/tmp/usr/share/wayland-sessions/plasmawaylandlocked.desktop
+
 override_dh_auto_test:
 	# Disable auto tests at build time
 	:
--- a/debian/plasma-workspace.install
+++ b/debian/plasma-workspace.install
@@ -66,3 +66,4 @@ usr/share/kservicetypes5/
 usr/share/metainfo/
 usr/share/solid/actions/test-predicate-openinwindow.desktop
 usr/share/xsessions/plasma.desktop
+usr/share/xsessions/plasmalocked.desktop
--- a/debian/plasma-workspace-wayland.install
+++ b/debian/plasma-workspace-wayland.install
@@ -1,3 +1,4 @@
 usr/bin/startplasma-wayland
 usr/lib/*/libexec/startplasma-waylandsession
 usr/share/wayland-sessions/plasmawayland.desktop
+usr/share/wayland-sessions/plasmawaylandlocked.desktop
--- /dev/null
+++ b/debian/genlockedplasma.sed
@@ -0,0 +1,26 @@
+# -*- mode: conf; -*-
+
+# https://github.com/sddm/sddm/issues/306 has some discussion
+
+s@^Exec=\(/usr/.*/startplasma-x11.*\)$@Exec=/usr/bin/env DESKTOP_LOCKED=true \1@
+# The Plasma devs in their infinite wisdom made startplasma-wayland
+# ignore DESKTOP_LOCKED.  Also because their approach to command line
+# defaults is a bit unorthodox, we have to specify the command line
+# in full like so carefully preserving arch-specific paths.
+s@^Exec=/usr/\(.*/libexec\)/\(plasma-dbus-run-session-if-needed /usr/bin/startplasma-wayland.*\)$@Exec=/usr/\1/\2 --lockscreen --xwayland --exit-with-session /usr/\1/startplasma-waylandsession@
+
+# sddm in src/common/Session.cpp:Session::setTo() foolishly expects
+# the string "(Wayland)" at the very end of Name= (instead of e.g.
+# inspecting Type=), so we must preserve it until they fix the code.
+#
+# Consider using U+1F510 CLOSED LOCK WITH KEY (🔐) or U+1F512 LOCK
+# (🔒) once Qt supports it.
+#s@^Name=\(Plasma\)\(.*\)$@Name=\1 🔐\2@
+#s@^Name=\(Plasma\)\(.*\)$@Name=Locked \1\2@
+#s@^Name=\(Plasma\)\(.*\)$@Name=\1 „-o\2@
+#s@^Name=\(Plasma\)\(.*\)$@Name=\1 o––⃩\2@
+#s@^Name=\(Plasma\)\(.*\)$@Name=\1 o¬\2@
+#s@^Name=\(Plasma\)\(.*\)$@Name=\1 ◯—▄\2@
+s@^Name=\(Plasma\)\(.*\)$@Name=\1 [locked]\2@
+
+s@^Comment=\(.*\)$@Comment=\1 (locked)@

Reply via email to