enhance remote execution

This commit is contained in:
Denis Lehmann 2021-05-04 00:59:02 +02:00
parent 8dffc3e6da
commit e1a2f67d09
2 changed files with 18 additions and 7 deletions

View file

@ -62,6 +62,7 @@
** Installation
Make sure, mpv is installed and that you have access to a machine via SSH.
If you plan to execute *strm* on a remote machine with the =--remote= flag, install [[https://github.com/tmux/][tmux]] in addition to mpv on the target.
*strm* is just a script, you can execute it directly.
Or grab it and place it in your =$PATH=.
@ -115,17 +116,21 @@
*** The =--remote= flag
The =--remote= flag executes *strm* on another machine and passes all other arguments to it.
The =--remote= flag executes *strm* on another machine in a tmux session and passes all other arguments to it.
For this, *strm* needs to be installed and configured on the remote machine.
Launching it in a tmux session allows to detach from the session with =C-b d=.
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.
If a session is already running on the target machine, the session gets attached.
Further commands are ignored (it is even sufficient to call =strm -r <remote>=).
If you pass the =--media-directories= flag, *strm* doesn't need to be configured but make sure your arguments are correct from the point of view of the remote machine.
The same holds true if you pass the =--config= flag.
=--fullscreen= is inverted when playing on a remote machine.
It is set by default and not set if you explicitly pass it.
On the remote, the =$DISPLAY= variable is set by default to =:0= which should fit most setups.
If you wish to change this you have to adjust the script in line 131.
If you wish to change this, search for the line containing =DISPLAY= in the script and adjust it.
** Configuration

14
strm
View file

@ -125,6 +125,11 @@ done
# Execute strm on remote if argument set
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"
fi
# Check if strm tmux session is already running
if ssh "$remote" "tmux has-session -t strm &>/dev/null"; then
@ -135,7 +140,7 @@ if [ "$remote" != "" ]; then
# Print usage if no queries were given
if [ "${#queries[@]}" == 0 ]; then
echo -ne "No strm session running on ${text_bold}$remote${text_reset}, please provide a query"
echo -ne "No strm session running on ${text_bold}$remote${text_reset}, please provide a query\n"
exit
fi
@ -148,7 +153,7 @@ if [ "$remote" != "" ]; then
remote_arguments+=("--is-remote-call")
# Execute strm on remote machine
ssh -t "$remote" "DISPLAY=:0 tmux new-session -s strm strm ${remote_arguments[@]} &>/dev/null"
ssh -t "$remote" "DISPLAY=:0 tmux new-session -s strm 'tmux set-option status off; strm ${remote_arguments[@]}' &>/dev/null"
fi
exit
fi
@ -232,10 +237,11 @@ echo
# Exit if no results found
if [ "${#sftp_results[@]}" == 0 ]; then
echo "No files found"
if [ "$is_remote_call" == true ]; then
echo "Press something to quit"
echo "No files found, press something to quit"
read -n 1
else
echo "No files found"
fi
exit
fi