refactor: move items from (radix utils memory) to more general module (radix system monitoring)
parent
7b0fcc8543
commit
b34de78f5e
16
modules/radix/utils/memory.scm → modules/radix/system/monitoring.scm
Executable file → Normal file
16
modules/radix/utils/memory.scm → modules/radix/system/monitoring.scm
Executable file → Normal file
|
@ -1,10 +1,13 @@
|
||||||
(define-module (radix utils memory)
|
(define-module (radix utils monitoring)
|
||||||
#:use-module (srfi srfi-26)
|
#:use-module (srfi srfi-26)
|
||||||
#:use-module (ice-9 rdelim)
|
#:use-module (ice-9 rdelim)
|
||||||
#:export (current-memory-info
|
#:export (current-memory-info
|
||||||
current-ram-usage
|
current-ram-usage
|
||||||
current-swap-usage))
|
current-swap-usage
|
||||||
|
|
||||||
|
current-battery-capacity))
|
||||||
|
|
||||||
|
#|memory usage monitoring utilities|#
|
||||||
(define (current-memory-info)
|
(define (current-memory-info)
|
||||||
(let* ((port (open "/proc/meminfo" O_RDONLY))
|
(let* ((port (open "/proc/meminfo" O_RDONLY))
|
||||||
(lines (let loop ((line (read-line port))
|
(lines (let loop ((line (read-line port))
|
||||||
|
@ -33,3 +36,12 @@
|
||||||
(define (current-swap-usage)
|
(define (current-swap-usage)
|
||||||
(apply - (map (cut assoc-ref (current-memory-info) <>)
|
(apply - (map (cut assoc-ref (current-memory-info) <>)
|
||||||
'("SwapTotal" "SwapFree"))))
|
'("SwapTotal" "SwapFree"))))
|
||||||
|
|
||||||
|
#|battery usage monitoring utilities|#
|
||||||
|
(define (current-battery-capacity)
|
||||||
|
(let* ((port (open "/sys/class/power_supply/BAT0/capacity"
|
||||||
|
O_RDONLY))
|
||||||
|
(battery-level (read port)))
|
||||||
|
(close-input-port port)
|
||||||
|
battery-level))
|
||||||
|
|
Loading…
Reference in New Issue