WIP Laptop power

This commit is contained in:
Przemek Grondek 2022-10-26 01:18:13 +02:00
parent af322d762c
commit 6d7e92052f
4 changed files with 66 additions and 0 deletions

View File

@ -0,0 +1,2 @@
SUBSYSTEM=="power_supply", ATTR{online}=="0", RUN+="/usr/local/sbin/power-saver-mode"
SUBSYSTEM=="power_supply", ATTR{online}=="1", RUN+="/usr/local/sbin/unlimited-power"

View File

@ -0,0 +1,14 @@
#!/usr/bin/env sh
# Enable back all CPUs
echo 1 | tee /sys/devices/system/cpu/cpu[2-7]/online
echo 1 | tee /sys/devices/system/cpu/cpu1[0-5]/online
# Set CPU to governor to powersave
cpupower frequency-set --governor ondemand
# Set brightness to 120 / 255
echo 200 | tee /sys/class/backlight/amdgpu_bl0/brightness
# Enable bluetooth
rfkill unblock bluetooth

View File

@ -0,0 +1,26 @@
#!/usr/bin/env sh
# Limit 8C/16T CPU to 2C/4T
echo 0 | tee /sys/devices/system/cpu/cpu[2-7]/online
echo 0 | tee /sys/devices/system/cpu/cpu1[0-5]/online
# Set CPU to governor to powersave
cpupower frequency-set --governor powersave
# Set brightness to 120 / 255
echo 120 | tee /sys/class/backlight/amdgpu_bl0/brightness
# Disable bluetooth
rfkill block bluetooth
# TODO disable some services
# systemctl disable containerd.service
# systemctl disable docker.service
# systemctl disable bluetooth.service
# systemctl disable libvirtd.service
# systemctl disable winbind.service
# systemctl disable snapd.service
# systemctl disable cups.service
# systemctl disable avahi-daemon.service
# TODO exit steam

View File

@ -0,0 +1,24 @@
- name: install required packages for script
become: yes
apt:
update_cache: yes
pkg:
- linux-tools-common
- linux-tools-generic
- name: copy scripts
become: yes
copy:
src: "usr/local/sbin/{{item}}"
dest: "/usr/local/sbin/{{item}}"
mode: '0755'
loop:
- power-saver-mode
- unlimited-power
- name: add udev rules
become: yes
copy:
src: etc/udev/rules.d/99-powersave.rules
dest: /etc/udev/rules.d/99-powersave.rules
mode: '0755'