summaryrefslogtreecommitdiff
path: root/tofimpv
diff options
context:
space:
mode:
authorzachir <zachir@librem.one>2022-10-09 00:42:32 -0500
committerzachir <zachir@librem.one>2022-10-09 00:42:32 -0500
commit0217995cda2e5b3700b911b5561e99c659fba92b (patch)
tree80abdcf81366ebf51432b406e5e0e3293930cf8f /tofimpv
parent5355ec2d7e7e79d636e62b70af7dbb39002e98d3 (diff)
add tofi scripts, replacing barmenu
Diffstat (limited to 'tofimpv')
-rwxr-xr-xtofimpv46
1 files changed, 46 insertions, 0 deletions
diff --git a/tofimpv b/tofimpv
new file mode 100755
index 0000000..1d935d0
--- /dev/null
+++ b/tofimpv
@@ -0,0 +1,46 @@
+#!/sbin/sh
+
+cd ~/Videos
+case "$@" in
+ "-l")
+ LOOP="true"
+ ;;
+ "-h")
+ HELP="true"
+ ;;
+esac
+
+playvid () {
+ while true; do
+ VIDEO=$(printf ".\n%s\n" "$(ls)" | uniq | tofi "$@")
+ [ -z $VIDEO ] && exit
+ if [ "$VIDEO" = "." ]; then
+ break;
+ fi
+ [ -d $VIDEO ] && cd $VIDEO && continue
+ [ -f "$VIDEO" ] && break
+ pwd
+ done
+ mpv "$VIDEO"
+}
+
+printhelp () {
+ printf \
+ "Usage: dmpv [-l] [-h]\n" \
+ "dmpv is a simple tofi interface for playing content with mpv\n" \
+ "dmpv assumes videos are stored in ~/Videos\n" \
+ " -h\t\tprint this help message\n" \
+ " -l\t\trun the prompt again after mpv exits\n"
+}
+
+if [ -n "$HELP" ]; then
+ printhelp && exit 0
+elif [ -n "$LOOP" ]; then
+ while true; do
+ playvid || exit 0
+ done
+fi
+
+playvid
+ done
+fi