mplayershell 3.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. #!/bin/sh
  2. #BK try fix some problems with running mplayer and gmplayer.
  3. #100821 BK: improve DVD detection.
  4. #101007 test for 16-bit color depth. no, removed.
  5. #101218 fixes.
  6. #130301 exact determination of running xorg driver.
  7. #130301 turn off screen blanking.
  8. ##101007 test color depth...
  9. #COLORDEPTH="`xwininfo -root | grep -o 'Depth: [0-9][0-9]' | rev | cut -f 1 -d ' ' | rev`"
  10. #if [ "$COLORDEPTH" = "16" ];then
  11. # yaf-splash -close box -bg pink -placement center -text "NOTICE: the display color depth is set to 16 bits. Mplayer requires 24-bit depth to work. You will need to run the Xorg Wizard again. (sorry about that, lobby the mplayer developers if you are unhappy about this restriction)" &
  12. #fi
  13. MYVIDOUT="-vo xv"
  14. [ "`readlink /usr/bin/X`" = "Xvesa" ] && MYVIDOUT="-vo x11" #101218
  15. #130301 exact determination of running xorg driver...
  16. #[ -f /etc/X11/xorg.conf ] && [ "`grep 'card0driver' /etc/X11/xorg.conf | grep '"vesa"'`" != "" ] && MYVIDOUT="-vo x11"
  17. VIDEODRIVER='vesa'
  18. if [ "`readlink /usr/bin/X`" = "Xorg" ];then
  19. #xorg.conf does not necessarily tell us what driver is loaded.
  20. #got this code from /usr/sbin/report-video...
  21. LOADED="$(grep 'Loading .*/xorg/modules/drivers/.*_drv.so' /var/log/Xorg.0.log | rev | cut -f 1 -d '/' | rev | cut -f 1 -d '_' | tr '\n' ' ')"
  22. for ALOADED in $LOADED
  23. do
  24. aPTN="UnloadModule: \"$ALOADED\""
  25. bPTN="LoadModule: \"$ALOADED\""
  26. CNTload=`grep "$bPTN" /var/log/Xorg.0.log | wc -l`
  27. CNTunload=`grep "$aPTN" /var/log/Xorg.0.log | wc -l`
  28. [ $CNTload -eq 0 ] && continue
  29. [ $CNTunload -ge $CNTload ] && continue
  30. VIDEODRIVER="$ALOADED"
  31. break
  32. done
  33. fi
  34. case $VIDEODRIVER in
  35. vesa) MYVIDOUT="-vo x11"
  36. esac
  37. PREFGUI="gmplayer"
  38. #[ "`which gimv`" != "" ] && PREFGUI="gimv"
  39. #if a specific file passed, play that...
  40. if [ "${1}" ];then #101218 need quotes if passed param has spaces (rox passes $1 in quotes).
  41. [ "$PREFGUI" = "gimv" ] && exec gimv "$@"
  42. #exec gmplayer -really-quiet $MYVIDOUT "$@"
  43. xset s off -dpms #130301
  44. nohup gmplayer -really-quiet $MYVIDOUT "$@" &
  45. xset s on #130301
  46. exit
  47. fi
  48. #100821 detect if a dvd inserted (code similar in /usr/local/bin/drive_all)...
  49. if [ -e /dev/dvd ];then
  50. if [ "`cddetect -d/dev/dvd | grep -E 'no disc|tray open'`" = "" ];then
  51. ONEDRVNAME="`readlink /dev/dvd | rev | cut -f 1 -d '/' | rev`"
  52. dPATTERN='^/dev/'"$ONEDRVNAME"' '
  53. if [ "`df | grep "$dPATTERN"`" = "" ];then #only test if not mounted.
  54. FLAGDVDVIDEO="`dvd+rw-mediainfo /dev/${ONEDRVNAME} | grep 'Mounted Media: .* DVD-ROM'`"
  55. if [ "$FLAGDVDVIDEO" = "" ];then
  56. #mount and look for 'video_ts' directory (dir should contain file video_ts.ifo)...
  57. mkdir -p /mnt/${ONEDRVNAME}
  58. mount -t iso9660 /dev/${ONEDRVNAME} /mnt/${ONEDRVNAME}
  59. if [ $? -eq 0 ];then
  60. [ -d /mnt/${ONEDRVNAME}/video_ts -o -d /mnt/${ONEDRVNAME}/VIDEO_TS ] && FLAGDVDVIDEO="yes"
  61. umount /mnt/${ONEDRVNAME}
  62. fi
  63. fi
  64. if [ "$FLAGDVDVIDEO" != "" ];then
  65. [ -f /usr/local/bin/defaultdvdplayer ] && exec defaultdvdplayer
  66. xset s off -dpms #130301
  67. nohup gmplayer $MYVIDOUT dvdnav:// &
  68. xset s on #130301
  69. exit
  70. fi
  71. fi
  72. fi
  73. fi
  74. #CDTYPE1="`cddetect -d/dev/dvd | grep 'cdtype: audio'`"
  75. #CDTYPE2="`cddetect -d/dev/cdrom | grep 'cdtype: audio'`"
  76. #[ "$CDTYPE1" != "" ] && exec gmplayer $MYVIDOUT
  77. #fall down...
  78. #exec gmplayer -really-quiet $MYVIDOUT
  79. xset s off -dpms #130301
  80. nohup gmplayer -really-quiet $MYVIDOUT &
  81. xset s on #130301
  82. ###END###