mirror of
https://github.com/stumpwm/stumpwm-contrib.git
synced 2026-09-10 07:26:25 -04:00
Disk plugin: Use library instead of external process on GNU/Linux (#160)
This commit is contained in:
parent
0eeeca2d22
commit
3a9629ce55
|
|
@ -6,14 +6,16 @@ This module prints some information about your disks on the modeline.
|
|||
|
||||
Put:
|
||||
#+BEGIN_SRC common-lisp
|
||||
(ql:quickload "cl-diskspace")
|
||||
(ql:quickload "cl-diskspace")
|
||||
;; on GNU/linux only
|
||||
(ql:quickload "cl-mount-info")
|
||||
#+END_SRC
|
||||
|
||||
** Usage
|
||||
|
||||
Put:
|
||||
#+BEGIN_SRC
|
||||
(load-module "disk")
|
||||
#+BEGIN_SRC common-lisp
|
||||
(load-module "disk")
|
||||
#+END_SRC
|
||||
|
||||
into your ~~/.stumpwmrc~
|
||||
|
|
@ -38,9 +40,10 @@ modeline.
|
|||
| %a | Filesystem available space |
|
||||
| %p | Filesystem used space in percent |
|
||||
| %m | Filesystem mount point |
|
||||
| %f | Filesystem type |
|
||||
|------+----------------------------------|
|
||||
|
||||
** Known issues
|
||||
|
||||
This module will fallback on an external shell process method to get
|
||||
informations if either ~%m~ or ~%d~ is used.
|
||||
This module will fallback on an external shell process on non
|
||||
GNU/Linux platform
|
||||
|
|
|
|||
|
|
@ -1,11 +1,12 @@
|
|||
;;;; disk.asd
|
||||
|
||||
(asdf:defsystem #:disk
|
||||
(asdf:defsystem "disk"
|
||||
:serial t
|
||||
:description "Display filesystem information in the modeline"
|
||||
:author "Morgan Veyret"
|
||||
:license "GPLv3"
|
||||
:depends-on (:stumpwm
|
||||
:cl-diskspace)
|
||||
:cl-diskspace
|
||||
(:feature :linux "cl-mount-info"))
|
||||
:components ((:file "package")
|
||||
(:file "disk")))
|
||||
|
|
|
|||
|
|
@ -37,7 +37,8 @@
|
|||
(#\u disk-get-used)
|
||||
(#\a disk-get-available)
|
||||
(#\p disk-get-use-percent)
|
||||
(#\m disk-get-mount-point)))
|
||||
(#\m disk-get-mount-point)
|
||||
(#\f disk-get-filesystem-type)))
|
||||
|
||||
(defparameter *disk-modeline-fmt* "%m: %u/%s"
|
||||
"The default value for displaying disk usage information on the modeline.
|
||||
|
|
@ -57,6 +58,8 @@ Filesystem available space
|
|||
Filesystem used space in percent
|
||||
@item %m
|
||||
Filesystem mount point
|
||||
@item %f
|
||||
Filesystem type
|
||||
@end table
|
||||
")
|
||||
|
||||
|
|
@ -110,21 +113,23 @@ Filesystem mount point
|
|||
|
||||
(format nil "~a%" value)))
|
||||
|
||||
;;; whe should use fallback mode (i.e. shell + df) for this two :(
|
||||
;;; any idea how to improve this?
|
||||
|
||||
(defun disk-get-device (path)
|
||||
(disk-usage-get-field path 0))
|
||||
#+linux (cl-mount-info:mountpoint->device path)
|
||||
#-linux (disk-usage-get-field path 0))
|
||||
|
||||
(defun disk-get-mount-point (path)
|
||||
(disk-usage-get-field path 5))
|
||||
path)
|
||||
|
||||
(defun disk-get-filesystem-type (path)
|
||||
#+linux (cl-mount-info:mountpoint->fstype path)
|
||||
#-linux "filesystem type supported only on GNU/Linux :-(")
|
||||
|
||||
(defun use-fallback-method-p ()
|
||||
(or (search "%m" *disk-modeline-fmt* :test #'string=)
|
||||
(search "%d" *disk-modeline-fmt* :test #'string=)))
|
||||
(search "%d" *disk-modeline-fmt* :test #'string=))
|
||||
|
||||
(defun disk-modeline (ml)
|
||||
(declare (ignore ml))
|
||||
#-linux
|
||||
(when (use-fallback-method-p)
|
||||
(disk-update-usage *disk-usage-paths*))
|
||||
(let ((fmts (loop for p in *disk-usage-paths* collect
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
;;;; package.lisp
|
||||
|
||||
(defpackage :disk
|
||||
(:use :cl
|
||||
:stumpwm)
|
||||
(defpackage #:disk
|
||||
(:use #:cl
|
||||
#:stumpwm)
|
||||
(:export
|
||||
:*disk-modeline-fmt*
|
||||
:*disk-usage-paths*))
|
||||
#:*disk-modeline-fmt*
|
||||
#:*disk-usage-paths*))
|
||||
|
|
|
|||
Loading…
Reference in a new issue