-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path10-archtask-pro.rules
More file actions
51 lines (46 loc) Β· 2 KB
/
10-archtask-pro.rules
File metadata and controls
51 lines (46 loc) Β· 2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
/*
* /usr/share/polkit-1/rules.d/10-archtask-pro.rules
*
* ArchTask-Pro GUI β Polkit Rule
* ==============================
* Grants members of the "wheel" group passwordless access to:
* 1. cpupower β CPU governor switching
* 2. systemctl β service start/stop/restart/enable/disable
* 3. kill β terminate system processes
*
* Install:
* sudo install -Dm644 polkit/10-archtask-pro.rules \
* /usr/share/polkit-1/rules.d/10-archtask-pro.rules
*
* For a single user instead of wheel group, change:
* subject.isInGroup("wheel")
* to:
* subject.user == "yourusername"
*/
polkit.addRule(function(action, subject) {
// ββ cpupower (CPU governor) βββββββββββββββββββββββββββββββββββββββββββββββ
if (action.id === "org.freedesktop.policykit.exec") {
var prog = action.lookup("program") || "";
if ((prog.indexOf("cpupower") !== -1) && subject.isInGroup("wheel")) {
return polkit.Result.YES;
}
// ββ systemctl service management βββββββββββββββββββββββββββββββββββββ
if ((prog === "/usr/bin/systemctl" || prog === "/bin/systemctl") &&
subject.isInGroup("wheel"))
{
var cmd = action.lookup("command_line") || "";
var allowed = ["start", "stop", "restart", "enable", "disable"];
for (var i = 0; i < allowed.length; i++) {
if (cmd.indexOf("systemctl " + allowed[i]) !== -1) {
return polkit.Result.YES;
}
}
}
// ββ kill (for system processes) βββββββββββββββββββββββββββββββββββββββ
if ((prog === "/bin/kill" || prog === "/usr/bin/kill") &&
subject.isInGroup("wheel"))
{
return polkit.Result.YES;
}
}
});