dotfiles/scripts/playvid.ros

39 lines
1.4 KiB
Common Lisp
Executable file

#!/usr/bin/env -S ros -Q --
#|-*- mode:lisp -*-|#
#|
exec ros -Q -- $0 "$@"
|#
(progn ;;init forms
(ros:ensure-asdf)
#+quicklisp(ql:quickload '(uiop) :silent t))
(defpackage :playvid
(:use :cl))
(in-package :playvid)
(defun main (&rest argv)
(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)))))