Conversation
Co-authored-by: mlutonsky <423848+mlutonsky@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix fragile switch_profile success detection
idle-power-manager: fix fragile switch_profile success detection
Mar 14, 2026
mlutonsky
approved these changes
Mar 14, 2026
There was a problem hiding this comment.
Pull request overview
Improves idle-power-manager.sh’s tuned profile switching reliability by avoiding fragile stdout parsing and using gdbus command success/failure directly.
Changes:
- Refactor
switch_profile()to branch ongdbus callexit status instead of grepping for"true". - Stop capturing and parsing
gdbusoutput; suppress output with redirection.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+93
to
+96
| "$profile" > /dev/null 2>&1; then | ||
| return 0 | ||
| else | ||
| log "ERROR" "Failed to switch to profile '$profile': $result" | ||
| log "ERROR" "Failed to switch to profile '$profile'" |
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 characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
switch_profile()detected success by grepping stdout for"true", which could false-positive on any output containing that string (e.g., error messages referencing a profile namedtrue-performance). Replace with a direct exit-code check.Changes
switch_profile(): Drop stdout capture andgrep -q "true"; usegdbus call ... > /dev/null 2>&1and branch on exit code directly.Original prompt
idle-power-manager: fix fragile switch_profile success detection
File to modify:
idle-power-manager.shProblem
The
switch_profile()function checks success by grepping stdout for the string"true":This is fragile — it would match any output containing the word "true", including error messages like "profile 'true-performance' not found". Checking the exit code of
gdbus calldirectly is more reliable.Fix
Refactor
switch_profile()to check the exit code ofgdbus calldirectly instead of grepping its output. Replace the entire function body with:No other changes to the file.
The following is the prior conversation context from the user's chat exploration (may be truncated):
Assistant: ````list type="task"
data:
- title: 'Add ShellCheck CI workflow'
repository: mlutonsky/utils
url: https://github.com/copilot/tasks/pull/PR_kwDORnE_6M7KoP2B
state: queued
The agent is working on all 10. PRs will appear at github.com/mlutonsky/utils/pulls as they're completed — review and merge whichever you find useful!
User: @copilot Accepted Confirmation: Are you sure?
User: @copilot Accepted Confirmation: Are you sure?
Assistant: The Copilot coding agent is now working on all the pull requests! Here's the full tracking list: