/usr/bin/run-on-ac is in tlp 0.9-3.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
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 49 50 51 | #!/bin/sh
# tlp - run commands depending on power source
#
# Copyright (c) 2016 Thomas Koch <linrunner at gmx.net>
# This software is licensed under the GPL v2 or later.
# --- Constants
readonly LIBDIR="/usr/share/tlp-pm"
readonly LIBS="tlp-functions"
# --- Source libraries
for lib in $LIBS; do
if [ ! -f $LIBDIR/$lib ]; then
echo "Error: missing function library \'$LIBDIR/$lib\'." 1>&2
exit 1
fi
. $LIBDIR/$lib
done
# --- MAIN
self=${0##*/}
cmd=$1
if [ -z "$cmd" ]; then
echo "Usage: $self command [arg(s)]" 1>&2
exit 1
fi
if ! cmd_exists $cmd; then
echo "Error: \"$cmd\" not found." 1>&2
exit 2
fi
shift
case $self in
run-on-ac)
if get_power_state; then
$cmd $@
fi
;;
run-on-bat)
if ! get_power_state; then
$cmd $@
fi
;;
*)
echo "Error: unknown mode $self." 1>&2
exit 1
;;
esac
|