The GUI option to change power profiles in Fedora 35 quickly is nice, but wouldn’t it be nicer to have it automatically put the laptop in “Performance” mode when AC Power is applied and “Power Saver” when running on battery? Easily done. After putting the scripts and rules in place, I wrote a small script to automate it and a readme for step-by step instructions. It’s not a hard process, but this is a time saver.
GitLab Link: Eiko Tsukida / Power Profiles Automation · GitLab
Alternate Download: File on MEGA
As with all scripts (especially ones that require root permissions), I don’t recommend running them if you haven’t read or don’t understand the content. So the rest of this post will break it down.
The installer script does 3 things.
- Creates the directory /usr/share/power-profiles
- Copies a pair of 1-line bash scripts (courtesy of https://github.com/ruzko/power-profiles-daemon-scripts2 ) to that directory to set the appropriate profile
- Copies a pair of udev rules (adapted from linux - udev rule to start a command on AC/Battery plug/unplug event - Super User ) to /etc/udev/rules.d
The readme file also has instructions for dropping the files in-place yourself. Feel free to read the files before running anything.
You can use
udevadm monitor --environment to monitor for changes and then plug/unplug power to make sure that the files adjust the correct property for your situation. It’s also not hard to rewrite the scripts to use the Balanced profile if you prefer it.
I’ve only tested this on a Framework laptop running the latest Fedora 35 (Kernel 5.14.14-300.fc35.x86_64), but theoretically it may work on other distros and flavours running power-profiles-daemon. No warranty is expressed or implied, use at your own risk, etc.
You may want to throw those files in GitLab/GitHub somewhere instead. People may not trust downloading files from MEGA, and more importantly, a link out to there could potentially be flagged as spam.
@jorp Thank you for the feedback. Taking your advice, I created a GitLab account and submitted the files that way as the primary download. While more work to set up initially, it is a more elegant solution.
Thanks for the code, there is an error on the udev rules, it should be RUN /usr/share/power-profiles/performance.sh and not /usr/share/performance.sh
For my dell laptop I had to modify the env variable to the following to work:
@Felipe_Gaete Good catch! I just updated the path on both files in the GitLab share. I don’t have an edit button to update the MEGA link anymore, so this is the new one in case GitLab gives anyone trouble: 892 byte file on MEGA
In KDE, this can be set up in the GUI, under Settings - Power Management - Energy Saver . Then, on each event tab, check “Run” and select a script (you may need to copy or create the scripts that call powerprofilesctl, user scripts work just fine).
Thank you for this! It works flawlessly over the past couple of days. I noticed you had typed
/usr/shares/... in multiple spots, which wouldn’t work on my install (I think it was a typo?), so I updated them to
I’ve forked and updated your script here and created a merge request if you’d like to add my changes to your script.
Thanks again! This works great!
@Jay_Vogt Thank you very much for this. I reviewed the changes in your merge request, and they are all positive. The merge request has been approved, and the project has been updated to reflect these changes.