Skip to content

Commit

Permalink
move conservation mode scripts to pkexec she-bang, allowing all users…
Browse files Browse the repository at this point in the history
… to run them
  • Loading branch information
noahdotpy committed Jan 8, 2024
1 parent d5b784e commit af76740
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 3 deletions.
2 changes: 1 addition & 1 deletion config/files/usr/bin/conservationmodeoff
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
#!/usr/bin/env bash
#!/usr/bin/pkexec /usr/bin/env bash
echo -n "0" | tee /sys/bus/platform/drivers/ideapad_acpi/VPC2004:00/conservation_mode
2 changes: 1 addition & 1 deletion config/files/usr/bin/conservationmodeon
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
#!/usr/bin/env bash
#!/usr/bin/pkexec /usr/bin/env bash
echo -n "1" | tee /sys/bus/platform/drivers/ideapad_acpi/VPC2004:00/conservation_mode
2 changes: 1 addition & 1 deletion config/files/usr/bin/conservationmodestatus
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
#!/usr/bin/env bash
#!/usr/bin/pkexec /usr/bin/env bash
cat /sys/bus/platform/drivers/ideapad_acpi/VPC2004:00/conservation_mode
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@ polkit.addRule(function(action, subject) {
return polkit.Result.YES;
}
});

17 changes: 17 additions & 0 deletions config/files/usr/etc/polkit-1/rules.d/conservationmode.rules
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/* Allow members of the wheel group to execute the defined actions
* without password authentication, similar to "sudo NOPASSWD:"
*/
polkit.addRule(function(action, subject) {
if (
(action.id == "org.projectatomic.rpmostree1.upgrade") &&
(
action.lookup("program") == "/usr/bin/conservationmodeon" ||
action.lookup("program") == "/usr/bin/conservationmodeoff" ||
action.lookup("program") == "/usr/bin/conservationmodestatus"
)
)
{
return polkit.Result.YES;
}
});

0 comments on commit af76740

Please sign in to comment.