lisp-scripts/time-window/time-window.lisp

26 lines
940 B
Common Lisp
Raw Permalink Normal View History

(in-package #:time-window)
(defun time-window (argv use-pid)
(time
(let* ((process-info (uiop:launch-program argv))
(pid (uiop:process-info-pid process-info)))
(format t "Started process via `~{~A~^ ~}` with PID ~A~%" argv pid)
(hyprland-ipc:handle-events
:return-on-non-nil-p t
:open-window (lambda (address workspace-name class title)
(declare (ignorable address workspace-name class title))
(or (not use-pid)
(= pid
(gethash "pid"
(hyprland-ipc:find-client-data address)))))))))
(defun main ()
(let* ((argv (uiop:command-line-arguments))
(use-pid (string= (first argv) "-p")))
(when use-pid
(setf argv (rest argv)))
(unless argv
(format *error-output* "Needs command string!~%")
(uiop:quit 1 t))
(time-window argv use-pid)))