07-01-2020, 08:12 PM
Ok...figured it out. Posting this in case someone wants to do the same. I think this is a cool idea because it should squeeze out some more battery life and still allow the maximum speed when on AC. First of all, you should install nvme-cli and make sure that your nvme supports different power states. Check the wiki for info on that. I wrote a simple script called '/usr/bin/nvmelowpower.sh' which containes " #!/bin/sh sudo nvme set-feature /dev/nvme0 -f 2 -v 2" I also created a file called '/usr/bin/nvmehighpower.sh' which contains #!/bin/sh sudo nvme set-features /dev/nvme0 - 2 -v 0" Then I added "username ALL=(ALL) NOPASSWD: /usr/bin/nvme" to my /etc/sudoers file. I had to run "sudo chmod a+x /usr/bin/nvmelowpower.sh" and "sudo chmod a+x /usr/bin/nvmehighpower.sh" to make the files executable. Finally I opened up the KDE System settings "power management" menu. Under the "On AC Power" tab under "Run Script" I entered the script "/usr/bin/nvmehighpower.sh" Under the "On Battery" tab under "run Script" I entered "/usr/bin/nvmelowpower.sh" Now when I plug in the AC power my NVME runs at the maximum (for my drive) 4w. When I unplug my computer it runs at the maximum 2.2w. Not a lot, but every bit counts.