@@ -2,9 +2,9 @@
;; Author: Lucien Cartier-Tilet <lucien@phundrak.com>
;; Author: Lucien Cartier-Tilet <lucien@phundrak.com>
;; Maintainer: Lucien Cartier-Tilet <lucien@phundrak.com>
;; Maintainer: Lucien Cartier-Tilet <lucien@phundrak.com>
;; Version: 0.7.7
;; Version: 0.7.2
;; Package-Requires: ((emacs "25.1") (f "0.20") (s "1"))
;; Package-Requires: ((emacs "25.1") (f "0.20") (s "1"))
;; Homepage: https://github .com/P hundrak/eshell-info-banner.el
;; Homepage: https://labs.phundrak .com/p hundrak/eshell-info-banner.el
;; This file is not part of GNU Emacs
;; This file is not part of GNU Emacs
@@ -82,34 +82,9 @@
( " 11.1 " . " macOS Big Sur " )
( " 11.1 " . " macOS Big Sur " )
( " 11.2 " . " macOS Big Sur " )
( " 11.2 " . " macOS Big Sur " )
( " 11.3 " . " macOS Big Sur " )
( " 11.3 " . " macOS Big Sur " )
( " 11.4 " . " macOS Big Sur " )
( " 11.4 " . " macOS Big Sur " ) )
( " 11.5 " . " macOS Big Sur " )
( " 11.6 " . " macOS Big Sur " ) )
" Versions of OSX and macOS and their name. " ) )
" Versions of OSX and macOS and their name. " ) )
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; Macros ;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
( defmacro eshell-info-banner--with-face ( str &rest properties )
" Helper macro for applying face `PROPERTIES' to `STR' . "
` ( propertize , str 'face ( list ,@ properties ) ) )
( defun eshell-info-banner--executable-find ( program &optional remote )
( if ( version< emacs-version " 27.1 " )
( let ( ( default-directory ( if ( and eshell-info-banner-tramp-aware
remote )
default-directory
" ~ " ) ) )
( executable-find program ) )
( executable-find program remote ) ) )
( defun eshell-info-banner--shell-command-to-string ( command )
" Execute shell command COMMAND and return its output as a string.
Ensures the command is ran with LANG=C. "
( shell-command-to-string ( format " LANG=C %s " command ) ) )
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; Custom variables ;
; Custom variables ;
@@ -170,8 +145,7 @@ Ensures the command is ran with LANG=C."
:safe #' stringp
:safe #' stringp
:version " 0.5.0 " )
:version " 0.5.0 " )
( defcustom eshell-info-banner-use-duf
( defcustom eshell-info-banner-use-duf ( if ( executable-find eshell-info-banner-duf-executable )
( if ( eshell-info-banner--executable-find eshell-info-banner-duf-executable )
t
t
nil )
nil )
" If non-nil, use `duf' instead of `df' . "
" If non-nil, use `duf' instead of `df' . "
@@ -205,6 +179,20 @@ Ensures the command is ran with LANG=C."
" Face for `eshell-info-banner' progress bars displaying critical levels. "
" Face for `eshell-info-banner' progress bars displaying critical levels. "
:group 'eshell-info-banner )
:group 'eshell-info-banner )
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; Macros ;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
( defmacro eshell-info-banner--with-face ( str &rest properties )
" Helper macro for applying face `PROPERTIES' to `STR' . "
` ( propertize , str 'face ( list ,@ properties ) ) )
( defun eshell-info-banner--shell-command-to-string ( command )
" Execute shell command COMMAND and return its output as a string.
Ensures the command is ran with LANG=C. "
( shell-command-to-string ( format " LANG=C %s " command ) ) )
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; Internal functions ;
; Internal functions ;
@@ -216,7 +204,7 @@ Ensures the command is ran with LANG=C."
" Get uptime of machine if `uptime' is available.
" Get uptime of machine if `uptime' is available.
If the executable `uptime' is not found, return nil. "
If the executable `uptime' is not found, return nil. "
( when ( eshell-info-banner-- executable-find " uptime " )
( when ( executable-find " uptime " )
( let ( ( uptime-str ( eshell-info-banner--shell-command-to-string " uptime -p " ) ) )
( let ( ( uptime-str ( eshell-info-banner--shell-command-to-string " uptime -p " ) ) )
( if ( not ( seq-some ( lambda ( keyword )
( if ( not ( seq-some ( lambda ( keyword )
( string-match-p keyword uptime-str ) )
( string-match-p keyword uptime-str ) )
@@ -313,18 +301,17 @@ Common function between
otherwise differ solely on the position of the mount point in the
otherwise differ solely on the position of the mount point in the
partition list. Its position is given by the argument
partition list. Its position is given by the argument
MOUNT-POSITION. "
MOUNT-POSITION. "
( let ( ( partitions ( cdr ( split-string ( eshell-info-banner--shell-command-to-string " df -lH " )
( let ( ( partitions ( split-string ( eshell-info-banner--shell-command-to-string " df -lH " )
( regexp-quote " \n " )
( regexp-quote " \n " )
t ) ) ) )
t ) ) )
( cl-remove-if #' null
( seq-filter ( lambda ( partition )
( mapcar ( lambda ( partition )
( let* ( ( partition ( split-string partition " " t ) )
( let* ( ( partition ( split-string partition " " t ) )
( filesystem ( nth 0 partition ) )
( filesystem ( nth 0 partition ) )
( size ( nth 1 partition ) )
( size ( nth 1 partition ) )
( used ( nth 2 partition ) )
( used ( nth 2 partition ) )
( percent ( nth 4 partition ) )
( percent ( nth 4 partition ) )
( mount ( nth mount-position partition ) ) )
( mount ( nth mount-position partition ) ) )
( when ( seq-some ( lambda ( prefix )
( unless ( seq-some ( lambda ( prefix )
( string-prefix-p prefix filesystem t ) )
( string-prefix-p prefix filesystem t ) )
eshell-info-banner-partition-prefixes )
eshell-info-banner-partition-prefixes )
( make-eshell-info-banner--mounted-partitions
( make-eshell-info-banner--mounted-partitions
@@ -335,7 +322,7 @@ MOUNT-POSITION."
:used used
:used used
:percent ( string-to-number
:percent ( string-to-number
( string-trim-left percent ( regexp-quote " % " ) ) ) ) ) ) )
( string-trim-left percent ( regexp-quote " % " ) ) ) ) ) ) )
partitions ) ) ) )
partitions ) ) )
( defun eshell-info-banner--get-mounted-partitions-gnu ( )
( defun eshell-info-banner--get-mounted-partitions-gnu ( )
" Detect mounted partitions on a Linux system.
" Detect mounted partitions on a Linux system.
@@ -562,9 +549,8 @@ The usage of `eshell-info-banner-warning-percentage' and
thought of as the “percentage of discharge” of the computer.
thought of as the “percentage of discharge” of the computer.
Thus, setting the warning at 75% will be translated as showing
Thus, setting the warning at 75% will be translated as showing
the warning face with a battery level of 25% or less. "
the warning face with a battery level of 25% or less. "
( let ( ( battery-level ( when ( file-readable-p " /sys/ " ) ( battery ) ) ) )
( let ( ( battery-level ( battery ) ) )
( if ( or ( null battery-level )
( if ( or ( string= battery-level " Battery status not available " )
( string= battery-level " Battery status not available " )
( string-match-p ( regexp-quote " N/A " ) battery-level ) )
( string-match-p ( regexp-quote " N/A " ) battery-level ) )
" "
" "
( let ( ( percentage ( save-match-data
( let ( ( percentage ( save-match-data
@@ -638,27 +624,13 @@ If RELEASE-FILE is nil, use '/etc/os-release'."
" See `eshell-info-banner--get-os-information' . "
" See `eshell-info-banner--get-os-information' . "
( let ( ( prefix ( if eshell-info-banner-tramp-aware ( file-remote-p default-directory ) " " ) ) )
( let ( ( prefix ( if eshell-info-banner-tramp-aware ( file-remote-p default-directory ) " " ) ) )
` ( , ( cond
` ( , ( cond
;; Bedrock Linux
( ( executable-find " hostnamectl " eshell-info-banner-tramp-aware )
( ( file-exists-p ( concat prefix " /bedrock/etc/bedrock-release " ) )
( s-trim ( with-temp-buffer
( insert-file-contents ( concat prefix " /bedrock/etc/bedrock-release " ) )
( buffer-string ) ) ) )
;; Proxmox
( ( eshell-info-banner--executable-find " pveversion " eshell-info-banner-tramp-aware )
( let ( ( distro ( eshell-info-banner--shell-command-to-string " pveversion " ) ) )
( save-match-data
( string-match " / \\ ([^/]+ \\ )/ " distro )
( concat " Proxmox "
( substring-no-properties distro
( match-beginning 1 )
( match-end 1 ) ) ) ) ) )
( ( eshell-info-banner--executable-find " hostnamectl " eshell-info-banner-tramp-aware )
( eshell-info-banner--get-os-information-from-hostnamectl ) )
( eshell-info-banner--get-os-information-from-hostnamectl ) )
( ( eshell-info-banner-- executable-find " lsb_release " eshell-info-banner-tramp-aware )
( ( executable-find " lsb_release " eshell-info-banner-tramp-aware )
( eshell-info-banner--get-os-information-from-lsb-release ) )
( eshell-info-banner--get-os-information-from-lsb-release ) )
( ( file-exists-p ( concat prefix " /etc/os-release " ) )
( ( file-exists-p ( concat prefix " /etc/os-release " ) )
( eshell-info-banner--get-os-information-from-release-file ) )
( eshell-info-banner--get-os-information-from-release-file ) )
( ( eshell-info-banner-- executable-find " shepherd " )
( ( executable-find " shepherd " )
( let ( ( distro ( car ( s-lines ( eshell-info-banner--shell-command-to-string " guix -V " ) ) ) ) )
( let ( ( distro ( car ( s-lines ( eshell-info-banner--shell-command-to-string " guix -V " ) ) ) ) )
( save-match-data
( save-match-data
( string-match " \\ ([0-9 \\ .]+ \\ ) " distro )
( string-match " \\ ([0-9 \\ .]+ \\ ) " distro )
@@ -671,10 +643,6 @@ If RELEASE-FILE is nil, use '/etc/os-release'."
( s-trim ( with-temp-buffer
( s-trim ( with-temp-buffer
( process-file " uname " nil t nil " -s " )
( process-file " uname " nil t nil " -s " )
( buffer-string ) ) ) ) )
( buffer-string ) ) ) ) )
( ( and ( file-exists-p ( concat prefix " /system/app " ) )
( file-exists-p ( concat prefix " /system/priv-app " ) ) )
( concat " Android "
( s-trim ( eshell-info-banner--shell-command-to-string " getprop ro.build.version.release " ) ) ) )
( t " Unknown " ) )
( t " Unknown " ) )
.
.
, ( s-trim ( eshell-info-banner--shell-command-to-string " uname -rs " ) ) ) ) )
, ( s-trim ( eshell-info-banner--shell-command-to-string " uname -rs " ) ) ) ) )