diff --git a/README.org b/README.org index 0136c7d..08e766b 100644 --- a/README.org +++ b/README.org @@ -51,6 +51,7 @@ - List remote files by query - Play remote files via mpv - Query multiple remote directories with one command + - Play remote files on other machines (need to have *strm* installed) You can access your local machine also via SSH, so every occurrence of /remote/ in the list can be replaced with /local/. @@ -84,9 +85,11 @@ OPTIONS -h, --help Show this help message -c, --config CONFIG_FILE Path to config file (default: ~/.config/strm/strm.config) + -f, --fullscreen Play video files in fullscreen -l, --list List files instead of playing -m, --media-directories MEDIA_DIRECTORIES Use given media directories, config is ignored -o, --or Use a logical OR for queries (default: AND) + -r, --remote SSH_CONNECTION_STRING Execute strm with other given arguments on remote machine (-f is set by default) -s, --shuffle Play files in random order EXAMPLES @@ -101,6 +104,7 @@ - =LEFT= and =RIGHT= :: Seek backward/forward. - =p= and =SPACE= :: Pause (pressing again unpauses). - =<= and =>= :: Go backward/forward in the playlist. + - =f= :: Toggle fullscreen. - =q= :: Stop playing and quit. - =Q= :: Like =q=, but store the current playback position. Playing the same file later will resume at the old playback position if possible. @@ -109,6 +113,19 @@ Just make sure you always quit with =Q=. To clear all stored positions remove the directory (=~/.config/mpv/watch_later=). +*** The =--remote== flag + + The =--remote= flag executes *strm* on another machine and passes all other arguments to it. + For this, *strm* needs to be installed and configured on the remote machine. + + If you pass the =--media-directories= flag it doesn't need to be configured but make sure your arguments are correct from the point of view of the remote machine. + + The =--fullscreen= is inverted when playing on a remote machine. + It is set by default and not set if you explicitly pass it. + + The remote =$DISPLAY= variable is set to =:0= by default which should fit most setups. + If you wish to change this you have to adjust the script in line 131. + ** Configuration If the =--media-directories= argument is not set, the script looks for a configuration file with the following content: diff --git a/strm b/strm index 73248da..6e82284 100755 --- a/strm +++ b/strm @@ -12,9 +12,11 @@ function print_usage { echo "OPTIONS" echo " -h, --help Show this help message" echo " -c, --config CONFIG_FILE Path to config file (default: ~/.config/strm/strm.config)" + echo " -f, --fullscreen Play video files in fullscreen" echo " -l, --list List files instead of playing" echo " -m, --media-directories MEDIA_DIRECTORIES Use given media directories, config is ignored" echo " -o, --or Use a logical OR for queries (default: AND)" + echo " -r, --remote SSH_CONNECTION_STRING Execute strm with other given arguments on remote machine (-f is set by default)" echo " -s, --shuffle Play files in random order" echo echo "EXAMPLES" @@ -41,11 +43,14 @@ fi # Set default values config="$HOME/.config/strm/strm.config" +fullscreen=false list=false -or=false -shuffle=false -queries=() media_directories="" +or=false +queries=() +remote="" +remote_arguments=() +shuffle=false # Parse arguments while (( "$#" )); do @@ -53,21 +58,28 @@ while (( "$#" )); do -c|--config) if [ -n "$2" ] && [ "${2:0:1}" != "-" ]; then config="$2" + remote_arguments+=("$1" "$2") shift 2 else error "Argument for $1 is missing" fi ;; + -f|--fullscreen) + fullscreen=true + shift + ;; -h|--help) print_usage ;; -l|--list) list=true + remote_arguments+=("$1") shift ;; -m|--media-directories) if [ -n "$2" ] && [ "${2:0:1}" != "-" ]; then media_directories="$2" + remote_arguments+=("$1" "$2") shift 2 else error "Argument for $1 is missing" @@ -75,10 +87,20 @@ while (( "$#" )); do ;; -o|--or) or=true + remote_arguments+=("$1") shift ;; + -r|--remote) + if [ -n "$2" ] && [ "${2:0:1}" != "-" ]; then + remote="$2" + shift 2 + else + error "Argument for $1 is missing" + fi + ;; -s|--shuffle) shuffle=true + remote_arguments+=("$1") shift ;; -*|--*=) @@ -86,6 +108,7 @@ while (( "$#" )); do ;; *) queries+=("$1") + remote_arguments+=("$1") shift ;; esac @@ -96,6 +119,19 @@ if [ "${#queries[@]}" == 0 ]; then print_usage fi +# Execute strm on remote if argument set +if [ "$remote" != "" ]; then + + # Invert fullscreen argument + if [ "$fullscreen" == false ]; then + remote_arguments+=("-f") + fi + + # Execute strm on remote machine + ssh -t "$remote" "DISPLAY=:0 strm ${remote_arguments[@]}; echo" + exit +fi + # If no media directory was set load config file if [ "$media_directories" == "" ]; then @@ -197,6 +233,9 @@ if [ "$list" == false ]; then if [ "$shuffle" == true ]; then mpv_arguments+=("--shuffle") fi + if [ "$fullscreen" == true ]; then + mpv_arguments+=("--fullscreen") + fi # Play all remote files mpv --msg-level=all=error,statusline=status --term-status-msg='${playlist-pos-1}/${playlist-count} - ${time-pos}/${duration} - \e[1m${metadata/artist:}${?metadata/artist: - }${metadata/title:}${!metadata/title:${filename/no-ext}}\e[0m' "${mpv_arguments[@]}" "${sftp_results[@]}"