Hi there!
I've created two scripts that function together to manually set the Ultimate Performance power mode and update the toggle state at startup.
Here's what you need to do to get it up and running:
- Replace 'XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX' with the GUID of the “Ultimate Performance” power plan on your system. You can find the GUID by running powercfg /LIST in the command prompt.
- Replace both instances of ACTION_ID_1 with the Action ID of the first script.
To enable auto-start:
- Copy the Action ID of the second script.
- Look for 'SWS/S&M: Set global startup action'.
- Paste the Action ID.
Now it will automatically toggle on startup. (Otherwise, Script: X-Raym_Set SWS global startup action extstate value to On.lua)
ultimate_performance.lua:
Code:
function checkPerformanceMode()
local cmd = 'powercfg /GETACTIVESCHEME'
local handle = io.popen(cmd)
if handle then
local result = handle:read("*a")
handle:close()
if result:match("Ultimate Performance") then
return true
end
end
return false
end
function setUltimatePerformanceMode()
local cmd = 'powercfg /SETACTIVE XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX'
os.execute(cmd)
end
setUltimatePerformanceMode()
local action = "ACTION_ID_1"
local command_id = reaper.NamedCommandLookup(action)
local is_performance_mode = checkPerformanceMode()
if is_performance_mode then
reaper.SetToggleCommandState(0, command_id, 1)
else
reaper.SetToggleCommandState(0, command_id, 0)
reaper.ShowConsoleMsg("Failed to set power plan to Ultimate Performance\n")
end
reaper.RefreshToolbar2(0, command_id)
if is_performance_mode then
reaper.ShowConsoleMsg("Power plan set to Ultimate Performance\n")
end
check_ultimate_power.lua:
Code:
function checkPerformanceMode()
local cmd = 'powercfg /GETACTIVESCHEME'
local handle = io.popen(cmd)
if handle then
local result = handle:read("*a")
handle:close()
if result:match("Ultimate Performance") then
return true
end
end
return false
end
local action = "ACTION_ID_1"
local command_id = reaper.NamedCommandLookup(action)
-- Check the Ultimate Performance mode on Reaper startup
if checkPerformanceMode() then
reaper.SetToggleCommandState(0, command_id, 1)
else
reaper.SetToggleCommandState(0, command_id, 0)
end
reaper.RefreshToolbar2(0, command_id)