Last active
November 26, 2025 11:55
-
-
Save vwbusguy/02992061b3054e6b1cafe9b94bad500e to your computer and use it in GitHub Desktop.
Revisions
-
vwbusguy renamed this gist
Mar 25, 2025 . 1 changed file with 8 additions and 6 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -5,14 +5,16 @@ dbus-monitor --system "type='signal',path='/org/freedesktop/UPower/devices/batte if [ $? -eq 0 ]; then BATT_STAT=$(dbus-send --print-reply=literal --system --dest=org.freedesktop.UPower /org/freedesktop/UPower/devices/battery_BAT0 org.freedesktop.DBus.Properties.Get string:org.freedesktop.UPower.Device string:State | awk '{ print $3; }') if [ $BATT_STAT -eq 1 ] || [ $BATT_STAT -eq 4 ]; then LEVEL=$(tuned-adm list | grep -q throughput-performance && echo "throughput-performance" || echo "balanced") elif [ $BATT_STAT -eq 5 ]; then LEVEL="balanced" else LEVEL="powersave" fi if [[ "$(tuned-adm active | sed 's,.*: ,,')" != "$LEVEL" ]] ; then echo "Changing power level to ${LEVEL}" tuned-adm profile $LEVEL [[ $? -ne 0 ]] && echo "Could not change power level to ${LEVEL}!" fi fi done -
vwbusguy revised this gist
Mar 17, 2022 . 1 changed file with 4 additions and 3 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,7 +1,7 @@ #!/bin/bash dbus-monitor --system "type='signal',path='/org/freedesktop/UPower/devices/battery_BAT0',member='PropertiesChanged'" | while read LINE; do echo ${LINE} | grep battery_BAT0 | grep -q PropertiesChanged if [ $? -eq 0 ]; then BATT_STAT=$(dbus-send --print-reply=literal --system --dest=org.freedesktop.UPower /org/freedesktop/UPower/devices/battery_BAT0 org.freedesktop.DBus.Properties.Get string:org.freedesktop.UPower.Device string:State | awk '{ print $3; }') if [ $BATT_STAT -eq 1 ] || [ $BATT_STAT -eq 4 ]; then @@ -12,6 +12,7 @@ dbus-monitor --system "type='signal',path='/org/freedesktop/UPower/devices/batte LEVEL="power-saver" fi echo "Changing power level to ${LEVEL}" gdbus call --system --dest net.hadess.PowerProfiles --object-path /net/hadess/PowerProfiles --method org.freedesktop.DBus.Properties.Set 'net.hadess.PowerProfiles' 'ActiveProfile' "<'${LEVEL}'>" > /dev/null [[ $? -ne 0 ]] && echo "Could not change power level to ${LEVEL}!" fi done -
vwbusguy created this gist
Mar 11, 2022 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,17 @@ #!/bin/bash dbus-monitor --system "type='signal',path='/org/freedesktop/UPower/devices/battery_BAT0',member='PropertiesChanged'" | while read LINE; do echo ${LINE} | grep battery_BAT0 | grep PropertiesChanged if [ $? -eq 0 ]; then BATT_STAT=$(dbus-send --print-reply=literal --system --dest=org.freedesktop.UPower /org/freedesktop/UPower/devices/battery_BAT0 org.freedesktop.DBus.Properties.Get string:org.freedesktop.UPower.Device string:State | awk '{ print $3; }') if [ $BATT_STAT -eq 1 ] || [ $BATT_STAT -eq 4 ]; then LEVEL=$(powerprofilesctl list | grep -q performance && echo "performance" || echo "balanced") elif [ $BATT_STAT -eq 5 ]; then LEVEL="balanced" else LEVEL="power-saver" fi echo "Changing power level to ${LEVEL}" gdbus call --system --dest net.hadess.PowerProfiles --object-path /net/hadess/PowerProfiles --method org.freedesktop.DBus.Properties.Set 'net.hadess.PowerProfiles' 'ActiveProfile' "<'${LEVEL}'>" fi done