Skip to content

kchanqvq/insecure-lock

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

31 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

insecure-lock - Screen locker in pure Emacs Lisp

MELPA

insecure-lock is an extensible screen lock framework. It is implemented within Emacs itself rather than interfacing with underlying window system, so it is best used together with EXWM as a screen locker. Otherwise, it can be used as a screen saver.

As its name suggest, currently security is not a strength of this package. It’s more of an advice rather than defense against your intruders. Nevertheless, any suggestions about improving security are more than welcomed!

Gallery

(setq 'insecure-lock-mode-hook '(insecure-lock-redact insecure-lock-posframe)) /screenshot1.png

(setq insecure-lock-mode-hook '(vampire-time-screensaver insecure-lock-blank-screen)) (vampire-time-screensaver is a function for my personal use, haven’t been published yet. Curious people may check my .emacs.d.) /screenshot2.png

(setq insecure-lock-mode-hook '(insecure-lock-blank-screen insecure-lock-posframe)), with some tweaks to insecure-lock-blank-screen-face and insecure-lock-posframe-parameters /screenshot3.png

Configuration

Add the following lines to your init.el

(require 'insecure-lock)
(insecure-lock-run-idle 300) ;; Lock screen after 300 seconds
(require 'posframe)
(setq 'insecure-lock-mode-hook '(insecure-lock-blank-screen insecure-lock-posframe)) ;; Enable date time display

Note that currently insecure-lock is not very robust against errors from modules. To avoid hanging your Emacs session because of misconfiguration, it’s strongly advised to try your new configurations in a separate Emacs instance before using it in your main Emacs session!

Variables for customization

insecure-lock-require-password

If set, intercept input events and require login password to unlock. Otherwise unlock with any key stroke, acting more like a screen saver.

insecure-lock-mode-hook

You can turn on screen lock “modules” by adding functions to this variable. The default value is (insecure-lock-blank-screen).

The order of modules matters! For example, usually you want to put insecure-lock-posframe after the rest so that the posframe doesn’t get blanked/redacted.

Available “modules” (in fact just plain functions):

insecure-lock-blank-screen
Display a blank buffer without modeline in place of any displaying buffers/windows.
insecure-lock-redact
Available only if the redacted package is loaded. Turn on redact-mode and disable mode line on any displaying buffer.
insecure-lock-posframe
Available only if the posframe package is loaded. Display a posframe to show some status. This can be customized by:
insecure-lock-posframe-parameters
Parameters to the posframe.
insecure-lock-posframe-update-function
Function to populate the posframe. The default one, insecure-lock-posframe-default-update-function, shows current time and date in two lines, padded and centered. It’s a good starting point for writing your own snippet!

Writing a module

A primary goal for insecure-lock is to be composable and extensible. It should be quite easy to get hands on extending insecure-lock. Start Writing your module for your own amusement! And contribute to spread the joy!

An example insecure-lock module

A minimal example of a insecure-lock module:

(defvar blackout--saved-background-color nil)
(defun blackout ()
  (if insecure-lock-mode
      (progn
        (setq blackout--saved-background-color (face-background 'default))
        (set-background-color "black"))
    (set-background-color blackout--saved-background-color))

You can enable it via (add-hook 'insecure-lock-mode-hook 'blackout). This sets Emacs background color to black when screen is locked, and recover the original background color when unlocked.

In general, a module look like:

(defun my-module ()
  (if insecure-lock-mode
      '(code to setup when entering screen lock)
    '(code to clean up when leaving screen lock))

Useful Variables

insecure-lock-update-functions
Add periodic update functions for your module to this variable! The insecure-lock-update-timer will call functions in this list every insecure-lock-update-timer-interval seconds (default to 1).
(defun my-module-update ()
  '(code to update display))
(defun my-module ()
  (if insecure-lock-mode
      (progn
        (add-hook 'insecure-lock-update-functions 'my-module-update)
        '(code to setup when entering screen lock))
    '(code to clean up when leaving screen lock))
    

There’s no need to bother removing the update functions when cleanup. insecure-lock-update-functions will be set to nil at the beginning of screen lock setup.

About

Screen locker in pure Emacs Lisp

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published