#!/bin/sh
# tlp - run commands depending on power source
#
# Copyright (c) 2012 Thomas Koch <linrunner at gmx.net>
# This software is licensed under the GPL v2.

self=${0##*/}

cmd=$1
if [ -z "$1" ]; then
    echo "Usage: $self command [arg(s)]"
    exit 1
fi

shift

case $self in
    run-on-ac)
        if on_ac_power; then        
            $cmd $@
        fi
        ;;
        
    run-on-bat)
        if ! on_ac_power; then      
            $cmd $@
        fi
        ;;

    *)
        echo "Error: unknown mode $self."
        exit 1
        ;;
esac
