Fix some more sleep lock stuff
This commit is contained in:
@ -37,11 +37,17 @@ from which to calculate."
|
|||||||
"Return a string representing SECONDS in a human readable way."
|
"Return a string representing SECONDS in a human readable way."
|
||||||
(if (zerop seconds)
|
(if (zerop seconds)
|
||||||
"0s"
|
"0s"
|
||||||
(let* ((hours (floor (/ (abs seconds) 60 60)))
|
(let* ((days (floor (/ (abs seconds) 24 60 60)))
|
||||||
(mins (floor (/ (- (abs seconds) (* hours 60 60)) 60)))
|
(hours (floor (/ (- (abs seconds) (* days 24 60 60)) 60 60)))
|
||||||
(secs (- (abs seconds) (* mins 60) (* hours 60 60))))
|
(mins (floor (/ (- (abs seconds)
|
||||||
(format nil "~@[~*-~]~[~:;~:*~Sh~]~[~:;~:*~Sm~]~[~:;~:*~Ss~]"
|
(* hours 60 60)
|
||||||
(minusp seconds) hours mins secs))))
|
(* days 24 60 60))
|
||||||
|
60)))
|
||||||
|
(secs (- (abs seconds) (* mins 60)
|
||||||
|
(* hours 60 60) (* days 24 60 60))))
|
||||||
|
(format nil
|
||||||
|
"~@[~*-~]~[~:;~:*~Sd~]~[~:;~:*~Sh~]~[~:;~:*~Sm~]~[~:;~:*~Ss~]"
|
||||||
|
(minusp seconds) days hours mins secs))))
|
||||||
|
|
||||||
(defun split-key-value-line (line)
|
(defun split-key-value-line (line)
|
||||||
"Split LINE, in the form of key=vale, into a list of (key value)."
|
"Split LINE, in the form of key=vale, into a list of (key value)."
|
||||||
@ -96,7 +102,7 @@ string means infinite length."
|
|||||||
(parse-integer str :start i :junk-allowed t)
|
(parse-integer str :start i :junk-allowed t)
|
||||||
(unless num
|
(unless num
|
||||||
(error "Invalid time interval!"))
|
(error "Invalid time interval!"))
|
||||||
(incf i chars)
|
(setq i chars)
|
||||||
(let ((scale (assoc (if (< i (length str))
|
(let ((scale (assoc (if (< i (length str))
|
||||||
(aref str i)
|
(aref str i)
|
||||||
#\s)
|
#\s)
|
||||||
@ -148,7 +154,8 @@ show command."
|
|||||||
"Return a list of running locks."
|
"Return a list of running locks."
|
||||||
(with-input-from-string
|
(with-input-from-string
|
||||||
(stream (uiop:run-program '("systemctl" "--user" "--no-pager" "--full"
|
(stream (uiop:run-program '("systemctl" "--user" "--no-pager" "--full"
|
||||||
"show" "manual-inhibit-sleep@*.service")
|
"--state=activating,active" "show"
|
||||||
|
"manual-inhibit-sleep@*.service")
|
||||||
:output :string
|
:output :string
|
||||||
:error-output :interactive
|
:error-output :interactive
|
||||||
:input nil))
|
:input nil))
|
||||||
|
|||||||
@ -43,6 +43,8 @@
|
|||||||
maximize (length (cdr lock)) into second-col-len
|
maximize (length (cdr lock)) into second-col-len
|
||||||
finally
|
finally
|
||||||
(progn
|
(progn
|
||||||
|
(setq first-col-len (max first-col-len (length "Length"))
|
||||||
|
second-col-len (max second-col-len (length "Until")))
|
||||||
(insert (string-pad "Length" first-col-len) " Until\n")
|
(insert (string-pad "Length" first-col-len) " Until\n")
|
||||||
(insert (make-string (+ first-col-len 2 second-col-len) ?-) "\n")
|
(insert (make-string (+ first-col-len 2 second-col-len) ?-) "\n")
|
||||||
(dolist (lock locks)
|
(dolist (lock locks)
|
||||||
|
|||||||
@ -4,7 +4,7 @@ zmodload zsh/datetime
|
|||||||
zmodload zsh/mathfunc
|
zmodload zsh/mathfunc
|
||||||
setopt typeset_silent
|
setopt typeset_silent
|
||||||
|
|
||||||
local TIMES=(1m 5m 10m 15m 30m 1h 2h 4h 1d forever)
|
local TIMES=(forever 1m 5m 10m 15m 30m 1h 2h 4h 1d)
|
||||||
|
|
||||||
local -a running_locks
|
local -a running_locks
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user