Debian Script zum Schalten von Bluetooth WLAN WWAN: Unterschied zwischen den Versionen
Aus ThinkPad-Wiki
Ausgelagert aus Debian Schnelleinstieg |
(kein Unterschied)
|
Aktuelle Version vom 29. März 2014, 18:35 Uhr
Ein zyklisches Schalten von WLAN, WWAN und Bluetooth kann mittels des nachfolgenden Scripts erreicht werden.
Dazu muss zum einen TLP installiert sein, zum anderen ist eine Anpassung der Datei /etc/sudoers erforderlich. Hier muss dem jeweiligen Nutzer ein Zugriff auf die Befehle /usr/bin/bluetooth, /usr/bin/wwan und /usr/bin/wifi erlaubt werden. Informationen zur Bearbeitung und den Parametern in /etc/sudoers findet man mit
$ man sudoers
Script zum zyklischen Schalten von Bluetooth, WLAN und WWAN:
#!/bin/bash
# name: sywn (switch your wireless network)
# description: wireless network switch cyclically (ThinkPads with Debian)
# dependencies: tlp
# author: Frank Zimmermann
# version: 0.0.1~3
# date: 2012-11-04
BT=$(bluetooth)
WW=$(wwan)
WI=$(wifi)
BT0=$(bluetooth | grep 'bluetooth.*off')
BT1=$(bluetooth | grep 'bluetooth.*on')
BTN=$(bluetooth | grep 'bluetooth.*none')
WW0=$(wwan | grep 'wwan.*off')
WW1=$(wwan | grep 'wwan.*on')
WWN=$(wwan | grep 'wwan.*none')
WI0=$(wifi | grep 'wifi.*off')
WI1=$(wifi | grep 'wifi.*on')
WIN=$(wifi | grep 'wifi.*none')
if [[ "$WI" == "$WI1" ]] && [[ "$BT" == "$BT1" ]] && [[ "$WW" == "$WW1" || "$WWN" ]]; then
`sudo bluetooth off` && `sudo wwan off`
elif [[ "$WI" == "$WI1" ]] && [[ "$BT" == "$BTN" ]] && [[ "$WW" == "$WW1" ]]; then
`sudo wwan off`
elif [[ "$WI" == "$WI1" ]] && [[ "$BT" == "$BT0" ]] && [[ "$WW" == "$WW0" || "$WWN" ]]; then
`sudo wifi off` && `sudo bluetooth on`
elif [[ "$WI" == "$WI1" ]] && [[ "$BT" == "$BTN" ]] && [[ "$WW" == "$WW0" ]]; then
`sudo wifi off` && `sudo wwan on`
elif [[ "$WI" == "$WI0" ]] && [[ "$BT" == "$BT1" ]] && [[ "$WW" == "$WW0" || "$WWN" ]]; then
`sudo bluetooth off` && `sudo wwan on`
elif [[ "$WI" == "$WI0" ]] && [[ "$BT" == "$BT0" || "$BTN" ]] && [[ "$WW" == "$WW1" ]]; then
`sudo wwan off`
else
`sudo wifi on`
`sudo bluetooth on`
`sudo wwan on`
fi
exit 0
Weitere Informationen zur Shell-Programmierung findet man unter Einführung zur Shell-Programmierung.
