Advertisement
Guest User

Untitled

a guest
Jul 24th, 2011
354
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.51 KB | None | 0 0
  1. #!/bin/sh
  2.  
  3. fullPage=6 # How many pages before a full refresh?
  4.  
  5. ### Do not edit below this line unless you know what you are doing ###
  6.  
  7. read cvmPid < /var/run/cvm.pid
  8. pCount=0
  9. fullPage="$(($fullPage-1))"
  10.  
  11. trap "echo 0 > /sys/devices/platform/eink_fb.0/override_upd_mode ; echo 19 0 > /proc/eink_fb/update_display ; rm /var/run/flashdis.pid ; exit" SIGINT SIGTERM
  12.  
  13. if [[ ! -e "/var/run/flashdis.pid" ]]; then
  14.     echo $$ > "/var/run/flashdis.pid"
  15. else
  16.     echo "Flash disabler is already running"
  17.     exit 1
  18. fi
  19.  
  20. update() {
  21.     let pCount+=1
  22.     ## Do a bunch of refreshes
  23.     for i in 1 2 3 4 5 ; do
  24.         echo 19 0 > /proc/eink_fb/update_display
  25.         echo 0 > /sys/devices/platform/eink_fb.0/override_upd_mode
  26.         echo 18 0 > /proc/eink_fb/update_display
  27.         echo 1 > /sys/devices/platform/eink_fb.0/override_upd_mode
  28.         echo 19 4 > /proc/eink_fb/update_display
  29.         usleep 75000
  30.     done
  31.    
  32.     ## Sets the next page turn to be a full refresh
  33.     if [[ "$pCount" -ge "$fullPage" ]]; then
  34.         echo 0 > /sys/devices/platform/eink_fb.0/override_upd_mode
  35.         echo 19 0 > /proc/eink_fb/update_display
  36.         pCount=0
  37.     fi 
  38. }
  39.  
  40. bookCheck() {
  41.     ## Check if cvm has a open file descriptor for a file in /mnt/us/documents/
  42.     if [[ "$(realpath /proc/$cvmPid/fd/* 2> /dev/null | grep -c /mnt/us/documents/)" != "0" ]]; then
  43.         update
  44.     else
  45.         echo 0 > /sys/devices/platform/eink_fb.0/override_upd_mode
  46.         echo 19 0 > /proc/eink_fb/update_display
  47.     fi
  48. }
  49.  
  50. ## Wait for page turn
  51. while :; do
  52.     case "$(waitforkey)" in
  53.         191*|109*|104*|193*)
  54.             bookCheck
  55.         ;;
  56.     esac
  57. done
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement