Advertisement
sbicknel

Bash Medley Grid Video Player Improved

Sep 28th, 2014
21
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 19.79 KB | None | 0 0
  1. #!/bin/bash -
  2.  
  3. # vim: set tabstop=8 softtabstop=4 shiftwidth=4 smarttab noexpandtab:
  4.  
  5. ${DEBUG}
  6.  
  7. #========================================================================
  8. #          FILE:  medley
  9. #
  10. #         USAGE:  medley [-h|--help][-V|--version]|-a ASPECT -w WIDTH
  11. #            -n NUMBER -f -s FILENAME [FILENAME...]
  12. #         --help    display program help and exit
  13. #
  14. #         -a ASPECT aspect ratio of videos. Valid values for
  15. #                   ASPECT are cinema|hdtv|widescreen|standard.
  16. #                   Default is standard.
  17. #         -w WIDTH  width of video viewport. Cannot be used with
  18. #                   -f.
  19. #         -n NUMBER number of viewports in a row. Valid values
  20. #                   for NUMBER are 1-3. Default is 4.
  21. #         -f        turn off fullscreen view when playing a list
  22. #                   of videos sequentially. Cannot be used with
  23. #                   -w.
  24. #         -s        do not shuffle FILENAMEs.
  25. #         -u
  26. #         --usage   display a usage message and exit
  27. #  
  28. #         -V
  29. #         --version display the program version number and exit
  30. #         -x        display debugging information
  31. #
  32. #   DESCRIPTION:  play a medley of videos simultaneously
  33. #
  34. #       OPTIONS:  --help, --version
  35. #  REQUIREMENTS:  ---
  36. #          BUGS:  ---
  37. #         NOTES:  ---
  38. #        AUTHOR:  Scott Bicknell (SB), [email protected]
  39. #       COMPANY:  
  40. #       VERSION:  1.0
  41. #       CREATED:  
  42. #      REVISION:  ---
  43. #
  44. # Copyright 2010 Scott Bicknell, sbicknel (at) gmail dot com
  45. #
  46. # This program is free software: you can redistribute it and/or modify
  47. # it under the terms of the GNU General Public License as published by
  48. # the Free Software Foundation, either version 3 of the License, or
  49. # (at your option) any later version.
  50. #
  51. # This program is distributed in the hope that it will be useful,
  52. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  53. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  54. # GNU General Public License for more details.
  55. #
  56. # You should have received a copy of the GNU General Public License
  57. # along with this program.  If not, see <http://www.gnu.org/licenses/>.
  58. #========================================================================
  59.  
  60.  
  61. PROGNAME=${0##*/}
  62. VERSION='2.0'
  63. PATH="${HOME}/bin:/bin:/usr/bin:/usr/local/bin"
  64. umask 077
  65.  
  66. # -----------------------------------------------------------------------
  67. # Display error messages on standard error.
  68. # -----------------------------------------------------------------------
  69. function error () {
  70.     printf '%s: %s\n' $PROGNAME "$@"
  71. } >&2
  72.  
  73.  
  74. # -----------------------------------------------------------------------
  75. # Display warning messages on standard output.
  76. # -----------------------------------------------------------------------
  77. warning () {
  78.     printf '%s: %s\n' $PROGNAME "$@"
  79. }
  80.  
  81. # -----------------------------------------------------------------------
  82. # Display messages on standard output.
  83. # -----------------------------------------------------------------------
  84. function message () {
  85.     printf '%s: %s\n' $PROGNAME "$@"
  86. }
  87.  
  88.  
  89. # -----------------------------------------------------------------------
  90. # Function for exit due to fatal program error
  91. #   Accepts 1 argument:
  92. #       string containing descriptive error message
  93. # -----------------------------------------------------------------------
  94. function error_exit () {
  95.     error "${1:-'Unknown Error'}"
  96.     exit 1
  97. }
  98.  
  99.  
  100. # -----------------------------------------------------------------------
  101. # Function to handle termination signals
  102. #   Accepts 1 argument:
  103. #       signal_spec
  104. # -----------------------------------------------------------------------
  105. function signal_exit () {
  106.     case $1 in
  107.    
  108.     INT)
  109.         error_exit 'Program aborted by user'
  110.     ;;
  111.  
  112.     TERM)
  113.         error_exit 'Program terminated'
  114.     ;;
  115.  
  116.     *)
  117.         error_exit 'Terminating on unknown signal'
  118.     ;;
  119.  
  120.     esac
  121. }
  122.  
  123. trap 'signal_exit TERM' TERM HUP QUIT PIPE
  124. trap 'signal_exit INT'  INT
  125.  
  126.  
  127. # -----------------------------------------------------------------------
  128. # Function called for a graceful exit
  129. #   No arguments
  130. # -----------------------------------------------------------------------
  131. function graceful_exit () {
  132.     exit
  133. }
  134.  
  135.  
  136. # -----------------------------------------------------------------------
  137. # Simulate user activity to inhibit the screensaver
  138. # -----------------------------------------------------------------------
  139. function inhibit_screensaver () {
  140.     qdbus org.freedesktop.ScreenSaver /ScreenSaver SimulateUserActivity
  141. } &>/dev/null
  142.  
  143.  
  144. # -----------------------------------------------------------------------
  145. # Set player variable
  146. # -----------------------------------------------------------------------
  147. set_player () {
  148.     if [[ -n "$player" ]]; then
  149.     return 0
  150.     fi
  151.     if ! type -P mplayer2 &>/dev/null && ! type -P mplayer &>/dev/null; then
  152.     error_exit 'mplayer or mplayer2 is required'
  153.     fi
  154.     if type -P mplayer2 &>/dev/null; then
  155.     player=mplayer2
  156.     elif type -P mplayer &>/dev/null; then
  157.     player=mplayer
  158.     fi
  159. }
  160.  
  161.  
  162. # -----------------------------------------------------------------------
  163. # Display a short message about program usage. This is also used by the
  164. # helptext function to display part of its help text.
  165. # -----------------------------------------------------------------------
  166. function usage () {
  167.     cat <<- EOF
  168.    
  169. USAGE: $PROGNAME: [-a standard|cinema|hdtv|widescreen][-f][-s][-n NUM|-w NUM]|[-h|--help]
  170.                   [-u|--usage][-V|--version]|[-x] FILE [FILE...]
  171. EOF
  172. }
  173.  
  174.  
  175. # -----------------------------------------------------------------------
  176. # Display the program version number
  177. # -----------------------------------------------------------------------
  178. function version () {
  179.     printf '%s %s\n' $PROGNAME $VERSION
  180. }
  181.  
  182.  
  183. # -----------------------------------------------------------------------
  184. # Function to display help message for program
  185. #   No arguments
  186. # -----------------------------------------------------------------------
  187. function helptext () {
  188.     local tab=$(printf '\t\t')
  189.  
  190.     usage
  191.     cat << -EOF-
  192.  
  193.  
  194. DESCRIPTION:
  195.  
  196. Play a medley of videos simultaneously. By default, each video is scaled to fit
  197. in a row four viewports wide. The script fills the display with as many windows
  198. as it can and tiles them in a grid. As each video finishes playing another
  199. video fills the same location in the on-screen grid. The videos are played in
  200. random order by default if shuf is installed.
  201.  
  202.  
  203. Options:
  204.  
  205. -a ASPECT   Aspect ratio. This option affects vertical spacing of viewports
  206.                 in the on-screen grid. Valid names are standard, cinema, hdtv,
  207.         and widescreen. Default is 'standard'.
  208.         Name       | Meaning
  209.         --------------------
  210.         standard   |     4:3
  211.         cinema     |    16:9
  212.         hdtv       |  1.85:1
  213.         widescreen |  2.35:1
  214. -f      Turn off fullscreen mode when playing videos one at a time.
  215.         Disables -w. Must be used with -n 1.
  216. -s      Do not shuffle play list.  Ignored if shuf not installed
  217.  
  218. -h, --help  Display this help message and exit.
  219. -u, --usage Display a usage message and exit.
  220. -V, --version   Display program version and exit.
  221.  
  222. -w PIXELS       Width of a video viewport. This option affects how many
  223.                 videos are placed in a row and may affect how may rows
  224.         are placed in the grid. Default creates a row of four
  225.         videos and sizes the viewports to fit the width of the
  226.         display. Cannot be used with -n.
  227. -n NUMBER   Number of windows in a row. Cannot be used with -w. Valid
  228.         values are 1 to 3. If NUMBER is 1, -f may be used.
  229. -x      Display debugging output when running the program
  230.  
  231. This program requires mplayer or mplayer2.  Unsort is optional.
  232.  
  233.  
  234. -EOF-
  235.     version
  236. }
  237.  
  238. # -----------------------------------------------------------------------
  239. # Verify that the usage function and the helptext function both have
  240. # documentation for each long option. Verify that the header comment
  241. # also has each long option listed.
  242. # -----------------------------------------------------------------------
  243. if [[ "$1" == '--help' ]]; then
  244.     helptext
  245.     graceful_exit
  246. fi
  247. if [[ "$1" == '--version' ]]; then
  248.     version
  249.     graceful_exit
  250. fi
  251. if [[ "$1" == '--usage' ]]; then
  252.     usage
  253.     graceful_exit
  254. fi
  255.  
  256. # information about the current desktop from wmctrl
  257. if wmctrl -d &>/dev/null; then
  258.     desktopInfo=$(wmctrl -d | grep '^[0-9]* *\*')   # target the current desktop
  259.     dimensions=$(awk '{print $4}' <<< $desktopInfo) # display dimensions
  260.     waDimensions=$(awk '{print $9}' <<< $desktopInfo)   # work area dimensions
  261.     waWidth=${waDimensions%x*}              # width of work area in pixels
  262.     waHeight=${waDimensions#*x}             # height of work area in pixels
  263.     waOrigin=$(awk '{print $8}' <<< $desktopInfo)   # X,Y origin of work area
  264.  
  265. # information about the current display if wmctrl fails
  266. else
  267.     dimensions=$(xdpyinfo | awk '/dimensions/ {print $2}')  # display dimensions
  268.     waDimensions=$dimensions                    # work area dimensions
  269.     waWidth=$(( ${waDimensions%x*} - 50 ))          # width of work area in pixels
  270.     waHeight=$(( ${waDimensions#*x} - 50 ))         # height of work area in pixels
  271.     waOrigin='0,0'
  272.    
  273. fi
  274. dwidth=${dimensions%x*}     # width of display in pixels
  275. dheight=${dimensions#*x}    # height of display in pixels
  276. waX=${waOrigin%,*}      # X origin of work area
  277. waY=${waOrigin#*,}      # Y origin of work area
  278. unset dimensions
  279. unset waDimensions
  280. unset waOrigin
  281.  
  282. # default width of a video window
  283. maxGridHeight=$waHeight
  284. defaultWidth=$(echo "scale=2; $maxGridHeight / 3 * 4 / 3 " | bc | sed 's/...$//')
  285.  
  286. # mplayer/mplayer2 calling syntax differences
  287. declare -A id
  288. declare -A fd
  289. declare -A asp
  290. id[mplayer]='-identify '
  291. fd[mplayer]='-framedrop'
  292. asp[mplayer]='-aspect '
  293. id[mplayer2]='--identify='
  294. fd[mplayer2]='--framedrop'
  295. asp[mplayer2]='--aspect='
  296.  
  297. # ratios
  298. st='4:3'    # standard
  299. ci='16:9'   # cinema
  300. hd='1.85:1' # hdtv
  301. wi='64:27'  # widescreen
  302.  
  303. # -----------------------------------------------------------------------
  304. # Verify that the usage function and the helptext function both have
  305. # documentation for each short option. Verify that the header comment
  306. # also has each short option listed in the usage section.
  307. # -----------------------------------------------------------------------
  308. while getopts :a:fhn:suVw:x opt; do
  309.     case $opt in
  310.  
  311.     a) # aspect ratio
  312.         set_player
  313.         aspect=${asp[$player]}
  314.         case ${OPTARG,,} in
  315.  
  316.         standard)
  317.             aspect=${aspect}$st
  318.             aspRatio=${OPTARG,,}
  319.             ;;
  320.  
  321.         cinema)
  322.             aspect=${aspect}$ci
  323.             aspRatio=${OPTARG,,}
  324.             ;;
  325.  
  326.         hdtv)
  327.             aspect=${aspect}$hd
  328.             aspRatio=${OPTARG,,}
  329.             ;;
  330.  
  331.         widescreen)
  332.             aspect=${aspect}$wi
  333.             aspRatio=${OPTARG,,}
  334.             ;;
  335.  
  336.         *)
  337.             message "$OPTARG: unsupported aspect ratio. Setting aspect ratio to standard"
  338.             aspect=${aspect}$st
  339.             aspRatio=standard
  340.             ;;
  341.  
  342.         esac
  343.         ;;
  344.  
  345.     h) # help
  346.         helptext
  347.         graceful_exit
  348.         ;;
  349.  
  350.     f) # turn off fullscreen when playing videos one at a time
  351.         full=no
  352.         width=$(( $waWidth / 2 + 1 ))
  353.         ;;
  354.  
  355.     n) # number of windows in a grid row
  356.         case ${OPTARG} in
  357.  
  358.         *[!0-9]*)
  359.             message "$OPTARG: must be a number of windows. Setting number of windows to default"
  360.             width=$defaultWidth
  361.             ;;
  362.  
  363.         [1-3])
  364.             width=$(( $waWidth / $(( $OPTARG + 1 )) + 1 ))
  365.             ;;
  366.  
  367.         *)
  368.             message "$OPTARG: must be a number from 1 to 3. Setting number of windows to default"
  369.             width=$defaultWidth
  370.             ;;
  371.         esac
  372.         ;;
  373.  
  374.     s) # do not shuffle videos
  375.         unsort=no
  376.         ;;
  377.  
  378.     u) # usage
  379.         usage
  380.         graceful_exit
  381.         ;;
  382.    
  383.     V) # version
  384.         version
  385.         graceful_exit
  386.         ;;
  387.  
  388.     w) # width of a video window
  389.  
  390.         case $OPTARG in
  391.  
  392.         *[!0-9]*)
  393.             message "$OPTARG: video width must be a number. Setting width to $defaultWidth"
  394.             width=$defaultWidth
  395.             ;;
  396.  
  397.         esac
  398.         width=${width:-$OPTARG}
  399.         if [[ $width -gt $waWidth ]]; then
  400.         message "-w: width cannot exceed $dwidth. Setting width to $defaultWidth"
  401.         width=$defaultWidth
  402.         fi
  403.         ;;
  404.  
  405.     x)  # set debugging output on a per-run basis. The $DEBUG
  406.         # environment variable will enable degugging output at
  407.         # the top of the script.
  408.         set -x
  409.         ;;
  410.  
  411.     :)  # process missing required parameters
  412.         case $OPTARG in
  413.         a) error_exit "-$OPTARG: required argument missing: standard, cinema, hdtv, or widescreen expected";;
  414.         n) error_exit "-$OPTARG: required argument missing: 1, 2 or 3 expected";;
  415.         w) error_exit "-$OPTARG: required argument missing: pixel width of a single video expected (e.g. 300)";;
  416.         *) error_exit "-$OPTARG: required argument missing";;
  417.         esac
  418.         ;;
  419.  
  420.     *)  # process unknown options
  421.         usage
  422.         error_exit "Unknown option: -$OPTARG"
  423.         ;;
  424.  
  425.     esac
  426. done
  427. shift $(( $OPTIND - 1 ))
  428.  
  429. if [[ $# -eq 0 ]]; then
  430.     error_exit 'nothing to play'
  431. fi
  432. set_player
  433. killall $player &>/dev/null
  434.  
  435. # if aspect is not set, try to determine aspect ratio from folder name
  436. if [[ -z "$aspect" ]]; then
  437.     case ${PWD##*/} in
  438.     standard|cinema|hdtv|widescreen)
  439.         aspRatio=${PWD##*/}
  440.         aspect=${asp[$player]}
  441.         case $aspRatio in
  442.  
  443.         standard)
  444.             aspect=${aspect}$st
  445.             ;;
  446.  
  447.         cinema)
  448.             aspect=${aspect}$ci
  449.             ;;
  450.  
  451.         hdtv)
  452.             aspect=${aspect}$hd
  453.             ;;
  454.  
  455.         widescreen)
  456.             aspect=${aspect}$wi
  457.             ;;
  458.  
  459.         esac
  460.         ;;
  461.     esac
  462. fi
  463.  
  464. width=${width:-$defaultWidth}                   # width of a video window
  465. case $width in
  466.  
  467.     *[!0-9]*)
  468.     message "$OPTARG: video width must be a number. Setting width to $defaultWidth pixels."
  469.     width=$defaultWidth
  470.     ;;
  471. esac
  472.  
  473. # height of a video window
  474. aspRatio=${aspRatio:-standard}
  475. aspRatio=${aspRatio,,}
  476. case $aspRatio in
  477.      standard) height=$(echo "scale=2; $width /  4 *  3"  | bc | sed 's/...$//');;
  478.        cinema) height=$(echo "scale=2; $width / 16 *  9"  | bc | sed 's/...$//');;
  479.          hdtv) height=$(echo "scale=2; $width /    1.85"  | bc | sed 's/...$//');;
  480.    widescreen) height=$(echo "scale=2; $width / 64 * 27"  | bc | sed 's/...$//');;
  481.             *)
  482.         message 'unsupported aspect ratio. Using standard aspect ratio to set height'
  483.         height=$(echo "scale=2; $width / 4 *  3"  | bc | sed 's/...$//')
  484.         ;;
  485. esac  
  486. unset aspRatio
  487. maxxp=$(( $waX + $waWidth - $width ))   # maximum horizontal window position
  488.  
  489. # window dimensions of the entire grid
  490. maxWWide=$(( $waWidth / $width ))   # maximum windows wide
  491. maxWHigh=$(( $waHeight  / $height ))    # maximum windows high
  492. numWindows=$(( $maxWWide * $maxWHigh )) # number of windows in a grid
  493.  
  494. # pixel dimensions of the entire grid
  495. gridWidth=$(( $maxWWide * $width ))
  496. gridHeight=$(( $maxWHigh * $height ))
  497. unset maxWWide
  498. unset maxWHigh
  499.  
  500. # screen coordinates of first video window
  501. xstart=$(( $waX + ( ( $waWidth  - $gridWidth  ) / 2 ) ))    # initial horizontal window position
  502. ystart=$(( $waY + ( ( $waHeight - $gridHeight ) / 2 ) ))    # initial vertical window position
  503. x=$xstart                           # horizontal window position
  504. y=$ystart                           # vertical window position
  505. unset dwidth
  506. unset waWidth
  507. unset dheight
  508. unset waHeight
  509. unset ystart
  510. unset waX
  511. unset waY
  512.  
  513. # make a list of all window positions
  514. for (( w=1; w<=$numWindows; w++ )); do
  515.     window[$w]="$x:$y"
  516.     x=$(( $x + $width ))
  517.     if [[ $x -gt $maxxp ]]; then
  518.     x=$xstart
  519.     y=$(( $y + $height ))
  520.     fi
  521. done
  522. unset height
  523. unset maxxp
  524. unset xstart
  525. unset x
  526. unset y
  527.  
  528. # set fullscreen mode if only one window position in list
  529. declare -A fs
  530. if [[ ${#window[@]} -eq 1 ]] && [[ ${full:-yes} == yes ]]; then
  531.     fs[mplayer2]='--fs'
  532.     fs[mplayer]='-fs'
  533. fi
  534.  
  535. unset COLUMNS   # This setting prevents some data from reaching grep
  536.  
  537. v=0 # video list index
  538.  
  539. # create an indexed list of video files, skipping files not recognized as videos
  540. # explicite index assignment is necessary to prevent word splitting on spaces
  541. for f in "$@"; do
  542.     if ! [[ -f "$f" ]] ||
  543.     ! [[ $(file --mime-type -b "$f" | awk -F/ '{print $1}') == 'video' ]] &&
  544.     ! [[ $(file --mime-type -b "$f" | awk -F/ '{print $2}') == 'ogg'   ]]; then
  545.     warning "Video file not recognized. $f: $(file --mime-type -b \"$f\")"
  546.    
  547.     # ensures that the number of parameters equals the number of valid video files
  548.     # we can throw away parameters because we are storing valid ones in flist
  549.     shift
  550.     continue
  551.     fi
  552.     flist[$v]="$f"
  553.     (( v++ ))
  554. done
  555.  
  556. # create a list of video files in input order if shuf is not installed
  557. if ! type -P shuf &>/dev/null || [[ ${unsort:-yes} == no ]]; then
  558.     rlist=( "${flist[@]}" )
  559.  
  560. # create a random list of video files otherwise
  561. else
  562.     v=0
  563.  
  564.     # create a random list of indexes ($rn) for each video file in $flist
  565.     # $rn is our random list of indexes into $flist
  566.     rn=( $(for (( r=0; r<${#flist[@]}; r++ )); do
  567.     echo $r
  568.     done | sed 's/ /\n/g' | shuf 2>/dev/null) )
  569.  
  570.     # this random list is used to store video file names from random
  571.     # index locations in $flist to sequential locations in $rlist
  572.     for r in ${rn[@]}; do
  573.     rlist[$v]="${flist[$r]}"
  574.     (( v++ ))
  575.     done
  576. fi
  577. unset v
  578. unset flist
  579.  
  580. if [[ ${#rlist[@]} -eq 0 ]]; then
  581.     message 'video detection failed. Try: file --mime-type -b FILE'
  582.     error_exit 'no video files in file list'
  583. fi
  584.  
  585. # set fullscreen mode if only one video in list
  586. if [[ ${#rlist[@]} -eq 1 ]] && [[ ${full:-yes} == yes ]]; then
  587.     fs[mplayer2]='--fs'
  588.     fs[mplayer]='-fs'
  589. fi
  590.  
  591. # video format ratios
  592. WIDESCREEN=$(echo "scale=2; 64 / 27 * 100" | bc | sed -e 's/...$//')
  593. HDTV=$(      echo "scale=2;    1.85 * 100" | bc | sed -e 's/...$//')
  594. CINEMA=$(    echo "scale=2;  16 / 9 * 100" | bc | sed -e 's/...$//')
  595. STANDARD=$(  echo "scale=2;   4 / 3 * 100" | bc | sed -e 's/...$//')
  596.  
  597. rindex=0              # index into rlist
  598. started=0             # number of videos started in previous check
  599.  
  600. # delay between checks for empty slots.  Longer delays when playing more
  601. # videos; shorter delays when more cpu cores are installed.
  602. numProc=$(grep '^processor' /proc/cpuinfo | wc -l)
  603. [[ $numProc -lt 2 ]] && numProc=2
  604. delay=$(( $numWindows / $(( $numProc / 2 )) ))
  605. [[ $delay -lt 1 ]] && delay=1
  606.  
  607. # play each video in an empty slot. Shift each file name off the list as each video is played.
  608. while [[ $# -gt 0 ]]; do
  609.  
  610.     inhibit_screensaver
  611.  
  612.     # if all slots are filled with videos, sleep and skip further processing
  613.     if [[ $(ps aux | grep 'mplayer.*noborder.*zoom.*xy.*geometry.*' | grep -v grep | wc -l) -eq $numWindows ]]; then
  614.     if [[ $started -gt 0 ]]; then
  615.         sleep $(( $delay - 1 ))s
  616.         started=0
  617.     else
  618.         sleep ${delay}s
  619.     fi
  620.     continue
  621.     fi
  622.     started=0
  623.    
  624.     # fill empty slots with videos
  625.     for slot in ${window[@]}; do
  626.         if ! ps aux | grep "geometry $slot " | grep -vq grep; then
  627.  
  628.         # quit here if at end of file list
  629.         if [[ $# -eq 0 ]]; then
  630.         break
  631.         fi
  632.  
  633.         # get dimensions of video
  634.         widthDim=$($player -frames 0 ${id[$player]} ${rlist[$rindex]} 2>/dev/null | awk -F=  '/^ID_VIDEO_WIDTH/ {print $2}' 2>/dev/null)
  635.         heightDim=$($player -frames 0 ${id[$player]} ${rlist[$rindex]} 2>/dev/null | awk -F=  '/^ID_VIDEO_HEIGHT/ {print $2}' 2>/dev/null)
  636.  
  637.         # compute format ratio
  638.         format=$(echo "scale=2; $widthDim / $heightDim * 100" | bc | sed -e 's/...$//')
  639.  
  640.         # set aspect ratio for each video
  641.         aspect=${asp[$player]}
  642.         if [[ "$format" -ge "$WIDESCREEN" ]]; then
  643.         aspect=${aspect}$wi
  644.         elif [[ "$format" -ge "$HDTV" ]]; then
  645.         aspect=${aspect}$hd
  646.         elif [[ "$format" -ge "$CINEMA" ]]; then
  647.         aspect=${aspect}$ci
  648.         else
  649.         aspect=${aspect}$st
  650.         fi
  651.         $player ${fd[$player]} $aspect -noborder -zoom ${fs[$player]} -xy $width -geometry "$slot" "${rlist[$rindex]}" &>/dev/null &
  652.         unset rlist[$rindex]
  653.         (( started++ ))
  654.         (( rindex++ ))
  655.         sleep 1s
  656.             shift
  657.         fi
  658.     done
  659. done
  660.  
  661. # inhibit the screensaver until the last video ends
  662. while ps aux | grep 'mplayer.*noborder.*zoom.*xy.*geometry.*' | grep -vq grep; do
  663.     sleep $delay
  664.     inhibit_screensaver
  665. done
  666.  
  667. graceful_exit
  668.  
  669. This version removes dependency on unsort and should work in most desktop environments, not just KDE.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement