#!/bin/sh
# tlp-rdw - lock events during suspend/hibernate cycle
#
# Copyright (c) 2012 Thomas Koch <linrunner at gmx.net>
# This software is licensed under the GPL v2.

. "${PM_FUNCTIONS}"

readonly LIBDIRS="/usr/lib/tlp-pm /usr/lib64/tlp-pm"
readonly LIBS="tlp-functions"

for libdir in $LIBDIRS; do [ -d $libdir ] && break; done
[ -d $libdir ] || exit 0

for lib in $LIBS; do 
    [ -f $libdir/$lib ] || exit 0
    . $libdir/$lib
done

read_defaults || exit 0

[ "$TLP_ENABLE" = "1" ] || exit 0

echo_debug "pm" "48tlp-rdw-lock.$1"

case $1 in
	hibernate|suspend)
		set_run_flag $LOCK_RDW
		;;

	thaw|resume)
		reset_run_flag $LOCK_RDW
		;;

	*) exit $NA
		;;
esac

exit 0
