Update waybar sleep stuff
This commit is contained in:
@ -49,13 +49,33 @@ from which to calculate."
|
||||
(list (subseq line 0 index)
|
||||
(subseq line (1+ index)))))
|
||||
|
||||
(defun systemd-unescape (str &key (start 0) (end (length str)))
|
||||
"Act as sytemd-escape --unescape (for non-path strings) for STR."
|
||||
(with-output-to-string (stream)
|
||||
(let ((copy-start start))
|
||||
(flet ((copy-to-output (i skip)
|
||||
(when (<= copy-start end)
|
||||
(write-string str stream :start copy-start :end i)
|
||||
(setq copy-start (+ i skip)))))
|
||||
(loop for i upfrom start below end
|
||||
for c = (aref str i)
|
||||
when (and (eql c #\\) (>= (- end i) 4)
|
||||
(eql (aref str (1+ i)) #\x))
|
||||
do (copy-to-output i 4)
|
||||
and do (write-char (code-char (parse-integer str
|
||||
:start (+ i 2)
|
||||
:end (+ i 4)
|
||||
:radix 16))
|
||||
stream))
|
||||
(copy-to-output end 0)))))
|
||||
|
||||
(defun extract-lock-length-string-from-service-name (name)
|
||||
"Extract the lock length string from a service name NAME of the form
|
||||
\"NAME@TIME.service\"."
|
||||
(let ((start-idx (1+ (position #\@ name)))
|
||||
(end-idx (when (uiop:string-suffix-p name ".service")
|
||||
(- (length name) (length ".service")))))
|
||||
(subseq name start-idx end-idx)))
|
||||
(systemd-unescape name :start start-idx :end end-idx)))
|
||||
|
||||
(defparameter *lock-length-string-units*
|
||||
`((#\d . ,(* 24 60 60 1000 1000))
|
||||
|
||||
Reference in New Issue
Block a user