Skip to content

Instantly share code, notes, and snippets.

@rusty-snake
Created September 23, 2021 08:01
Show Gist options
  • Save rusty-snake/646289005110c0bacaa513e73e75e65d to your computer and use it in GitHub Desktop.
Save rusty-snake/646289005110c0bacaa513e73e75e65d to your computer and use it in GitHub Desktop.
Tweak battery usage on a Linux with GNOME desktop. powertop needs to be installed.
#!/bin/bash
# Copyright © 2020 rusty-snake
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
nmcli radio wifi on
gsettings reset org.gnome.desktop.session idle-delay
gsettings reset org.gnome.desktop.screensaver lock-delay
gsettings reset org.gnome.desktop.interface enable-animations
#!/bin/bash
# Copyright © 2020 rusty-snake
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
# Turnoff WLAN and WWAN
nmcli radio all off
# Turnoff the monitor after 1min, but lock it after 5min
gsettings set org.gnome.desktop.session idle-delay 60
gsettings set org.gnome.desktop.screensaver lock-delay 300
# Disable animations
gsettings set org.gnome.desktop.interface enable-animations false
# Lower monitor backlight to 0
while [[ $(dbus-send --session --print-reply --dest=org.gnome.SettingsDaemon.Power /org/gnome/SettingsDaemon/Power org.gnome.SettingsDaemon.Power.Screen.StepDown | awk '/^[[:space:]]+int32 [[:digit:]]+$/ { print $2 }') -ne 0 ]]; do :; done
# Run powertop --auto-tune
sudo powertop --auto-tune
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment