summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLinnnus <[email protected]>2023-12-09 09:19:20 +0100
committerLinnnus <[email protected]>2023-12-09 09:19:20 +0100
commitf2244c558a8160b7eb6f88712c86108f78054054 (patch)
tree91d3222c36568d17f2c71c6a6419ca331b29fee4
parentbd1be01050dc6de72f1fb4a67277a56267ddb1cf (diff)
pkgs/watch-while: Act transparently NO_WATCH is defined
-rw-r--r--pkgs/watch-while/watch-while.zsh13
1 files changed, 9 insertions, 4 deletions
diff --git a/pkgs/watch-while/watch-while.zsh b/pkgs/watch-while/watch-while.zsh
index d38d393..f483d15 100644
--- a/pkgs/watch-while/watch-while.zsh
+++ b/pkgs/watch-while/watch-while.zsh
@@ -2,16 +2,21 @@
set -ue
-# This file should be a (symbolik link to a) file which we want to watch. Once
-# we're finished with that movie, we just read the next.
+if [ $# -eq 0 ]; then
+ echo >&2 "Usage: $0 <command> [arg...]"
+ exit 1
+fi
+
+# This file should be a (symbolik link to a) file which we want to watch.
+# TODO: Once we're finished with that movie, we just read the next.
movie=${XDG_CONFIG_HOME:-$HOME/.config}/watch-while/movie
-if [ -f $movie ]; then
+if [ -f $movie ] && ! [ -v NO_WATCH ]; then
@mpv@/bin/mpv --save-position-on-quit --autofit='90%x90%' -- $movie >/dev/null 2>&1 &
mpv_pid=$?
trap 'kill -s QUIT $mpv_pid' EXIT
- # We don't exec because we want our exec handler to fire.
+ # We don't exec because we want our exit handler to fire.
"$@" || exit $?
else
# In this case where we don't have any movie we just transparently run the command.