diff options
author | Olivier Gayot <olivier.gayot@sigexec.com> | 2018-11-29 22:15:28 +0100 |
---|---|---|
committer | Olivier Gayot <olivier.gayot@sigexec.com> | 2018-11-29 22:40:57 +0100 |
commit | 0527d1069a879cd9200e56a5f68f86461a019fb7 (patch) | |
tree | 1401e98b3e9f0e68f87c29ca65776a41f03ff543 | |
parent | 0fe257ed917433231a0ca3b3755c8519c808c03a (diff) |
Add policykit configuration to allow setting as user
When the script is installed as /usr/local/bin/brightness, the policykit
configuration files allow the user sitting in front of the computer to
set the brightness as a non-privileged user.
Signed-off-by: Olivier Gayot <olivier.gayot@sigexec.com>
-rw-r--r-- | polkit-1/actions/com.sigexec.polkit.set-brightness.policy | 21 | ||||
-rw-r--r-- | polkit-1/rules/90-set-brightness.rules | 9 |
2 files changed, 30 insertions, 0 deletions
diff --git a/polkit-1/actions/com.sigexec.polkit.set-brightness.policy b/polkit-1/actions/com.sigexec.polkit.set-brightness.policy new file mode 100644 index 0000000..352e8bf --- /dev/null +++ b/polkit-1/actions/com.sigexec.polkit.set-brightness.policy @@ -0,0 +1,21 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE policyconfig PUBLIC "-//freedesktop//DTD polkit Policy Configuration 1.0//EN" +"http://www.freedesktop.org/software/polkit/policyconfig-1.dtd"> +<policyconfig> + + <vendor>Olivier Gayot</vendor> + <vendor_url>http://sigexec.com</vendor_url> + + <action id="com.sigexec.polkit.set-brightness"> + <description>Set the brightness of the monitor</description> + <description xml:lang="fr">Règle la luminosité de l'écran</description> + <defaults> + <allow_any>no</allow_any> + <allow_inactive>no</allow_inactive> + <allow_active>auth_admin_keep</allow_active> + </defaults> + <annotate key="org.freedesktop.policykit.exec.path">/usr/local/bin/brightness</annotate> + <annotate key="org.freedesktop.policykit.exec.argv1">set</annotate> + </action> + +</policyconfig> diff --git a/polkit-1/rules/90-set-brightness.rules b/polkit-1/rules/90-set-brightness.rules new file mode 100644 index 0000000..f8b158a --- /dev/null +++ b/polkit-1/rules/90-set-brightness.rules @@ -0,0 +1,9 @@ +polkit.addRule(function(action, subject) { + if (1 + && action.id == "com.sigexec.polkit.set-brightness" + && subject.seat == "seat0" + ) + { + return polkit.Result.YES; + } +}); |