dotfiles/modules/home/scripts/time-window.lisp
eriedaberrie e1fbf03dff Initial commit
Note: not the actual initial commit.

I swear I will stop repeatedly force pushing to this single commit eventually
ok.
2024-09-08 09:58:54 -07:00

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)))