8058f3d93a
Note: not the actual initial commit. I swear I will stop repeatedly force pushing to this single commit eventually ok.
32 lines
1 KiB
Common Lisp
32 lines
1 KiB
Common Lisp
(asdf:load-system :cl-hyprland-ipc)
|
|
|
|
(uiop:define-package #:time-window
|
|
(:use #:cl)
|
|
(:export #:time-window #:main))
|
|
|
|
(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)))
|