From 93d2743e3864e9eab0699b1bb1ea5f01c10bdbc1 Mon Sep 17 00:00:00 2001 From: Yaroslav Date: Mon, 23 Sep 2019 06:32:38 +0300 Subject: initial commit --- laptop/90-backlight.rules | 7 +++++++ laptop/lid-button | 2 ++ laptop/lid-button.sh | 15 +++++++++++++++ laptop/logind.conf | 37 +++++++++++++++++++++++++++++++++++++ laptop/pmsetup.sh | 16 ++++++++++++++++ laptop/powertune | 5 +++++ laptop/powertune.service | 11 +++++++++++ 7 files changed, 93 insertions(+) create mode 100644 laptop/90-backlight.rules create mode 100644 laptop/lid-button create mode 100755 laptop/lid-button.sh create mode 100644 laptop/logind.conf create mode 100755 laptop/pmsetup.sh create mode 100755 laptop/powertune create mode 100644 laptop/powertune.service (limited to 'laptop') diff --git a/laptop/90-backlight.rules b/laptop/90-backlight.rules new file mode 100644 index 0000000..2612365 --- /dev/null +++ b/laptop/90-backlight.rules @@ -0,0 +1,7 @@ +# Allow video group to control backlight and leds +SUBSYSTEM=="backlight", ACTION=="add", \ + RUN+="/bin/chgrp video /sys/class/backlight/%k/brightness", \ + RUN+="/bin/chmod g+w /sys/class/backlight/%k/brightness" +SUBSYSTEM=="leds", ACTION=="add", KERNEL=="*::kbd_backlight", \ + RUN+="/bin/chgrp video /sys/class/leds/%k/brightness", \ + RUN+="/bin/chmod g+w /sys/class/leds/%k/brightness" diff --git a/laptop/lid-button b/laptop/lid-button new file mode 100644 index 0000000..e2a381d --- /dev/null +++ b/laptop/lid-button @@ -0,0 +1,2 @@ +event=button/lid +action=/etc/acpi/actions/lid-button.sh %e diff --git a/laptop/lid-button.sh b/laptop/lid-button.sh new file mode 100755 index 0000000..601af5a --- /dev/null +++ b/laptop/lid-button.sh @@ -0,0 +1,15 @@ +#!/bin/sh +case "$3" in + close) + logger "LID close on custom"; + if [ "$(ps cax | grep i3)" ]; then + su yaroslav -c "DISPLAY=:0 i3 exec 'i3session suspend'" + else + systemctl suspend + fi + ;; + open) + logger "LID open on custom" ;; + *) + logger "LID undefined action $1" ;; +esac diff --git a/laptop/logind.conf b/laptop/logind.conf new file mode 100644 index 0000000..0e2c94f --- /dev/null +++ b/laptop/logind.conf @@ -0,0 +1,37 @@ +# This file is part of systemd. +# +# systemd is free software; you can redistribute it and/or modify it +# under the terms of the GNU Lesser General Public License as published by +# the Free Software Foundation; either version 2.1 of the License, or +# (at your option) any later version. +# +# Entries in this file show the compile time defaults. +# You can change settings by editing this file. +# Defaults can be restored by simply deleting this file. +# +# See logind.conf(5) for details. + +[Login] +#NAutoVTs=6 +#ReserveVT=6 +#KillUserProcesses=no +#KillOnlyUsers= +#KillExcludeUsers=root +#InhibitDelayMaxSec=5 +#HandlePowerKey=poweroff +#HandleSuspendKey=suspend +#HandleHibernateKey=hibernate +HandleLidSwitch=ignore +HandleLidSwitchExternalPower=ignore +#HandleLidSwitchDocked=ignore +#PowerKeyIgnoreInhibited=no +#SuspendKeyIgnoreInhibited=no +#HibernateKeyIgnoreInhibited=no +#LidSwitchIgnoreInhibited=yes +#HoldoffTimeoutSec=30s +#IdleAction=ignore +#IdleActionSec=30min +#RuntimeDirectorySize=10% +#RemoveIPC=yes +#InhibitorsMax=8192 +#SessionsMax=8192 diff --git a/laptop/pmsetup.sh b/laptop/pmsetup.sh new file mode 100755 index 0000000..be75384 --- /dev/null +++ b/laptop/pmsetup.sh @@ -0,0 +1,16 @@ +#!/bin/sh +# Meant to be executed just once after system install + +cp powertune /bin/powertune +cp powertune.service /etc/systemd/system/ +cp 90-backlight.rules /etc/udev/rules.conf.d/ +sudo systemctl start powertune + +# Disable everything from being able to wake up the computer except for the lid +for x in $(find /sys -name wakeup) ; do if [ "$(cat $x)" == "enabled" ]; then echo 'disabled' >> $x; fi; done +echo LID | tee /proc/acpi/wakeup + +# lid +cp logind.conf /etc/systemd/ +cp lidbutton /etc/acpi/events/ +cp lidbutton.sh /etc/acpi/actions/ diff --git a/laptop/powertune b/laptop/powertune new file mode 100755 index 0000000..f113000 --- /dev/null +++ b/laptop/powertune @@ -0,0 +1,5 @@ +#!/bin/sh + +/usr/bin/powertop --auto-tune +for x in $(find /sys -name wakeup) ; do if [ "$(cat $x)" == "enabled" ]; then echo 'disabled' >> $x; fi; done +echo LID | /usr/bin/tee /proc/acpi/wakeup diff --git a/laptop/powertune.service b/laptop/powertune.service new file mode 100644 index 0000000..0d7c3ca --- /dev/null +++ b/laptop/powertune.service @@ -0,0 +1,11 @@ +[Unit] +Description=Tune system's power management + +[Service] +User=root +Group=root +ExecStart=/bin/powertune + +[Install] +Alias=powertune.service +WantedBy=multi-user.target -- cgit v1.2.3