Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- function dblcmd_mplayer() {
- xdotool search --sync --name "Double Commander" windowactivate
- if [[ $? == 0 ]]; then
- # copy a file fullpath under cursor to clipboard
- echo -n "" | xclip -selection clipboard
- xdotool key ctrl+shift+c
- # read clipboard
- sleep 0.1
- fileLoc=$(xsel -b)
- escape=("[" "]" "~" "!" "{" "}" "(" ")" "$" "@" "<" ">" ":" ";" "," '`' "%" "+" "=" '"' "|" "?" '*' "&" " " "'")
- for e in "${escape[@]}"
- do
- fileLoc=${fileLoc//[$e]/\\$e}
- done
- fileLoc=${fileLoc//"\\'"/"'\"\'\"'"}
- # execute filename with full path in terminal via Mplayer
- # fileLoc=$(echo "lxterminal -e 'bash -c "'"mplayer -idx -aid 1 -sid 0 -fs '"$fileLoc"'; bash"'"'")
- fileLoc=$(echo "lxterminal -e 'bash -c "'"mplayer -idx -alang jp -slang jpn '"$fileLoc"'; bash"'"'")
- echo $fileLoc | tr -d "\n\r" | xclip -selection clipboard
- # run program
- bash -c "$fileLoc" 2>/dev/null
- while ! [[ $(xdotool search --onlyvisible --name "MPlayer") ]]; do
- sleep 1
- done
- xdotool windowmove "$(xdotool search --onlyvisible --name "MPlayer")" 0 60
- xdotool search --onlyvisible --name "MPlayer" windowactivate
- sleep 0.5
- xdotool key f
- else
- echo 'Double Commander window not found'
- fi
- # xdotool search --onlyvisible --name "MPlayer"
- # while [[ $(xdotool search --onlyvisible --name "MPlayer") ]]; do
- # sleep 1
- # done
- # # close any existing windows
- # sleep 0.5
- # ps -ef | grep "bash -c mplayer" | grep -v grep | awk '{print $2}' | xargs kill -9
- }
- dblcmd_mplayer
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement