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))
|
||||
|
||||
Reference in New Issue
Block a user