#!/bin/sh
# tlp-rdw - enable/disable RDW
#
# Copyright (c) 2020 Thomas Koch <linrunner at gmx.net> and others.
# This software is licensed under the GPL v2 or later.

# shellcheck disable=SC2086

# --- Source libraries

for lib in /usr/share/tlp/tlp-func-base /usr/share/tlp/func.d/25-tlp-func-rf /usr/share/tlp/func.d/30-tlp-func-rf-sw; do
    # shellcheck disable=SC1090
    . $lib || exit 70
done

# --- MAIN

# read configuration: quit on error, trace allowed
read_config 1 0

carg1=$1
parse_args4config "$@"

case $carg1 in
    enable)
        check_root
        reset_run_flag $RDW_KILL
        echo "tlp-rdw: enabled."
        ;;

    disable)
        check_root
        set_run_flag $RDW_KILL
        echo "tlp-rdw: disabled."
        ;;

    *)
        if check_run_flag $RDW_KILL; then
            echo "tlp-rdw: disabled."
        else
            echo "tlp-rdw: enabled."
        fi
        ;;
esac

do_exit 0
