Advertisement
Guest User

pusti_video.sh, plays video files

a guest
Feb 2nd, 2023
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.56 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. function dblcmd_mplayer() {
  4.   xdotool search --sync --name "Double Commander" windowactivate
  5.   if [[ $? == 0 ]]; then
  6.     # copy a file fullpath under cursor to clipboard
  7.     echo -n "" | xclip -selection clipboard
  8.     xdotool key ctrl+shift+c
  9.     # read clipboard
  10.     sleep 0.1
  11.     fileLoc=$(xsel -b)
  12.     escape=("[" "]" "~" "!" "{" "}" "(" ")" "$" "@" "<" ">" ":" ";" "," '`' "%" "+" "=" '"' "|" "?" '*' "&" " " "'")
  13.     for e in "${escape[@]}"
  14.     do
  15.       fileLoc=${fileLoc//[$e]/\\$e}
  16.     done
  17.     fileLoc=${fileLoc//"\\'"/"'\"\'\"'"}
  18.     # execute filename with full path in terminal via Mplayer
  19.     # fileLoc=$(echo "lxterminal -e 'bash -c "'"mplayer -idx -aid 1 -sid 0 -fs '"$fileLoc"'; bash"'"'")
  20.     fileLoc=$(echo "lxterminal -e 'bash -c "'"mplayer -idx -alang jp -slang jpn '"$fileLoc"'; bash"'"'")
  21.     echo $fileLoc | tr -d "\n\r" | xclip -selection clipboard
  22.     # run program
  23.     bash -c "$fileLoc" 2>/dev/null
  24.     while ! [[ $(xdotool search --onlyvisible --name "MPlayer") ]]; do
  25.       sleep 1
  26.     done
  27.     xdotool windowmove "$(xdotool search --onlyvisible --name "MPlayer")" 0 60
  28.     xdotool search --onlyvisible --name "MPlayer" windowactivate
  29.     sleep 0.5
  30.     xdotool key f
  31.   else
  32.     echo 'Double Commander window not found'
  33.   fi
  34.   # xdotool search --onlyvisible --name "MPlayer"
  35.   # while [[ $(xdotool search --onlyvisible --name "MPlayer") ]]; do
  36.      #  sleep 1
  37.   # done
  38.   # # close any existing windows
  39.   # sleep 0.5
  40.   # ps -ef | grep "bash -c mplayer" | grep -v grep | awk '{print $2}' | xargs kill -9
  41. }
  42.  
  43. dblcmd_mplayer
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement