xkb
sezanzeb 4 years ago committed by sezanzeb
parent 7237f43369
commit b68b958160

@ -41,6 +41,6 @@ sudo python3 setup.py install && python3 tests/test.py
- [x] offer going back to the system default
- [x] highlight changes and alert before discarding unsaved changes
- [ ] automatically load the preset when the mouse connects
- [ ] ask for administrator permissions using polkit
- [x] ask for administrator permissions using polkit
- [ ] make it work on wayland
- [ ] add to the AUR, provide .deb and .appimage files

@ -53,6 +53,7 @@ if __name__ == '__main__':
if getpass.getuser() != 'root' and 'unittest' not in sys.modules.keys():
# TODO add a polkit thing like
# https://gitlab.manjaro.org/applications/pamac/-/tree/master/data/polkit
# https://gitlab.manjaro.org/applications/pamac/-/blob/master/src/daemon.vala#L260
# does this require a dependency?
logger.error('Needs to run with sudo')
ErrorDialog(

@ -2,7 +2,7 @@
Type=Application
Name=key-mapper
Icon=mouse
Exec=key-mapper-gtk
Exec=pkexec key-mapper-gtk
Terminal=false
Categories=Settings
Comment=GUI for device specific keyboard mappings

@ -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">/usr/bin/key-mapper-gtk</annotate>
<annotate key="org.freedesktop.policykit.exec.allow_gui">true</annotate>
</action>
</policyconfig>

@ -183,6 +183,10 @@ class Window:
def on_apply_system_layout_clicked(self, button):
"""Load the mapping."""
setxkbmap(self.selected_device, None)
self.get('status_bar').push(
CTX_APPLY,
f'Applied the system default'
)
def on_save_preset_clicked(self, button):
"""Save changes to a preset to the file system."""

@ -30,5 +30,6 @@ DistUtilsExtra.auto.setup(
data_files=[
('share/applications/', ['data/key-mapper.desktop']),
('share/key-mapper/', ['data/xkb_symbols_template']),
('share/polkit-1/actions/', ['data/org.key-mapper.policy']),
],
)

Loading…
Cancel
Save