Steam Deck power tweaks for power users
Find a file
2022-08-23 17:50:46 -04:00
.github/ISSUE_TEMPLATE Update bug-report.md 2022-05-30 00:49:06 +00:00
assets Update thumbnail image 2022-07-10 20:03:41 -04:00
powertools-rs Add new backend interface to front-end (untested) 2022-08-23 17:50:46 -04:00
src Add new backend interface to front-end (untested) 2022-08-23 17:50:46 -04:00
.gitignore Define complete Rust back-end API and functionality 2022-08-09 20:56:22 -04:00
LICENSE Create LICENSE 2022-04-21 18:02:57 +00:00
main.old.py Create Rust back-end (WIP) 2022-07-30 16:33:31 -04:00
main.py Create Rust back-end (WIP) 2022-07-30 16:33:31 -04:00
package.json Add new backend interface to front-end (untested) 2022-08-23 17:50:46 -04:00
plugin.json Update thumbnail image 2022-07-10 20:03:41 -04:00
README.md Update README with code changes from v0.7.0 2022-07-10 14:20:34 -04:00
rollup.config.js React UI rewrite; port to new decky plugin framework 2022-06-10 20:02:05 -04:00
server.py Remove HTTP server due to plugin store requirements 2022-07-05 18:14:50 -04:00
tsconfig.json React UI rewrite; port to new decky plugin framework 2022-06-10 20:02:05 -04:00

PowerTools

plugin_demo

Steam Deck power tweaks for power users.

This is generated from the template plugin for the Decky Plugin Loader. You will need that installed for this plugin to work.

What does it do?

  • Enable & disable CPU threads & SMT
  • Set CPU max frequency and toggle boost
  • Set some GPU power parameters (fastPPT & slowPPT)
  • Display supplementary battery info
  • Keep settings between restarts (stored in ~/.config/powertools/<appid>.json)

Cool, but that's too much work

Fair enough. In case you still want some of the functionality, without the nice GUI, here's some equivalent commands. These should all be run as superuser, i.e. run sudo su and then run these commands in that.

Enable & Disable CPU threads

Enable: echo 1 > /sys/devices/system/cpu/cpu{cpu_number}/online where {cpu_number} is a number from 1 to 7 (inclusive).

Disable: echo 0 > /sys/devices/system/cpu/cpu{cpu_number}/online where {cpu_number} is a number from 1 to 7 (inclusive).

NOTE: You cannot enable or disable cpu0, hence why there are only 7 in the range for 8 cpu threads.

Enable & Disable CPU boost

Enable: echo 1 > /sys/devices/system/cpu/cpufreq/boost enables boost across all threads.

Disable: echo 0 > /sys/devices/system/cpu/cpufreq/boost disables boost across all threads.

Set CPU frequency

Use cpupower (usage: cpupower --help). This isn't strictly how PowerTools does it, but it's a multi-step process which can involve changing the CPU governor. All that can be done automatically by cpupower frequency-set --freq {frequency} where {frequency} is 1.7G, 2.4G or 2.8G.

Set GPU Power

Set Slow Powerplay Table (PPT):echo {microwatts} > /sys/class/hwmon/hwmon4/power1_cap where {microwatts} is a wattage in millionths of a Watt. This doesn't seem to do a lot.

Set Fast Powerplay Table (PPT): echo {microwatts} > /sys/class/hwmon/hwmon4/power2_cap where {microwatts} is a wattage in millionths of a Watt.

Get the entry limits for those two commands with cat /sys/class/hwmon/hwmon4/power{number}_cap_max where {number} is 1 (slowPPT) or 2 (fastPPT).

Set Fan speed

NOTE: PowerTools no longer supports this, since Fantastic does it much better.

Enable automatic control: echo 0 > /sys/class/hwmon/hwmon5/recalculate enables automatic fan control.

Disable automatic control: echo 1 > /sys/class/hwmon/hwmon5/recalculate disables automatic (temperature-based) fan control and starts using the set fan target instead.

Set the fan speed: echo {rpm} > /sys/class/hwmon/hwmon5/fan1_target where {rpm} is the RPM.

Read the actual fan RPM: cat /sys/class/hwmon/hwmon5/fan1_input gives the fan speed.

NOTE: There's a bug in the fan controller; if you enable automatic fan control it will forget any previously-set target despite it appearing to be set correctly (i.e. cat /sys/class/hwmon/hwmon5/fan1_target will display the correct value). When you disable automatic fan control, you will need to set the fan RPM again.

Battery stats

Get the battery charge right now: cat /sys/class/hwmon/hwmon2/device/charge_now gives charge in uAh (uAh * 7.7/1000000 = charge in Wh).

Get the maximum battery capacity: cat /sys/class/hwmon/hwmon2/device/charge_full gives charge in uAh.

Get the design battery capacity: cat /sys/class/hwmon/hwmon2/device/charge_full_design gives charge in uAh.

Get whether the deck is plugged in: cat /sys/class/hwmon/hwmon5/curr1_input gives the charger current in mA.

NOTE: 7.7 is the voltage of the battery -- it's not just a magic number.

Steam Deck kernel patches

This is how I figured out how the fan stuff works. I've only scratched the surface of what this code allows, I'm sure it has more useful information. https://lkml.org/lkml/2022/2/5/391

Game launch detection

//@ts-ignore
let lifetimeHook = SteamClient.GameSessions.RegisterForAppLifetimeNotifications((update) => {
    if (update.bRunning) {
        console.log("AppID " + update.unAppID.toString() + " is now running");
    } else {
        console.log("AppID " + update.unAppID.toString() + " is no longer running");
        // game exit code here
        // NOTE: custom games always have 0 as AppID, so AppID is bad to use as ID
    }
});
//@ts-ignore
let startHook = SteamClient.Apps.RegisterForGameActionStart((actionType, id) => {
    //@ts-ignore
    let gameInfo: any = appStore.GetAppOverviewByGameID(id);
    // game start code here
    // NOTE: GameID (variable: id) is always unique, even for custom games, so it's better to use than AppID
});

License

This is licensed under GNU GPLv3.