Advertisement
Guest User

Untitled

a guest
May 27th, 2016
173
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.77 KB | None | 0 0
  1. #/bin/sh
  2.  
  3. # This script monitors if a dvb device's frontend is opened by VDR.
  4. # Can be used with a single tuner or with two tuners.
  5. # Output:
  6. #  1  - adapter 0 is on
  7. #  2  - adapter 1 is on
  8. #  3  - both are on
  9. #  -  - both are off
  10. #  .  - VDR is not running
  11.  
  12. # VDR executable. Change to vdr.bin for OpenELEC.
  13. VDR=vdr
  14.  
  15. while true; do
  16.     vdrpid=$(pidof $VDR)
  17.     if [ -z "$vdrpid" ]; then
  18.         printf '.'
  19.     else
  20.         mask=0
  21.         for adapter in 0 1; do
  22.             if sudo lsof -p $vdrpid 2>/dev/null | grep -q "adapter$adapter/frontend"; then
  23.                 mask=$(($mask + $adapter + 1))
  24.             fi
  25.         done
  26.         if [ $mask -eq 0 ]; then
  27.             printf '-'
  28.         else
  29.             printf $mask
  30.         fi
  31.     fi
  32.     sleep 1
  33. done
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement