Skip to content

Instantly share code, notes, and snippets.

@sdaitzman
Created November 14, 2014 03:16
Show Gist options
  • Save sdaitzman/c68eb6de6464fbca31a2 to your computer and use it in GitHub Desktop.
Save sdaitzman/c68eb6de6464fbca31a2 to your computer and use it in GitHub Desktop.
power-saving /etc/rc.local tweaks for Elementary OS Freya on mid-2012 rMBP and integrated graphics
#!/bin/sh -e
#
# rc.local
#
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 0" on success or any other
# value on error.
#
# In order to enable or disable this script just change the execution
# bits.
#
# By default this script does nothing.
# switch off dGPU
echo 'OFF' > /sys/kernel/debug/vgaswitcheroo/switch
# set cpu frequency
# requires cpufrequtils
cpufreq-set -r -c 0 -g powersave
# remount / with atime disabled
mount -o remount,relatime /
# enable powersave mode
# requires pm-utils
pm-powersave true
# enable laptop mode
echo 5 > /proc/sys/vm/laptop_mode
# set screen brightness
echo '135' > /sys/class/backlight/gmux_backlight/brightness
# set keyboard brightness
echo '22' > /sys/class/leds/smc::kbd_backlight/brightness
# disable bluetooth
rfkill block bluetooth
# stop services and kernel modules that are dumb
service grub-common stop
# enable ALPM - agressive link power management
echo SATA_ALPM_ENABLE=true | sudo tee /etc/pm/config.d/sata_alpm
# set SATA power management to min-power
echo min_power > /sys/class/scsi_host/host0/link_power_management_policy
echo min_power > /sys/class/scsi_host/host1/link_power_management_policy
echo min_power > /sys/class/scsi_host/host2/link_power_management_policy
echo min_power > /sys/class/scsi_host/host3/link_power_management_policy
echo min_power > /sys/class/scsi_host/host4/link_power_management_policy
echo min_power > /sys/class/scsi_host/host5/link_power_management_policy
# stuff powertop says to do - VM writeback delay and setting PCI devices to auto power-management
echo '1500' > '/proc/sys/vm/dirty_writeback_centisecs';
echo 'auto' > '/sys/bus/usb/devices/2-1.8.2/power/control';
echo 'auto' > '/sys/bus/pci/devices/0000:00:01.0/power/control';
echo 'auto' > '/sys/bus/pci/devices/0000:03:00.1/power/control';
echo 'auto' > '/sys/bus/pci/devices/0000:01:00.0/power/control';
echo 'auto' > '/sys/bus/pci/devices/0000:00:1f.3/power/control';
echo 'auto' > '/sys/bus/pci/devices/0000:00:1f.2/power/control';
echo 'auto' > '/sys/bus/pci/devices/0000:00:1f.0/power/control';
echo 'auto' > '/sys/bus/pci/devices/0000:00:1d.0/power/control';
echo 'auto' > '/sys/bus/pci/devices/0000:00:1c.0/power/control';
echo 'auto' > '/sys/bus/pci/devices/0000:00:1a.0/power/control';
echo 'auto' > '/sys/bus/pci/devices/0000:00:16.0/power/control';
echo 'auto' > '/sys/bus/pci/devices/0000:00:14.0/power/control';
echo 'auto' > '/sys/bus/pci/devices/0000:00:02.0/power/control';
echo 'auto' > '/sys/bus/pci/devices/0000:00:01.2/power/control';
echo 'auto' > '/sys/bus/pci/devices/0000:00:01.1/power/control';
echo 'auto' > '/sys/bus/pci/devices/0000:00:1c.1/power/control';
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment