Skip to content

Commit

Permalink
Add missing file
Browse files Browse the repository at this point in the history
  • Loading branch information
sdilts committed Oct 27, 2023
1 parent 2ce6cca commit 5945ee9
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions lisp/system.lisp
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
(defpackage #:mahogany/system
(:documentation "Package for functions interacting with the system that
Mahogany is running under")
(:use :cl)
(:local-nicknames (#:alex #:alexandria))
(:nicknames #:sys)
(:export #:find-program
#:open-terminal))

(in-package #:mahogany/system)

(defun find-program (name)
(declare (type string name))
(handler-case
(string-trim '(#\Newline #\Space)
(with-output-to-string (stream)
(uiop:run-program (list "which" name) :output stream)))
(UIOP/RUN-PROGRAM:SUBPROCESS-ERROR nil)))

(defun open-terminal ()
(let ((programs #("konsole" "gnome-terminal")))
(loop for i across programs
do (alex:when-let ((program (find-program i)))
(uiop:launch-program program)
(return t)))
(values nil)))

0 comments on commit 5945ee9

Please sign in to comment.