Useful cli remote control for N900 KMplayer

Works only if you use mplayer backend.

On N900 create script /home/user/.bin/mplayer-control.sh:

#!/bin/bash
if [ "`pidof kmplayer`" == "" ]; then
    exit
fi

out=/proc/`pidof mplayer`/fd/0

echo "Choose:
  p or space or enter: toggle play/pause
  <: seek backward 5 seconds
  >: seek forward 5 seconds
  [: seek backward 30 seconds
  ]: seek forward 30 seconds
  {: seek backward 5 minutes
  }: seek forward 5 minutes
  9: volume down
  0: volume up
  o: toggle osd mode
  v: toggle subtitle visibility
  q: quit this program"
while true; do
    read -n 1 -s  ans
    case $ans in
        "" ) echo "pause" > $out ;;
        " " ) echo "pause" > $out ;;
        "p" ) echo "pause" > $out ;;
        "<" ) echo "seek -5" > $out ;;
        ">" ) echo "seek +5" > $out ;;
        "[" ) echo "seek -30" > $out ;;
        "]" ) echo "seek +30" > $out ;;
        "{" ) echo "seek -300" > $out ;;
        "}" ) echo "seek +300" > $out ;;
        "9" ) echo "volume -1" > $out ;;
        "0" ) echo "volume +2" > $out ;;
        "o" ) echo "osd" > $out ;;
        "v" ) echo "sub_visibility" > $out ;;
        "q" ) exit ;;
    esac
done

On desktop add to .bashrc:

alias mplco="ssh n900 /home/user/.bin/mplayer-control.sh"
blog comments powered by Disqus