-
Notifications
You must be signed in to change notification settings - Fork 149
Expand file tree
/
Copy pathtlp-run-on.in
More file actions
53 lines (46 loc) · 1.09 KB
/
tlp-run-on.in
File metadata and controls
53 lines (46 loc) · 1.09 KB
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
52
53
#!/bin/sh
# tlp - run commands depending on power source
#
# Copyright (c) 2026 Thomas Koch <linrunner at gmx.net> and others.
# SPDX-License-Identifier: GPL-2.0-or-later
# --- Source libraries
# shellcheck disable=SC2043
for lib in @TLP_TLIB@/tlp-func-base; do
# shellcheck disable=SC1090
. "$lib"
done
# --- MAIN
self=${0##*/}
cmd=$1
if [ -z "$cmd" ]; then
cecho "Usage: $self command [arg(s)]" 1>&2
exit 1
fi
if ! cmd_exists "$cmd"; then
cecho "Error: \"$cmd\" not found." 1>&2
exit 2
fi
shift
case $self in
run-on-ac)
get_sys_power_supply
# shellcheck disable=SC2154
case "$_syspwr" in
"$PS_AC") $cmd "$@" ;;
"$PS_BAT") ;;
"$PS_UNKNOWN") cecho "Error: power source unknown." 1>&2 ;;
esac
;;
run-on-bat)
get_sys_power_supply
case "$_syspwr" in
"$PS_AC") ;;
"$PS_BAT") $cmd "$@" ;;
"$PS_UNKNOWN") cecho "Error: power source unknown." 1>&2 ;;
esac
;;
*)
cecho "Error: unknown mode $self." 1>&2
exit 1
;;
esac