Guest User

WiFi - /sys/class/rfkill/rfkill0/state 0-выключено 1-включен

a guest
Jun 24th, 2011
392
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 2.06 KB | None | 0 0
  1. #!/bin/sh
  2. FUNC_LIB=/etc/acpi/functions.sh
  3. DEFAULT=/etc/default/$PKG
  4. WLAN_IF=wlan0
  5. # для корректной работы synclient требуется $DISPLAY, решение "в лоб":
  6. export DISPLAY=:0.0
  7. [ -e $FUNC_LIB ] || exit 0
  8.  
  9. #if [ -e "$DEFAULT" ]; then . "$DEFAULT"; fi
  10. . $FUNC_LIB
  11.  
  12. code=$3
  13. wireless_toggle(){
  14. CTL=/sys/class/rfkill/rfkill0/state
  15.  
  16.     if [ -e $CTL ]; then
  17.         toggle
  18.     else
  19.         notify error 'Wifi unavailable'
  20.     fi
  21. }
  22. handle_blank_screen() {
  23.     if [ -S /tmp/.X11-unix/X0 ]; then
  24.         detect_x_display
  25.  
  26.         if [ -n "$XAUTHORITY" ]; then
  27.             xset dpms force off
  28.         fi
  29.     fi
  30. }
  31. is_on()
  32.  {
  33.      if [ -e $CTL ]; then
  34.          [ $( cat $CTL ) = "1" ]
  35.      else
  36.          false
  37.      fi
  38.  }
  39. toggle()
  40.  {
  41.      if is_on; then
  42.          echo 0 > $CTL
  43.      else
  44.          if [ -e $CTL ]; then
  45.              echo 1 > $CTL
  46.          fi
  47.      fi
  48. }
  49. handle_camera_toggle() {
  50. CTL=/sys/devices/platform/eeepc/camera
  51. [ -e $CTL ] || CTL=/proc/acpi/asus/camera #pre-2.6.26
  52.  
  53.     if [ -e $CTL ]; then
  54.         toggle
  55.     fi
  56. }
  57. cardr_toggle() {
  58. CTL=/sys/devices/platform/eeepc/cardr
  59.  
  60.     if [ -e $CTL ]; then
  61.         toggle
  62.     fi
  63. }
  64. touchpad_toggle(){
  65. if(/usr/bin/synclient -l | grep -e "TouchpadOff" | grep -e "0" > /dev/null) ; th
  66. en
  67. /usr/bin/synclient TouchpadOff=1
  68. else
  69. /usr/bin/synclient TouchpadOff=0
  70. fi
  71. }
  72. case $code in
  73.     00000013)
  74.         /etc/acpi/actions/volume.sh toggle
  75.         ;;
  76.     00000014)
  77.          /etc/acpi/actions/volume.sh down
  78.         ;;
  79.     00000015)
  80.          /etc/acpi/actions/volume.sh up
  81.         ;;
  82. # Fn+F2 -- toggle wireless
  83.     00000010)
  84.         wireless_toggle
  85.         ;;
  86. #    0000003[012])
  87. #        /etc/acpi/actions/vga-toggle.sh
  88. #        ;;
  89.     0000001a)
  90.           handle_blank_screen
  91.         ;;
  92.     00000016)
  93.          handle_blank_screen
  94.         ;;
  95.     0000001b)
  96.         cardr_toggle # soft-buton 2
  97.         ;;
  98.     0000001c)
  99.         # soft-buton 3
  100.            handle_camera_toggle
  101.         ;;
  102.     0000001d)
  103.         touchpad_toggle
  104.         ;;
  105. esac
Advertisement
Add Comment
Please, Sign In to add comment