From 4b8d5b28193d8a80a6d0ea268d19e06a208ea189 Mon Sep 17 00:00:00 2001 From: Denis Lehmann Date: Fri, 15 Oct 2021 20:58:13 +0200 Subject: [PATCH 01/10] update README --- README.org | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/README.org b/README.org index c890b4e..27ff362 100644 --- a/README.org +++ b/README.org @@ -18,7 +18,7 @@ If *strm* is configured to use the =media= directory, you can play the shortfilm e.g. with the following command: - : strm daily dweebs + : $ strm daily dweebs Every argument which is not assigned to an flag is interpreted as part of the query. The query arguments are interpreted as [[https://en.wikipedia.org/wiki/Glob_(programming)][glob patterns]], additionally surrounded by wildcards (=*=). @@ -28,9 +28,9 @@ The shortfilm from the example above could have also been played with one of the following commands: - : strm dweebs daily - : strm movies dwee - : strm d d 17 + : $ strm dweebs daily + : $ strm movies dwee + : $ strm d d 17 It is possible that multiple files are matched by one of the commands. All files are then played in the order of the configured media directories, followed by lexicographical order of the filepath. @@ -74,7 +74,7 @@ This project is also a [[https://nixos.wiki/wiki/Flakes][Nix flake]]. You can execute it with the following command if you have a recent version of [[https://nixos.org/][Nix]] installed and flakes are enabled: - : nix run github:Deleh/strm -- --help + : $ nix run github:Deleh/strm -- --help If you use it this way, mpv is started with *MPRIS* support by default. From 8ab56881457c0f58717e6ac2bdc7ff3a2a3f4701 Mon Sep 17 00:00:00 2001 From: Denis Lehmann Date: Fri, 5 Nov 2021 09:53:29 +0100 Subject: [PATCH 02/10] save only the playback position --- strm | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/strm b/strm index c05d66d..803e586 100755 --- a/strm +++ b/strm @@ -170,7 +170,7 @@ if [ "$remote" != "" ]; then # Check if dependencies are fulfilled on remote if ! ssh "$remote" "command -v mpv strm tmux &>/dev/null"; then - error "make sure ${text_bold}$remote${text_reset} is accessible and mpv, strm and tmux are installed" + error "make sure ${text_bold}$remote${text_reset} is accessible and mpv, strm and tmux are installed" fi # Check if strm tmux session is already running @@ -414,6 +414,12 @@ if [ "$list" == false ]; then fi if [ "$playback_directory" != "" ]; then mpv_arguments+=("--save-position-on-quit") + + # Save only the playback position if mpv version is at least 0.34.0 + [[ $(mpv --version | head -n 1) =~ [0-9]+.([0-9]+).[0-9]+ ]] + if [ ${BASH_REMATCH[1]} -ge 34 ]; then + mpv_arguments+=("--watch-later-options-clr") + fi fi # Play all remote files From 5c422f88dedbefd07fb902d7dab4c7135fde2918 Mon Sep 17 00:00:00 2001 From: Denis Lehmann Date: Fri, 5 Nov 2021 09:57:25 +0100 Subject: [PATCH 03/10] update flake --- flake.lock | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/flake.lock b/flake.lock index 6702fbb..6526931 100644 --- a/flake.lock +++ b/flake.lock @@ -2,11 +2,11 @@ "nodes": { "flake-utils": { "locked": { - "lastModified": 1631561581, - "narHash": "sha256-3VQMV5zvxaVLvqqUrNz3iJelLw30mIVSfZmAaauM3dA=", + "lastModified": 1634851050, + "narHash": "sha256-N83GlSGPJJdcqhUxSCS/WwW5pksYf3VP1M13cDRTSVA=", "owner": "numtide", "repo": "flake-utils", - "rev": "7e5bf3925f6fbdfaf50a2a7ca0be2879c4261d19", + "rev": "c91f3de5adaf1de973b797ef7485e441a65b8935", "type": "github" }, "original": { @@ -17,10 +17,10 @@ }, "nixpkgs": { "locked": { - "lastModified": 1634115022, - "narHash": "sha256-K9DZMQ47VRrg9gtTPwex5p0E8LnwM/dDkNe7AQW0qj0=", - "path": "/nix/store/fjn0mcw4wcm7lkcn92bzq11f0mzv3xqv-source", - "rev": "564cb4d81d4f734dd068684adec5a60077397fe9", + "lastModified": 1635719588, + "narHash": "sha256-pWjdy0NheM97NsPE6+jUnr5LYyeA0sBGTdw4mfXMGZQ=", + "path": "/nix/store/w1kgp6j8n0w46q5d5a2d3zmas4g4xr28-source", + "rev": "f0869b1a2c0b150aac26e10bb5c2364ffb2e804f", "type": "path" }, "original": { From 9a113c5013abd39c64e1f93d2487049e26f07dc2 Mon Sep 17 00:00:00 2001 From: Denis Lehmann Date: Sun, 7 Nov 2021 23:51:25 +0100 Subject: [PATCH 04/10] update inputs --- flake.lock | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/flake.lock b/flake.lock index 6526931..eb74317 100644 --- a/flake.lock +++ b/flake.lock @@ -17,10 +17,10 @@ }, "nixpkgs": { "locked": { - "lastModified": 1635719588, - "narHash": "sha256-pWjdy0NheM97NsPE6+jUnr5LYyeA0sBGTdw4mfXMGZQ=", - "path": "/nix/store/w1kgp6j8n0w46q5d5a2d3zmas4g4xr28-source", - "rev": "f0869b1a2c0b150aac26e10bb5c2364ffb2e804f", + "lastModified": 1636138231, + "narHash": "sha256-FZQ5wBcB9zI21uQMB/PaEQ/cLYk+Bwnig5cg1+2rPgg=", + "path": "/nix/store/c504m27i25igq2xzrl80pksycz3jkax1-source", + "rev": "5c02380de3951d0237807c16eb19873cb3c5f75d", "type": "path" }, "original": { From a1dca93dc80c36ac9f70d80315bd55d1b5c2e6c1 Mon Sep 17 00:00:00 2001 From: Denis Lehmann Date: Mon, 8 Nov 2021 02:38:22 +0100 Subject: [PATCH 05/10] explicitly declare nixpkgs --- flake.lock | 17 ++++++++++------- flake.nix | 7 +++++-- 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/flake.lock b/flake.lock index eb74317..1074df1 100644 --- a/flake.lock +++ b/flake.lock @@ -17,15 +17,18 @@ }, "nixpkgs": { "locked": { - "lastModified": 1636138231, - "narHash": "sha256-FZQ5wBcB9zI21uQMB/PaEQ/cLYk+Bwnig5cg1+2rPgg=", - "path": "/nix/store/c504m27i25igq2xzrl80pksycz3jkax1-source", - "rev": "5c02380de3951d0237807c16eb19873cb3c5f75d", - "type": "path" + "lastModified": 1636267212, + "narHash": "sha256-KDS173KqmqrYUPY9N4vf750GxIo+S6E0djyq2BsQm8s=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "c935f5e0add2cf0ae650d072c8357533e21b0c35", + "type": "github" }, "original": { - "id": "nixpkgs", - "type": "indirect" + "owner": "nixos", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" } }, "root": { diff --git a/flake.nix b/flake.nix index 16956ea..c6bf35b 100644 --- a/flake.nix +++ b/flake.nix @@ -3,7 +3,10 @@ nixConfig.bash-prompt = "\[\\e[1mstrm-dev\\e[0m:\\w\]$ "; - inputs.flake-utils.url = "github:numtide/flake-utils"; + inputs = { + nixpkgs.url = github:nixos/nixpkgs/nixos-unstable; + flake-utils.url = github:numtide/flake-utils; + }; outputs = { self, nixpkgs, flake-utils }: @@ -28,7 +31,7 @@ src = self; patchPhase = with pkgs; '' substituteInPlace strm \ - --replace mpv\ ${mpv}/bin/mpv\ + --replace mpv\ ${mpv}/bin/mpv\ ''; installPhase = '' install -m 755 -D strm $out/bin/strm From a2aa93a9cb65426ad141fd9a871f4914761ebc46 Mon Sep 17 00:00:00 2001 From: Denis Lehmann Date: Mon, 8 Nov 2021 02:46:37 +0100 Subject: [PATCH 06/10] add missing space --- flake.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/flake.nix b/flake.nix index c6bf35b..f29f9a8 100644 --- a/flake.nix +++ b/flake.nix @@ -31,7 +31,7 @@ src = self; patchPhase = with pkgs; '' substituteInPlace strm \ - --replace mpv\ ${mpv}/bin/mpv\ + --replace mpv\ ${mpv}/bin/mpv\ ''; installPhase = '' install -m 755 -D strm $out/bin/strm From 1fea7028ed3479bd1a24c6c882ef8a7e97f737c5 Mon Sep 17 00:00:00 2001 From: Denis Lehmann Date: Thu, 13 Jan 2022 11:41:21 +0100 Subject: [PATCH 07/10] update flake inputs --- flake.lock | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/flake.lock b/flake.lock index 1074df1..fbe661d 100644 --- a/flake.lock +++ b/flake.lock @@ -2,11 +2,11 @@ "nodes": { "flake-utils": { "locked": { - "lastModified": 1634851050, - "narHash": "sha256-N83GlSGPJJdcqhUxSCS/WwW5pksYf3VP1M13cDRTSVA=", + "lastModified": 1638122382, + "narHash": "sha256-sQzZzAbvKEqN9s0bzWuYmRaA03v40gaJ4+iL1LXjaeI=", "owner": "numtide", "repo": "flake-utils", - "rev": "c91f3de5adaf1de973b797ef7485e441a65b8935", + "rev": "74f7e4319258e287b0f9cb95426c9853b282730b", "type": "github" }, "original": { @@ -17,11 +17,11 @@ }, "nixpkgs": { "locked": { - "lastModified": 1636267212, - "narHash": "sha256-KDS173KqmqrYUPY9N4vf750GxIo+S6E0djyq2BsQm8s=", + "lastModified": 1641887635, + "narHash": "sha256-kDGpufwzVaiGe5e1sBUBPo9f1YN+nYHJlYqCaVpZTQQ=", "owner": "nixos", "repo": "nixpkgs", - "rev": "c935f5e0add2cf0ae650d072c8357533e21b0c35", + "rev": "b2737d4980a17cc2b7d600d7d0b32fd7333aca88", "type": "github" }, "original": { From 323540641f4cc647a66d07dd5d193bd31da6e26f Mon Sep 17 00:00:00 2001 From: Denis Lehmann Date: Tue, 14 Feb 2023 21:24:20 +0100 Subject: [PATCH 08/10] update flake inputs --- flake.lock | 12 ++++++------ flake.nix | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/flake.lock b/flake.lock index fbe661d..47d5708 100644 --- a/flake.lock +++ b/flake.lock @@ -2,11 +2,11 @@ "nodes": { "flake-utils": { "locked": { - "lastModified": 1638122382, - "narHash": "sha256-sQzZzAbvKEqN9s0bzWuYmRaA03v40gaJ4+iL1LXjaeI=", + "lastModified": 1676283394, + "narHash": "sha256-XX2f9c3iySLCw54rJ/CZs+ZK6IQy7GXNY4nSOyu2QG4=", "owner": "numtide", "repo": "flake-utils", - "rev": "74f7e4319258e287b0f9cb95426c9853b282730b", + "rev": "3db36a8b464d0c4532ba1c7dda728f4576d6d073", "type": "github" }, "original": { @@ -17,11 +17,11 @@ }, "nixpkgs": { "locked": { - "lastModified": 1641887635, - "narHash": "sha256-kDGpufwzVaiGe5e1sBUBPo9f1YN+nYHJlYqCaVpZTQQ=", + "lastModified": 1676300157, + "narHash": "sha256-1HjRzfp6LOLfcj/HJHdVKWAkX9QRAouoh6AjzJiIerU=", "owner": "nixos", "repo": "nixpkgs", - "rev": "b2737d4980a17cc2b7d600d7d0b32fd7333aca88", + "rev": "545c7a31e5dedea4a6d372712a18e00ce097d462", "type": "github" }, "original": { diff --git a/flake.nix b/flake.nix index f29f9a8..7c049e5 100644 --- a/flake.nix +++ b/flake.nix @@ -16,7 +16,7 @@ pkgs = nixpkgs.legacyPackages.${system}; # Use mpv with scripts - mpv = (pkgs.mpv-with-scripts.override { + mpv = (pkgs.mpv.override { scripts = [ pkgs.mpvScripts.mpris ]; From 06a2585909fd21855afa8125bdd999ffe106ffba Mon Sep 17 00:00:00 2001 From: Denis Lehmann Date: Mon, 27 Nov 2023 05:09:42 +0100 Subject: [PATCH 09/10] shellcheck --- strm | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/strm b/strm index 803e586..413aa75 100755 --- a/strm +++ b/strm @@ -154,7 +154,7 @@ while (( "$#" )); do remote_arguments+=("$1") shift ;; - -*|--*=) + -*) error "Unsupported flag: $1" ;; *) @@ -190,7 +190,7 @@ if [ "$remote" != "" ]; then remote_arguments+=("--is-remote-call") # Execute strm on remote machine - ssh -o ConnectTimeout=10 -t "$remote" "DISPLAY=:0 tmux new-session -s strm 'tmux set-option status off; strm ${remote_arguments[@]}' &>/dev/null" + ssh -o ConnectTimeout=10 -t "$remote" "DISPLAY=:0 tmux new-session -s strm 'tmux set-option status off; strm ${remote_arguments[*]}' &>/dev/null" fi exit fi @@ -253,7 +253,7 @@ if [ "$list" == false ] && [ "$playback_directory" != "" ]; then # Add leading and trailing slash to directory if missing [[ "$directory" != /*/ ]] && directory="/$directory/" - echo -ne "Synchronizing playback directory with $text_bold$(basename $connection_string)$text_reset\n" + echo -ne "Synchronizing playback directory with $text_bold$(basename "$connection_string")$text_reset\n" # Make remote directory if not existent ssh -o ConnectTimeout=10 "$connection_string" "mkdir -p $directory" @@ -272,10 +272,10 @@ if [ "${#queries[@]}" == 0 ]; then fi # Read media directories -IFS="," read -a media_directories <<< "$media_directories" +IFS="," read -ar media_directories <<< "$media_directories" # Read ignore files -IFS="," read -a ignore_files <<< "$ignore_files" +IFS="," read -ar ignore_files <<< "$ignore_files" # Construct find argument array @@ -337,7 +337,7 @@ for media_directory in "${media_directories[@]}"; do # Add leading and trailing slash to directory if missing [[ "$directory" != /*/ ]] && directory="/$directory/" - echo -ne "Fetching results from $text_bold$(basename $directory)$text_reset on $text_bold$connection_string$text_reset\n" + echo -ne "Fetching results from $text_bold$(basename "$directory")$text_reset on $text_bold$connection_string$text_reset\n" # Get search results from remote # Look for paths matching given queries in visible directories, listing only filenames and links @@ -359,7 +359,7 @@ echo if [ "${#sftp_results[@]}" == 0 ]; then if [ "$is_remote_call" == true ]; then echo "No files found, press something to quit" - read -n 1 + read -nr 1 else echo "No files found" fi @@ -389,7 +389,7 @@ if [ "$list" == false ]; then # Save arguments for later call if [ "$playback_directory" != "" ]; then - echo "queries=(${queries[@]})" > "$HOME/.cache/strm/strm_later" + echo "queries=(${queries[*]})" > "$HOME/.cache/strm/strm_later" echo "or=$or" >> "$HOME/.cache/strm/strm_later" echo "shuffle=$shuffle" >> "$HOME/.cache/strm/strm_later" fi @@ -417,7 +417,7 @@ if [ "$list" == false ]; then # Save only the playback position if mpv version is at least 0.34.0 [[ $(mpv --version | head -n 1) =~ [0-9]+.([0-9]+).[0-9]+ ]] - if [ ${BASH_REMATCH[1]} -ge 34 ]; then + if [ "${BASH_REMATCH[1]}" -ge 34 ]; then mpv_arguments+=("--watch-later-options-clr") fi fi @@ -447,7 +447,7 @@ if [ "$list" == false ]; then # Add leading and trailing slash to directory if missing [[ "$directory" != /*/ ]] && directory="/$directory/" - echo -ne "\nSynchronizing playback directory with $text_bold$(basename $connection_string)$text_reset" + echo -ne "\nSynchronizing playback directory with $text_bold$(basename "$connection_string")$text_reset" # Synchronize local to remote rsync -az --delete "$HOME/.cache/strm/" "$connection_string:$directory" From 413701bf138faef6d37cf21dff1f18b967b4b3b1 Mon Sep 17 00:00:00 2001 From: Denis Lehmann Date: Mon, 27 Nov 2023 05:09:49 +0100 Subject: [PATCH 10/10] update flake inputs --- flake.lock | 30 ++++++++++++++++++++++++------ 1 file changed, 24 insertions(+), 6 deletions(-) diff --git a/flake.lock b/flake.lock index 47d5708..397cc5a 100644 --- a/flake.lock +++ b/flake.lock @@ -1,12 +1,15 @@ { "nodes": { "flake-utils": { + "inputs": { + "systems": "systems" + }, "locked": { - "lastModified": 1676283394, - "narHash": "sha256-XX2f9c3iySLCw54rJ/CZs+ZK6IQy7GXNY4nSOyu2QG4=", + "lastModified": 1694529238, + "narHash": "sha256-zsNZZGTGnMOf9YpHKJqMSsa0dXbfmxeoJ7xHlrt+xmY=", "owner": "numtide", "repo": "flake-utils", - "rev": "3db36a8b464d0c4532ba1c7dda728f4576d6d073", + "rev": "ff7b65b44d01cf9ba6a71320833626af21126384", "type": "github" }, "original": { @@ -17,11 +20,11 @@ }, "nixpkgs": { "locked": { - "lastModified": 1676300157, - "narHash": "sha256-1HjRzfp6LOLfcj/HJHdVKWAkX9QRAouoh6AjzJiIerU=", + "lastModified": 1700794826, + "narHash": "sha256-RyJTnTNKhO0yqRpDISk03I/4A67/dp96YRxc86YOPgU=", "owner": "nixos", "repo": "nixpkgs", - "rev": "545c7a31e5dedea4a6d372712a18e00ce097d462", + "rev": "5a09cb4b393d58f9ed0d9ca1555016a8543c2ac8", "type": "github" }, "original": { @@ -36,6 +39,21 @@ "flake-utils": "flake-utils", "nixpkgs": "nixpkgs" } + }, + "systems": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } } }, "root": "root",