add playvid script

This commit is contained in:
LordMZTE 2023-04-27 22:28:58 +02:00
parent 1e18e7ea45
commit f0f191f1db
Signed by: LordMZTE
GPG key ID: B64802DC33A64FF6
2 changed files with 23 additions and 1 deletions

View file

@ -15,7 +15,7 @@ zls-git
install-scripts target=(`echo $HOME` + "/.local"): install-scripts target=(`echo $HOME` + "/.local"):
ln -sf \ ln -sf \
`pwd`/scripts/{map-touch-display,start-joshuto,withjava,startriver,update-nvim-plugins} \ `pwd`/scripts/{map-touch-display,playvid,start-joshuto,withjava,startriver,update-nvim-plugins} \
{{target}}/bin {{target}}/bin
cd scripts/randomwallpaper && zig build -Doptimize=ReleaseFast -p {{target}} cd scripts/randomwallpaper && zig build -Doptimize=ReleaseFast -p {{target}}

22
scripts/playvid Executable file
View file

@ -0,0 +1,22 @@
#!/usr/bin/env racket
#lang racket
;; Plays a random file in CWD using mpv, unless one is provided as CLI arg.
;; Asks to delete the file after viewing it.
(require racket/gui/base)
(current-print void)
(define file
(command-line
;; default to random file
#:args ([f (let ([dir (directory-list)]) (path->string (list-ref dir (random (length dir)))))])
f))
(printf "playing: ~a\n" file)
(system* (find-executable-path "mpv") file)
(when (eq? (message-box "Delete Video?" (format "Delete this video?\n\n~a" file) #f '(yes-no)) 'yes)
(printf "deleting `~a`\n" file)
(delete-file file))