From bd3a8563f293ba01d85ad9af9c02b054f553e0af Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=A1clav=20Uruba?= Date: Fri, 16 Apr 2021 14:36:07 +0200 Subject: [PATCH] add laptop_power_plug script --- scripts/scripts/laptop_power_plug | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100755 scripts/scripts/laptop_power_plug diff --git a/scripts/scripts/laptop_power_plug b/scripts/scripts/laptop_power_plug new file mode 100755 index 0000000..0863a42 --- /dev/null +++ b/scripts/scripts/laptop_power_plug @@ -0,0 +1,26 @@ +#!/bin/sh + +case "$1" in + "in") + export message="Power cord plugged in" + governor="performance" + ;; + "out") + export message="Power cord unplugged" + governor="schedutil" + ;; + *) + echo "Wrong argument specified" + exit 1 + ;; +esac + +user=$(who | head -n 1 | cut -d" " -f1) + + +export XAUTHORITY=/home/$user/.Xauthority +export DISPLAY=:0 + +su $user -c 'notify-send "$message"' +cpupower frequency-set -r -g $governor +