Advertisement
Skedar

AsusG50vt Oled Linux

Jan 26th, 2012
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.24 KB | None | 0 0
  1. #!/bin/sh
  2.  
  3. # chkconfig: 2345 99 20
  4. # description: ASUS G50 OLED Daemon
  5. # Startup script to be installed in /etc/init.d or equivalent
  6.  
  7. ### BEGIN INIT INFO
  8. # Provides: asusg50leds
  9. # Required-Start: $syslog $local_fs $network
  10. # Required-Stop: $syslog
  11. # Should-Start:
  12. # Should-Stop:
  13. # Default-Start: 2 3 4 5
  14. # Default-Stop: 0 1 6
  15. # Short-Description: Starts asusg50leds
  16. # Description: Starts the ASUS OLED daemon
  17. ### END INIT INFO
  18.  
  19. # Get the position in lsmod of some module
  20. # @param 1 module name
  21. getModulePos()
  22. {
  23. lsmod | awk '{print $1}' | nl | grep "$1" | awk '{print $1}'
  24. }
  25.  
  26. reloadModules()
  27. {
  28. rmmod asus_oled >/dev/null
  29. rmmod usbhid
  30. modprobe asus_oled
  31. modprobe usbhid
  32. }
  33.  
  34. # Check if "asus_oled" is loaded _before_ "usbhid"
  35. checkModulesOrder(){
  36. usbhidpos=`getModulePos usbhid`
  37. asusoledpos=`getModulePos asus_oled`
  38.  
  39. if [ -z "$usbhidpos" ]; then
  40. if [ -z "$asusoledpos" ]; then
  41. modprobe asus_oled
  42. fi
  43. else
  44. if [ -z "$asusoledpos" ]; then
  45. reloadModules
  46. elif [ "$asusoledpos" -lt "$usbhidpos" ]; then
  47. reloadModules
  48. fi
  49. fi
  50. }
  51.  
  52. # Check if the kernel version requires re-arranging of the modules order
  53. # @return 0 if it is not required, 1 is re-arranging is required
  54. checkKernelVersion(){
  55. kernelversion=`uname -r`
  56.  
  57. MAJ=`echo "$kernelversion" | awk -F'[-._]' '{print $1}'`
  58. MIN=`echo "$kernelversion" | awk -F'[-._]' '{print $2}'`
  59. REL=`echo "$kernelversion" | awk -F'[-._]' '{print $3}'`
  60.  
  61. VER=$((MAJ*1000000+MIN*1000+REL))
  62.  
  63. # if before 2.6.28 return 1 else return 0
  64. if [ $VER -lt 2006028 ]; then
  65. if [ $VER -lt 2006027 ]; then
  66. echo "***"
  67. echo "*** You should upgrade the kernel to at least 2.6.27 to take full benefit of the Asus G50/G70 hardware"
  68. echo "***"
  69. fi
  70.  
  71. return 1
  72. fi
  73.  
  74. return 0
  75. }
  76.  
  77. case "$1" in
  78. start|restart)
  79. checkKernelVersion || checkModulesOrder
  80.  
  81. # By default the value there is 0 although the led is lit
  82. echo 1 > "/sys/class/leds/asus::touchpad/brightness" 2>/dev/null
  83.  
  84. /opt/leds/start.sh &
  85. ;;
  86. stop)
  87. /opt/leds/stop.sh
  88. ;;
  89. *)
  90. N=/etc/init.d/${0##*/}
  91. echo "Usage: $N {start|stop|restart}"
  92. exit 1
  93. ;;
  94. esac
  95.  
  96. exit 0
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement