dotfiles/scripts/playvid.ros

40 lines
1.4 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)
2023-09-17 15:00:11 +02:00
#+quicklisp(ql:quickload '(uiop) :silent t))
2023-05-18 23:49:38 +02:00
(defpackage :playvid
(:use :cl))
(in-package :playvid)
(defun main (&rest argv)
2023-09-17 15:00:11 +02:00
(let* ((vidfile (or (uiop:parse-native-namestring (car argv))
(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" (uiop:native-namestring vidfile))
:input :interactive
:error-output :interactive
:output :interactive
:ignore-error-status t)
(let ((confirm (uiop:run-program (list
"rofi"
"-dmenu"
"-theme"
(format nil "~a/.local/share/rofi/applets/confirm.rasi"
(user-homedir-pathname))
"-mesg"
(format nil "delete `~a`?" basename))
:input (lambda (s) (format s "No~CYes" #\newline))
:ignore-error-status t
:output :string)))
(when (string-equal (format nil "Yes~C" #\newline) confirm)
(format t "deleting file `~a`~%" basename)
(delete-file vidfile)))))