wlan-ps-toggle 475 B

123456789101112131415161718192021222324252627282930313233
  1. #!/bin/sh
  2. set -e
  3. dev=wlan0
  4. [ $# -ge 1 ] && dev="$1"
  5. msg()
  6. {
  7. local text="$*"
  8. echo "$text"
  9. zenity --info --timeout=1 --title="WLAN power saving" \
  10. --text="$text" || true
  11. }
  12. ps_is_on()
  13. {
  14. [ "$(iw dev "$dev" get power_save | cut -d':' -f2 | tr -d ' ')" = on ]
  15. }
  16. ps_enable()
  17. {
  18. iw dev "$dev" set power_save on
  19. msg "Turned $dev power saving ON"
  20. }
  21. ps_disable()
  22. {
  23. iw dev "$dev" set power_save off
  24. msg "Turned $dev power saving OFF"
  25. }
  26. ps_is_on && ps_disable || ps_enable