diff --git a/roles/laptop/files/etc/udev/rules.d/99-powersave.rules b/roles/laptop/files/etc/udev/rules.d/99-powersave.rules new file mode 100644 index 0000000..060eee5 --- /dev/null +++ b/roles/laptop/files/etc/udev/rules.d/99-powersave.rules @@ -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" \ No newline at end of file diff --git a/roles/laptop/files/usr/local/sbin/power-saver-mode b/roles/laptop/files/usr/local/sbin/power-saver-mode new file mode 100644 index 0000000..e999f97 --- /dev/null +++ b/roles/laptop/files/usr/local/sbin/power-saver-mode @@ -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 diff --git a/roles/laptop/files/usr/local/sbin/unlimited-power b/roles/laptop/files/usr/local/sbin/unlimited-power new file mode 100644 index 0000000..dd3cd7e --- /dev/null +++ b/roles/laptop/files/usr/local/sbin/unlimited-power @@ -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 diff --git a/roles/laptop/tasks/powersave.yml b/roles/laptop/tasks/powersave.yml new file mode 100644 index 0000000..01bcc64 --- /dev/null +++ b/roles/laptop/tasks/powersave.yml @@ -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'