|
|
|
@ -0,0 +1,44 @@
|
|
|
|
|
:PROPERTIES:
|
|
|
|
|
:ID: 20230212T100136.539310
|
|
|
|
|
:ROAM_ALIASES: systemd-inhibit-mode
|
|
|
|
|
:END:
|
|
|
|
|
#+TITLE: Keep Screen Awake with Systemd-Inhibit-Mode
|
|
|
|
|
|
|
|
|
|
#+ARROYO_EMACS_MODULE: systemd-inhibit
|
|
|
|
|
|
|
|
|
|
#+ARCOLOGY_KEY: cce/systemd-inhibit-mode
|
|
|
|
|
#+ARCOLOGY_ALLOW_CRAWL: t
|
|
|
|
|
|
|
|
|
|
When I watch a full-screen [[id:94841773-88a0-4c41-9af8-fbf0d0a133d0][Video]] in Firefox while using [[id:20220421T100313.402598][XMonad]], it doesn't properly disable DPMS so my screen blanks every five minutes in to the video. Rather than try to figure out why that was, I would invoke =systemd-inhibit= to inhibit screen blanking. This was fine, but I'd run it in a terminal emulator which I would promptly forget about. Cue my laptop having a dead battery or my monitor burning in the lock-screen text overnight when I would manually lock the desktop and head to bed.
|
|
|
|
|
|
|
|
|
|
I whipped this [[id:cce/emacs][Emacs]] global minor mode up so that I would have a =modeline= entry and a simple toggle. Enabling =systemd-inhibit-mode= will, by default prevent any of the "idle" actions from happening. No screen blanking, no lock screen, no sleep, just video. If you want to use it like =Caffeine= to prevent sleep while your code compiles or something you can customize =systemd-inhibit-what=.
|
|
|
|
|
|
|
|
|
|
#+begin_src emacs-lisp :tangle ~/org/cce/systemd-inhibit.el :results none
|
|
|
|
|
(defcustom systemd-inhibit-what (list "idle")
|
|
|
|
|
"Type of operation to inhibit with systemd-inhibit"
|
|
|
|
|
:type '(repeat string)
|
|
|
|
|
:options '("shutdown" "sleep" "idle"
|
|
|
|
|
"handle-power-key" "handle-suspend-key"
|
|
|
|
|
"handle-hibernate-key" "handle-lid-switch"))
|
|
|
|
|
|
|
|
|
|
(defvar systemd-inhibit-mode-process nil)
|
|
|
|
|
|
|
|
|
|
(define-minor-mode systemd-inhibit-mode
|
|
|
|
|
"When active, SystemD will not lock or blank the screen depending on configuration."
|
|
|
|
|
:global t
|
|
|
|
|
:init-value nil
|
|
|
|
|
:lighter "[INHIBIT]"
|
|
|
|
|
(if systemd-inhibit-mode
|
|
|
|
|
(setq systemd-inhibit-mode-process
|
|
|
|
|
(start-process "systemd-inhibit" " *systemd-inhibit*"
|
|
|
|
|
"systemd-inhibit"
|
|
|
|
|
"--mode=block"
|
|
|
|
|
"--why=emacs-systemd-inhibit-mode"
|
|
|
|
|
(concat "--what=" (s-join ":" systemd-inhibit-what))
|
|
|
|
|
"watch" "-n" "45" "date"))
|
|
|
|
|
(progn
|
|
|
|
|
(kill-process systemd-inhibit-mode-process)
|
|
|
|
|
(setq systemd-inhibit-mode-process nil))))
|
|
|
|
|
|
|
|
|
|
(provide 'cce/systemd-inhibit)
|
|
|
|
|
#+end_src
|