Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- # Dependencies: zenity coreutils sed notify-osd mawk procps grep
- if [ "$1" == "--help" ];then
- me="`basename $0`"
- echo -e "Usage:\n\t$me [player] [player options] [flash id] [file]\n\tExamples: (empty quotes = auto)\n\t\t$me vlc\n\t\t$me '' '' 2702\n\t\t$me totem '' '' 17\n\t\t$me smplayer '-fullscreen -close-at-end' 7458 25"
- exit
- fi
- if [ -z "$3" ];then
- flash="`pgrep -f flashplayer`"
- if [ `echo "$flash" | wc -l` -gt 1 ];then
- flash="`echo "$flash" | paste -sd ' ' | sed 's/ / FALSE /'`"
- flash="`zenity --list --title 'Pick a Process' --text 'Multiple instances of Flash detected' --radiolist --column 'Pick' --column 'Opinion' TRUE $flash`"
- if [ -z "$flash" ];then
- exit
- fi
- fi
- else
- flash="$3"
- fi
- if [ -z "$flash" ];then
- notify-send --icon=info "No process ID" "Exiting script"
- exit
- fi
- if [ -z "$4" ];then
- files="`ls -r -l /proc/$flash/fd | grep '/tmp/Flash' | awk '{print $9}'`"
- if [ "`echo "$files" | head -1`" == "->" ];then # have to use $8 on my 10.04 Ubuntu install
- files="`ls -l /proc/$flash/fd | grep '/tmp/Flash' | awk '{print $8}'`"
- fi
- if [ `echo "$files" | wc -l` -gt 1 ];then
- files="`echo "$files" | paste -sd ' ' | sed 's/ / FALSE /'`"
- file="`zenity --list --title 'Pick a File' --text 'Multiple videos detected' --radiolist --column 'Pick' --column 'Opinion' TRUE $files`"
- if [ -z "$file" ];then
- exit
- fi
- else
- file="$files"
- fi
- else
- file="$4"
- fi
- video="/proc/$flash/fd/$file"
- if [ -f "$video" ];then
- if [ -z "$1" ];then
- player="`zenity --height 230 --list --title 'Pick a Video Player' --text 'Choose your preferred player' --radiolist --column 'Pick' --column 'Opinion' TRUE VLC FALSE Parole FALSE SMPlayer FALSE Totem FALSE Gnome-MPlayer`"
- player="`echo ${player,,}`"
- if [ -z "$player" ];then
- exit
- elif [ ! -f "/usr/bin/$player" ];then
- notify-send --icon=info "$player" "Is not installed"
- exit
- fi
- else
- player="$1"
- fi
- if [ "$player" == "echo" ];then
- echo $video
- else
- notify-send --icon=$player "Now Playing:" "$video"
- $player $2 $video > /dev/null
- fi
- else
- notify-send --icon=info "404: Not Found" "$video"
- fi
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement