summarylogtreecommitdiffstats
path: root/tlp-pmu.install
blob: c796c0270b56628f3898bcac59216851f1c66337 (plain)
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
post_install() {
# Mask conflicting pm-utils hooks
if [ -d /usr/lib/pm-utils/power.d ] && [ -d /etc/pm/power.d ]; then
    for i in $(find /usr/lib/pm-utils/power.d -type f -printf "%f\n"); do
        if [ -x /usr/lib/pm-utils/power.d/$i ]; then
            # Executable hook in /usr/lib/pm-utils/power.d/ exists
            if [ -f /etc/pm/power.d/$i ]; then
                # Exclude symlinks to tlp-nop
                if [ "$( readlink -s /etc/pm/power.d/$i )" != "/usr/lib/tlp-pm/tlp-nop" ]; then
                    # Move aside superseding hook of same name in /etc/pm/power.d/
                    mv -n /etc/pm/power.d/$i /etc/pm/power.d/$i.tlp-save
                fi
            fi
            # Make a soft link to tlp-nop in /etc/pm/power.d/
            # to disable corresponding hook /usr/lib/pm-utils/power.d/
            ln -sf /usr/lib/tlp-pm/tlp-nop /etc/pm/power.d/$i
        fi
    done
fi
}

post_upgrade() {
	post_install
}

post_remove() {
# Unmask pm-utils hooks
for i in $(find /etc/pm/power.d -printf "%f\n"); do
    if [ "$( readlink /etc/pm/power.d/$i )" = "/usr/lib/tlp-pm/tlp-nop" ]; then
        rm /etc/pm/power.d/$i
    fi
done
}