aboutsummaryrefslogtreecommitdiff
path: root/laptop
diff options
context:
space:
mode:
authorYaroslav <contact@yaroslavps.com>2019-09-23 06:32:38 +0300
committerYaroslav <contact@yaroslavps.com>2019-09-23 06:32:38 +0300
commit93d2743e3864e9eab0699b1bb1ea5f01c10bdbc1 (patch)
treef5cab1472bf7d95aa72c43a713e104d2827b37a5 /laptop
downloadswayrice-93d2743e3864e9eab0699b1bb1ea5f01c10bdbc1.tar.gz
swayrice-93d2743e3864e9eab0699b1bb1ea5f01c10bdbc1.zip
initial commit
Diffstat (limited to 'laptop')
-rw-r--r--laptop/90-backlight.rules7
-rw-r--r--laptop/lid-button2
-rwxr-xr-xlaptop/lid-button.sh15
-rw-r--r--laptop/logind.conf37
-rwxr-xr-xlaptop/pmsetup.sh16
-rwxr-xr-xlaptop/powertune5
-rw-r--r--laptop/powertune.service11
7 files changed, 93 insertions, 0 deletions
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