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."
|
||||
(if (zerop seconds)
|
||||
"0s"
|
||||
(let* ((hours (floor (/ (abs seconds) 60 60)))
|
||||
(mins (floor (/ (- (abs seconds) (* hours 60 60)) 60)))
|
||||
(secs (- (abs seconds) (* mins 60) (* hours 60 60))))
|
||||
(format nil "~@[~*-~]~[~:;~:*~Sh~]~[~:;~:*~Sm~]~[~:;~:*~Ss~]"
|
||||
(minusp seconds) hours mins secs))))
|
||||
(let* ((days (floor (/ (abs seconds) 24 60 60)))
|
||||
(hours (floor (/ (- (abs seconds) (* days 24 60 60)) 60 60)))
|
||||
(mins (floor (/ (- (abs seconds)
|
||||
(* hours 60 60)
|
||||
(* 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)
|
||||
"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)
|
||||
(unless num
|
||||
(error "Invalid time interval!"))
|
||||
(incf i chars)
|
||||
(setq i chars)
|
||||
(let ((scale (assoc (if (< i (length str))
|
||||
(aref str i)
|
||||
#\s)
|
||||
@ -148,7 +154,8 @@ show command."
|
||||
"Return a list of running locks."
|
||||
(with-input-from-string
|
||||
(stream (uiop:run-program '("systemctl" "--user" "--no-pager" "--full"
|
||||
"show" "manual-inhibit-sleep@*.service")
|
||||
"--state=activating,active" "show"
|
||||
"manual-inhibit-sleep@*.service")
|
||||
:output :string
|
||||
:error-output :interactive
|
||||
:input nil))
|
||||
|
||||
@ -43,6 +43,8 @@
|
||||
maximize (length (cdr lock)) into second-col-len
|
||||
finally
|
||||
(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 (make-string (+ first-col-len 2 second-col-len) ?-) "\n")
|
||||
(dolist (lock locks)
|
||||
|
||||
@ -4,7 +4,7 @@ zmodload zsh/datetime
|
||||
zmodload zsh/mathfunc
|
||||
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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user