2024-03-01 07:31:59 +01:00
|
|
|
#!/usr/bin/bash
|
|
|
|
# This script sends the Power Profile Daemon dbus call to set tuneD to power-saver mode
|
|
|
|
# This is useful only for battery powered devices where you want to start in power-saver mode by default
|
|
|
|
POWERSAVE=1
|
2024-06-21 19:44:32 +02:00
|
|
|
if [ -n "$1" ]; then
|
|
|
|
if [ "$1" == "0" ]; then
|
2024-03-01 07:31:59 +01:00
|
|
|
POWERSAVE=0
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Check what DE we are on
|
|
|
|
if command -v /usr/bin/mutter > /dev/null; then
|
|
|
|
# If we are on Gnome send the dbus signal with gdbus
|
2024-06-21 19:44:32 +02:00
|
|
|
if [ "$POWERSAVE" == "0" ]; then
|
2024-03-01 07:31:59 +01:00
|
|
|
gdbus call --system --dest net.hadess.PowerProfiles --object-path /net/hadess/PowerProfiles --method org.freedesktop.DBus.Properties.Set 'net.hadess.PowerProfiles' 'ActiveProfile' "<'balanced'>"
|
|
|
|
else
|
|
|
|
gdbus call --system --dest net.hadess.PowerProfiles --object-path /net/hadess/PowerProfiles --method org.freedesktop.DBus.Properties.Set 'net.hadess.PowerProfiles' 'ActiveProfile' "<'power-saver'>"
|
|
|
|
fi
|
|
|
|
else
|
|
|
|
# Assume we are on KDE and send the dbus signal with qdbus
|
2024-06-21 19:44:32 +02:00
|
|
|
if [ "$POWERSAVE" == "0" ]; then
|
2024-03-01 07:31:59 +01:00
|
|
|
qdbus org.kde.Solid.PowerManagement /org/kde/Solid/PowerManagement/Actions/PowerProfile setProfile balanced
|
|
|
|
else
|
|
|
|
qdbus org.kde.Solid.PowerManagement /org/kde/Solid/PowerManagement/Actions/PowerProfile setProfile power-saver
|
|
|
|
fi
|
|
|
|
fi
|