;;; jao-dirmon.el --- little utility to monitor disk usage -*- lexical-binding: t; -*- ;; Copyright (C) 2022 jao ;; Author: jao ;; Keywords: tools ;; This program is free software; you can redistribute it and/or modify ;; it under the terms of the GNU General Public License as published by ;; the Free Software Foundation, either version 3 of the License, or ;; (at your option) any later version. ;; This program is distributed in the hope that it will be useful, ;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ;; GNU General Public License for more details. ;; You should have received a copy of the GNU General Public License ;; along with this program. If not, see . ;;; Commentary: ;; What directories suddenly increased their size? ;;; Code: (require 'multisession) (require 'jao-shell) (define-multisession-variable jao-dirmon-last '()) (defun jao-dirmon-dirs () (jao-shell-cmd-lines "find ~ -mindepth 2 -maxdepth 3 -type d")) (defun jao-dirmon-sizes () (mapcar (lambda (f) (let ((x (split-string (jao-shell-string "du -s" f)))) (cons (cadr x) (string-to-number (car x))))) (jao-dirmon-dirs))) (defvar jao-dirmon-threshold 100000) (defvar jao-dirmon-last-delta nil) ;;;###autoload (defun jao-dirmon-report () (interactive) (let ((old (multisession-value jao-dirmon-last)) (current (jao-dirmon-sizes)) (high ())) (dolist (c current) (let ((d (- (cdr c) (alist-get (car c) old 0 nil #'string=)))) (when (> d jao-dirmon-threshold) (push c high)))) (setq jao-dirmon-last-delta high) (let ((prompt (format"High deltas: %s. Save state?" high))) (when (y-or-n-p prompt) (setf (multisession-value jao-dirmon-last) current))) jao-dirmon-last-delta)) (provide 'jao-dirmon) ;;; jao-dirmon.el ends here