wlan an/aus via Menü/Plugin / wlan leistung (txpower)

    Diese Seite verwendet Cookies. Durch die Nutzung unserer Seite erklären Sie sich damit einverstanden, dass wir Cookies setzen. Weitere Informationen

    • wlan an/aus via Menü/Plugin / wlan leistung (txpower)

      hi zusammen,

      ich wollte ein Plugin, dass mir nur wlan aus + wieder anschaltet.
      Wlan muss ja nicht immer an sein :)

      Das Plugin erscheint dann im Plugins Menü und via blauer Taste.

      Folgendes müsste manuell gemacht werden:
      - mkdir /usr/lib/enigma2/python/Plugins/Extensions/wlanonoff
      - touch /usr/lib/enigma2/python/Plugins/Extensions/wlanonoff/__init__.py
      - vi /usr/lib/enigma2/python/Plugins/Extensions/wlanonoff/plugin.py

      Quellcode

      1. '''
      2. Created on 09.09.2014
      3. @author: me
      4. '''
      5. #Every enigma2 Plugin needs to return a single or a list of PluginDescriptor instances
      6. from Plugins.Plugin import PluginDescriptor
      7. #The good old Messagebox
      8. from Screens.MessageBox import MessageBox
      9. #Our main function. Will be called when the Plugin starts
      10. def main(session, **kwargs):
      11. session.open(MessageBox, _("wlan was set on/off"), type = MessageBox.TYPE_INFO, timeout = 10 )
      12. import os
      13. os.system("/etc/tuxbox/wifionoff.sh")
      14. #Here comes the "voodoo".
      15. #enigma2 calls this function in every "plugin.py" within the Plugins/* directories.
      16. #The function has to return one ore more PluginDescriptor objects (as python list)
      17. def Plugins(**kwargs):
      18. return [
      19. PluginDescriptor(name=_("wlan on/off"), description=_("wlan on/off"), where=[PluginDescriptor.WHERE_PLUGINMENU], icon="plugin.png", fnc=main),
      20. PluginDescriptor(name=_("wlan on/off"), description=_("wlan on/off"), where=[PluginDescriptor.WHERE_EXTENSIONSMENU], icon="plugin.png", fnc=main),
      21. ]
      Alles anzeigen


      - vi /etc/tuxbox/wifionoff.sh

      Shell-Script

      1. #!/bin/sh
      2. STATEFILE="/tmp/wifionoff.state"
      3. if [ $# -eq 1 ]; then
      4. case $1 in
      5. "up"|"on")
      6. STATE=off
      7. ;;
      8. "down"|"off")
      9. STATE=on
      10. ;;
      11. esac
      12. else
      13. if [ ! -e ${STATEFILE} ]; then
      14. STATE=on
      15. else
      16. . ${STATEFILE}
      17. fi
      18. fi
      19. if [ -z ${STATE} ]; then
      20. STATE=on
      21. fi
      22. if [ ${STATE} == "on" ]; then
      23. /usr/sbin/rfkill block 0
      24. STATE=off
      25. else
      26. #/usr/sbin/rfkill unblock 0
      27. /etc/init.d/networking restart
      28. STATE=on
      29. fi
      30. echo "STATE=${STATE}" > ${STATEFILE}
      Alles anzeigen


      - chmod 777 /etc/tuxbox/wifionoff.sh


      Das kann man dann auch via cronjob weiterverarbeiten:

      Quellcode

      1. 02 02 * * * /etc/tuxbox/wifionoff.sh off


      Das ganze kann natürlich einfach angepasst werden.
      Mit "rfkill list" werden die Adapter angezeigt und mit dem rfkill --help kommt man sicher weiter


      Fallls man auch noch die txpower, also die Wlan Leistung des Sticks anpassen will, dann geht das mit "iwconfig"
      Hinzufügen von pre-up in:
      vi /etc/network/interfaces
      z.B.

      pre-up iwconfig wlan0 txpower 0

      => checken danach dann mit iwconfig

      Da ich aktuell kein VTI mehr installiert habe und mich im openpli Forum nicht auch noch extra anmelden will, kann das eventuell jemand weiterrreichen/weiterentwickeln :thumbsup:

      Dieser Beitrag wurde bereits 3 mal editiert, zuletzt von twerty ()