From 754bbf7a25a8dda49b5d08ef0d0443bbf5af0e36 Mon Sep 17 00:00:00 2001 From: Craig Jennings Date: Sun, 7 Apr 2024 13:41:34 -0500 Subject: new repository --- modules/host-environment.el | 48 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 modules/host-environment.el (limited to 'modules/host-environment.el') diff --git a/modules/host-environment.el b/modules/host-environment.el new file mode 100644 index 00000000..649cabe5 --- /dev/null +++ b/modules/host-environment.el @@ -0,0 +1,48 @@ +;;; host-environment.el --- Host Environment Convenience Functions -*- lexical-binding: t; -*- + +;;; Commentary: +;; Convenience functions to report about the host environment + +;;; Code: + +(require 'battery) + +(defun env-laptop-p () + "Return t if host is a laptop (has a battery), nil if not." + (when (and battery-status-function + (not (string-match-p "N/A" + (battery-format "%B" + (funcall battery-status-function))))) + t)) + +(defun env-desktop-p () + "Return t if host is a laptop (has a battery), nil if not." + (when (not (env-laptop-p)) + t)) + +(defun env-linux-p () + "Return t if host system is GNU/Linux." + (string-equal system-type "gnu/linux")) + +(defun env-bsd-p () + "Return t if host system is FreeBSD." + (string-equal system-type "berkeley-unix")) + +(defun env-macos-p () + "Return t if host system is Mac OS (darwin-based)." + (string-equal system-type "darwin")) + +(defun env-windows-p () + "Return t if host system is Windows." + (memq system-type '(cygwin windows-nt ms-dos))) + +(defun env-terminal-p () + "Return t if running in a terminal." + (not (display-graphic-p))) + +(defun env-gui-p () + "Return t if running in graphical environment." + (display-graphic-p)) + +(provide 'host-environment) +;;; host-environment.el ends here. -- cgit v1.2.3