Advertisement
Guest User

Untitled

a guest
Aug 3rd, 2013
315
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 2.12 KB | None | 0 0
  1. #!/bin/bash
  2. # Dependencies: zenity coreutils sed notify-osd mawk procps grep
  3. if [ "$1" == "--help" ];then
  4.     me="`basename $0`"
  5.     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"
  6.     exit
  7. fi
  8. if [ -z "$3" ];then
  9.     flash="`pgrep -f flashplayer`"
  10.     if [ `echo "$flash" | wc -l` -gt 1 ];then
  11.         flash="`echo "$flash" | paste -sd ' ' | sed 's/ / FALSE /'`"
  12.         flash="`zenity --list --title 'Pick a Process' --text 'Multiple instances of Flash detected' --radiolist --column 'Pick' --column 'Opinion' TRUE $flash`"
  13.         if [ -z "$flash" ];then
  14.             exit
  15.         fi
  16.     fi
  17. else
  18.     flash="$3"
  19. fi
  20. if [ -z "$flash" ];then
  21.     notify-send --icon=info "No process ID" "Exiting script"
  22.     exit
  23. fi
  24. if [ -z "$4" ];then
  25.     files="`ls -r -l /proc/$flash/fd | grep '/tmp/Flash' | awk '{print $9}'`"
  26.     if [ "`echo "$files" | head -1`" == "->" ];then # have to use $8 on my 10.04 Ubuntu install
  27.         files="`ls -l /proc/$flash/fd | grep '/tmp/Flash' | awk '{print $8}'`"
  28.     fi
  29.     if [ `echo "$files" | wc -l` -gt 1 ];then
  30.         files="`echo "$files" | paste -sd ' ' | sed 's/ / FALSE /'`"
  31.         file="`zenity --list --title 'Pick a File' --text 'Multiple videos detected' --radiolist --column 'Pick' --column 'Opinion' TRUE $files`"
  32.         if [ -z "$file" ];then
  33.             exit
  34.         fi
  35.     else
  36.         file="$files"
  37.     fi
  38. else
  39.     file="$4"
  40. fi
  41. video="/proc/$flash/fd/$file"
  42. if [ -f "$video" ];then
  43.     if [ -z "$1" ];then
  44.         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`"
  45.         player="`echo ${player,,}`"
  46.         if [ -z "$player" ];then
  47.             exit
  48.         elif [ ! -f "/usr/bin/$player" ];then
  49.             notify-send --icon=info "$player" "Is not installed"
  50.             exit
  51.         fi
  52.     else
  53.         player="$1"
  54.     fi
  55.     if [ "$player" == "echo" ];then
  56.         echo $video
  57.     else
  58.         notify-send --icon=$player "Now Playing:" "$video"
  59.         $player $2 $video > /dev/null
  60.     fi
  61. else
  62.     notify-send --icon=info "404: Not Found" "$video"
  63. fi
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement