#!/bin/sh
# tlp - switch bluetooth/wifi/wwan on/off
#
# Copyright (c) 2012 Thomas Koch <linrunner at gmx.net>
# This software is licensed under the GPL v2.

# --- Constants
readonly LIB=/usr/lib64/tlp-pm/tlp-functions
readonly RFLIB=/usr/lib64/tlp-pm/tlp-rf-func

# --- Source libraries
[ -f $LIB ] || exit 0
[ -f $RFLIB ] || exit 0
. $LIB
. $RFLIB

# --- MAIN
read_defaults
self=${0##*/}

case $self in
    bluetooth|wifi|wwan)
        case $1 in
            on)
                device_on $self
                echo_device_state $self $devs
                ;;

            off)
                device_off $self
                echo_device_state $self $devs
                ;;
                
            toggle)
                device_toggle $self
                echo_device_state $self $devs
                ;;
                
            *)
                device_state $self
                echo_device_state $self $devs
                ;;
        esac
        ;;

    *)
        echo "Error: unknown device type \"$self\"."
        exit 1
        ;;
esac

exit 0
