Bug 442092 - allow infinite time before password is required to unlock after auto-locking
Summary: allow infinite time before password is required to unlock after auto-locking
Status: RESOLVED FIXED
Alias: None
Product: kscreenlocker
Classification: Plasma
Component: general (show other bugs)
Version: unspecified
Platform: unspecified Linux
: NOR wishlist
Target Milestone: ---
Assignee: Plasma Bugs List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2021-09-06 19:48 UTC by tempel.julian
Modified: 2024-05-22 20:26 UTC (History)
3 users (show)

See Also:
Latest Commit:
Version Fixed In: 6.1


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description tempel.julian 2021-09-06 19:48:18 UTC
Currently, three minutes is the maximum value a user can set. However, this is still annoying when kscreenlocker is mostly used as a screensaver, as chances are you don't want to always enter your password after three minutes.

Perhaps not using a password for a user can be a workaround in some scenarios, but there are quite some reasons why an option to turn off auto-locking would be the better choice:

-Users shouldn't be encouraged not to use passwords.
-Users want to be able to deliberately lock the screen e.g. via hotkey, but don't necessarily want auto-locking.
-I assume allowing (close to) infinite values for LockGrace config setting in kscreenlockerrc should be easy to implement.
-So kscreenlocker should be able to easily act as a screensaver, without really bending its purpose and not making things harder for developers in the future.
-screensaver situation is dire on Linux, especially on Wayland. kscreenlocker already has all the DPMS and inactivity detection functionality implemented that is required by a screensaver, so a separate screensaver program inside KDE/Plasma would cause redundancy (and doesn't seem likely to happen).
-On Windows, screensaver and screen locker are basically the same thing. Windows screensaver offers an option to lock the screen after the screensaver is stopped by activity. Which in return means you can also have a screensaver without automatic screen locking by not having the locking checkbox ticked.
Comment 1 Bug Janitor Service 2023-11-21 17:11:01 UTC
A possibly relevant merge request was started @ https://invent.kde.org/plasma/kscreenlocker/-/merge_requests/179
Comment 2 Dave Kaye 2023-12-05 17:27:50 UTC
I want to have a screen saving program similar to KDE4 which was lost in an upgrade to KDE5.  That would mean slide show capability with no password required upon return to normal screen activity.  I have been following the discussions on gitlab about kscreenlocker as well as general internet interest on this subject.  I have modified less than 10 lines of code and achieved a reasonable program.  

My system is:
KDE Plasma Version 5.18.5
KDE Frameworks Version 5.71.0
Qt Version 5.12.7
Linux Distribution openSUSE Leap 15.2

Within the kscreenlocker program, I modified 3 files changing only a couple of lines per file:

--   in the file kcm/kcm.ui I changed the lock grace spinbox property specialValueText from "Immediately" to "Forever", and the minimum value from 0 to -1.  This results in the line "Allow unlocking without password for:" spinbox display to change from "Immediately, 1 second, 2 seconds ..." to "Forever, 0 seconds, 1 second, 2 seconds...".  This would make sense to the user, as 0 seconds and immediately are equivalent.  The selection of Forever will give a time value of -1 which is invisible to the user.  No other modifications to the user interface are needed. (I did change the step value to 1 from 10, a matter of personal preference and ease of usage - but not necessary.)

--   in the file kcfg/kscreenlockersettings.kcfg I updated the minimum value from 0 to -1.  This makes it consistent with the ui modification.

--   in the file ksldapp.cpp within the configure subroutine I added one condition to the lock grace setup if statement.  This checked for a lock request and grace time of -1 seconds.  If found, it set the variable m_lockGrace to -1.  The variable m_lockGrace with a value of -1 already exists in the code and causes the system not to require a password when exiting a locked condition.  It appears to be active throughout the code, however on my system I can only test with the XOrg screen control.

The diff file for the changes is as follows:

--- ksldapp.cpp
+++ ksldapp.cpp
@@ -341,7 +341,10 @@
         // timeout stored in minutes
         m_idleId = KIdleTime::instance()->addIdleTimeout(timeout*1000*60);
     }
-    if (KScreenSaverSettings::lock()) {
+    if (KScreenSaverSettings::lock() && (KScreenSaverSettings::lockGrace() == -1)) {
+         // lockGrace is forever, flag grace time to last forever
+         m_lockGrace = -1;
+    } else if (KScreenSaverSettings::lock()) {
         // lockGrace is stored in seconds
         m_lockGrace = KScreenSaverSettings::lockGrace() * 1000;
     } else {
--- kcm/kcm.ui
+++ kcm/kcm.ui
@@ -76,8 +76,11 @@
        <item row="2" column="1">
         <widget class="KPluralHandlingSpinBox" name="kcfg_LockGrace">
          <property name="specialValueText">
-          <string>Immediately</string>
+          <string>Forever</string>
          </property>
+         <property name="minimum">
+          <number>-1</number>
+         </property>
          <property name="maximum">
           <number>300</number>
          </property>
--- kcfg/kscreenlockersettings.kcfg
+++ kcfg/kscreenlockersettings.kcfg
@@ -23,7 +23,7 @@
     </entry>
     <entry key="LockGrace" type="Int">
       <default>5</default>
-      <min>0</min>
+      <min>-1</min>
       <max>300</max>
       <label></label>
       <whatsthis></whatsthis>

The user will setup the screen locker with the slide show or other lock screen appearance and their normal lock screen settings.  In the variable labeled "Allow unlocking without password for:" the user will select "Forever" to setup the system as a no password needed screen saver.  I believe this is easier to do than using a huge grace time value.  It also does not require a special check button or similar constuct to indicate a screen saver verses a screen locker.  The program interface flow appears to be readily understandable.

The program also acts as a password required screen locker, ignoring the grace time settings, if it is activated by the hot key sequence.  This is in existing code.  It will allow a rapid screen lock if such action is needed.

This is a demonstration/idea code only.  I do not have KDE6 and multiple screen types to check the modifications for the newest release and make a MR.  In going from my version of KDE5 to KDE6 it appears that the codes are the same (line numbers slightly different) - only the ui file has been changed to a qml file.  It may be possible to make a quick test KDE6 version and see if it is worth consideration for inclusion in the kscreenlocker program.
Comment 3 Bug Janitor Service 2024-03-16 19:17:11 UTC
A possibly relevant merge request was started @ https://invent.kde.org/plasma/kscreenlocker/-/merge_requests/207
Comment 4 Nate Graham 2024-05-22 20:26:15 UTC
Git commit 247bfb0a45fc68e072d67ee0984bc15a7d9c50ff by Nate Graham, on behalf of Kristen McWilliam.
Committed on 22/05/2024 at 20:26.
Pushed by ngraham into branch 'master'.

feat: enable use as a screensaver

The screen locker is already in essence a screensaver, allowing one to
hide the unlock controls and clock, show various types of wallpaper
slideshows, etc. This is great since screensavers are almost
non-existent these days, and they are still wanted by many people.

The only thing missing really is the ability to use it as a screensaver
_without_ requiring a password to unlock.
FIXED-IN: 6.1

M  +21   -6    kcm/ui/main.qml
M  +19   -8    ksldapp.cpp
M  +9    -0    ksldapp.h
M  +5    -0    settings/kscreenlockersettings.kcfg

https://invent.kde.org/plasma/kscreenlocker/-/commit/247bfb0a45fc68e072d67ee0984bc15a7d9c50ff