correct prefix in .policy

xkb
sezanzeb 4 years ago committed by sezanzeb
parent 571ce264c5
commit 2159328b8e

@ -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.

@ -1,8 +1,8 @@
<?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"
>
"-//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">
@ -13,7 +13,7 @@
<allow_inactive>auth_admin</allow_inactive>
<allow_active>auth_admin</allow_active>
</defaults>
<annotate key="org.freedesktop.policykit.exec.path">/usr/bin/key-mapper-gtk</annotate>
<annotate key="org.freedesktop.policykit.exec.path">{executable}</annotate>
<annotate key="org.freedesktop.policykit.exec.allow_gui">true</annotate>
</action>
</policyconfig>

@ -19,9 +19,39 @@
# 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."""
executable = os.path.join(self.install_data, 'bin/key-mapper-gtk')
assert os.path.exists(executable)
policy_path = '/usr/share/polkit-1/actions/org.key-mapper.policy'
with open(policy_path, 'r') as f:
contents = f.read()
if '{executable}' not in contents:
# already done previously
return
with open(policy_path, 'w') as f:
print(
f'Inserting the correct path "{executable}" into '
'org.key-mapper.policy'
)
f.write(contents.format(
executable=executable
))
DistUtilsExtra.auto.setup(
name='key-mapper',
version='0.1.0',
@ -29,6 +59,9 @@ DistUtilsExtra.auto.setup(
license='GPL-3.0',
data_files=[
('share/applications/', ['data/key-mapper.desktop']),
('share/polkit-1/actions/', ['data/org.key-mapper.policy']),
('/usr/share/polkit-1/actions/', ['data/org.key-mapper.policy']),
],
cmdclass={
'install': Install
}
)

Loading…
Cancel
Save