correct prefix in .policy

pull/14/head
sezanzeb 4 years ago
parent 9da5651a1c
commit efa5c3a7de

@ -14,7 +14,7 @@ will likely work.
# Running
```bash
sudo python3 setup.py install --prefix /usr && sudo key-mapper-gtk -d
sudo python3 setup.py install && sudo key-mapper-gtk -d
```
You can also start it via your applications menu.

@ -0,0 +1,19 @@
<?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>
<icon_name>mouse</icon_name>
<action id="org.key-mapper">
<description>Run Key Mapper as root</description>
<message>Authentication is required to discover devices and write configs.</message>
<defaults>
<allow_any>no</allow_any>
<allow_inactive>auth_admin</allow_inactive>
<allow_active>auth_admin</allow_active>
</defaults>
<annotate key="org.freedesktop.policykit.exec.path">{executable}</annotate>
<annotate key="org.freedesktop.policykit.exec.allow_gui">true</annotate>
</action>
</policyconfig>

@ -19,9 +19,38 @@
# along with key-mapper. If not, see <https://www.gnu.org/licenses/>.
import os
import DistUtilsExtra.auto
class Install(DistUtilsExtra.auto.install_auto):
def run(self):
DistUtilsExtra.auto.install_auto.run(self)
self.ensure_polkit_prefix()
def ensure_polkit_prefix(self):
"""Make sure the policy file uses the right prefix."""
policy_path = os.path.join(
self.install_data,
'share/polkit-1/actions/org.key-mapper.policy'
)
executable = os.path.join(self.install_data, 'bin/key-mapper-gtk')
assert os.path.exists(executable)
with open(policy_path, 'r') as f:
contents = f.read()
if not '{executable}':
# already done previously
return
with open(policy_path, 'w') as f:
f.write(contents.format(
executable=executable
))
DistUtilsExtra.auto.setup(
name='key-mapper',
version='0.1.0',
@ -31,4 +60,7 @@ DistUtilsExtra.auto.setup(
('share/applications/', ['data/key-mapper.desktop']),
('share/polkit-1/actions/', ['data/org.key-mapper.policy']),
],
cmdclass={
'install': Install
}
)

Loading…
Cancel
Save