File: ibm-wireless.sh

package info (click to toggle)
acpi-support 0.143-5.2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 828 kB
  • sloc: sh: 816; ansic: 131; makefile: 38
file content (48 lines) | stat: -rwxr-xr-x 1,125 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#!/bin/sh

test -f /usr/share/acpi-support/state-funcs || exit 0

read vendor </sys/class/dmi/id/sys_vendor 2>/dev/null || exit 0
case $vendor in
	[iI][bB][mM]*)
		;;
	[lL][eE][nN][oO][vV][oO]*)
		;;
	*)
		exit 0
		;;
esac

if ! test -x /usr/sbin/rfkill
then
logger -t${0##*/} -perr -- "Error: Please install package rfkill to enable toggling of wireless devices."
exit 0
fi


# Find and toggle wireless of bluetooth devices on ThinkPads

. /usr/share/acpi-support/state-funcs
. /etc/default/acpi-support

rfkill list | sed -n -e'/tpacpi_bluetooth_sw/,/^[0-9]/p' | grep -q 'Soft blocked: yes'
bluetooth_state=$?

# Note that this always alters the state of the wireless!
toggleAllWirelessStates;

# Sequence is Both on, Both off, Wireless only, Bluetooth only
if ! isAnyWirelessPoweredOn; then
    # Wireless was turned off
    if [ "$bluetooth_state" = 0 ]; then
      if [ x$WIRELESS_BLUETOOTH_SYNC != xtrue ]; then
        rfkill unblock bluetooth
      fi
    else
        rfkill block bluetooth
    fi
else
    if [ x$WIRELESS_BLUETOOTH_SYNC = xtrue -a "$bluetooth_state" = 0 ]; then
	rfkill unblock bluetooth
    fi
fi