mirror of
https://github.com/zoriya/noctalia-shell.git
synced 2026-08-15 18:43:59 +00:00
BatteryService: create placeholder policy to chagne charging treshold without password
This commit is contained in:
@@ -0,0 +1,17 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!DOCTYPE policyconfig PUBLIC
|
||||||
|
"-//freedesktop//DTD PolicyKit Policy Configuration 1.0//EN"
|
||||||
|
"http://www.freedesktop.org/standards/PolicyKit/1/policyconfig.dtd">
|
||||||
|
<policyconfig>
|
||||||
|
<action id="com.local.battery-manager.ACTUAL_USER_PLACEHOLDER">
|
||||||
|
<description>Manage battery settings for ACTUAL_USER_PLACEHOLDER</description>
|
||||||
|
<message>Authentication is required to manage battery settings</message>
|
||||||
|
<defaults>
|
||||||
|
<allow_any>no</allow_any>
|
||||||
|
<allow_inactive>no</allow_inactive>
|
||||||
|
<allow_active>yes</allow_active>
|
||||||
|
</defaults>
|
||||||
|
<annotate key="org.freedesktop.policykit.exec.path">/usr/bin/battery-manager-ACTUAL_USER_PLACEHOLDER</annotate>
|
||||||
|
<annotate key="org.freedesktop.policykit.exec.allow_gui">true</annotate>
|
||||||
|
</action>
|
||||||
|
</policyconfig>
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
polkit.addRule(function(action, subject) {
|
||||||
|
if (action.id == "com.local.battery-manager.ACTUAL_USER_PLACEHOLDER" &&
|
||||||
|
subject.user == "ACTUAL_USER_PLACEHOLDER") {
|
||||||
|
|
||||||
|
// Check if the parent process is quickshell or set-battery-threshold
|
||||||
|
var pid = subject.pid;
|
||||||
|
var ppid = polkit.spawn(["ps", "-o", "ppid=", "-p", pid.toString()]).trim();
|
||||||
|
var parentCmd = polkit.spawn(["ps", "-o", "comm=", "-p", ppid]).trim();
|
||||||
|
|
||||||
|
if (parentCmd.indexOf("quickshell") !== -1 || parentCmd.indexOf("set-battery-treshold") !== -1) {
|
||||||
|
return polkit.Result.YES;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
Reference in New Issue
Block a user