dotfiles/scripts/playvid.ros

31 lines
1 KiB
Text
Raw Normal View History

2023-05-18 23:49:38 +02:00
#!/usr/bin/env -S ros -Q --
#|-*- mode:lisp -*-|#
2023-05-19 16:23:34 +02:00
#|
exec ros -Q -- $0 "$@"
|#
2023-05-18 23:49:38 +02:00
(progn ;;init forms
(ros:ensure-asdf)
#+quicklisp(ql:quickload '(uiop trivial-raw-io) :silent t))
(defpackage :playvid
(:use :cl))
(in-package :playvid)
(defun main (&rest argv)
2023-07-07 21:45:14 +02:00
(let* ((vidfile (or (uiop:parse-native-namestring (car argv))
2023-05-18 23:49:38 +02:00
(let ((dir (uiop:directory-files ".")))
(nth (random (length dir) (make-random-state t)) dir))))
(basename (pathname-name vidfile)))
(format t "playing video: ~a~%" basename)
(uiop:run-program (list "mpv" (file-namestring vidfile))
:input :interactive
:error-output :interactive
:output :interactive)
(format t "delete `~a`? [Y/n] " basename)
(force-output)
(let ((input (char-upcase (trivial-raw-io:read-char))))
(format t "~a~%" input)
(when (char-equal #\Y input)
(format t "deleting file `~a`~%" basename)
(delete-file vidfile)))))