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 }