diff --git a/.idea/setxkbmap-gtk.iml b/.idea/setxkbmap-gtk.iml index bac9494a..09ef3c40 100644 --- a/.idea/setxkbmap-gtk.iml +++ b/.idea/setxkbmap-gtk.iml @@ -2,7 +2,9 @@ - + + + diff --git a/bin/key-mapper-gtk b/bin/key-mapper-gtk index c836423f..a4e22c2a 100755 --- a/bin/key-mapper-gtk +++ b/bin/key-mapper-gtk @@ -29,9 +29,9 @@ from argparse import ArgumentParser import gi gi.require_version('Gtk', '3.0') gi.require_version('GLib', '2.0') -from gi.repository import Gtk, GLib +from gi.repository import Gtk -from keymapper.util import find_devices +from keymapper.data import get_data_path from keymapper.logger import logger, update_verbosity, log_info @@ -44,7 +44,7 @@ class Window: builder.connect_signals(self) self.builder = builder - window = builder.get_object('key-mapper-gtk_window') + window = builder.get_object('window') window.show() self.window = window @@ -52,6 +52,10 @@ class Window: """Get a widget from the window""" return self.builder.get_object(name) + def on_close(self, *_): + """Safely close the application.""" + Gtk.main_quit() + if __name__ == '__main__': parser = ArgumentParser() diff --git a/data/key-mapper.glade b/data/key-mapper.glade index 0a7750ea..e670bce0 100644 --- a/data/key-mapper.glade +++ b/data/key-mapper.glade @@ -2,8 +2,9 @@ - + False + True diff --git a/keymapper/config.py b/keymapper/config.py index 0f2aaa24..85f98dca 100644 --- a/keymapper/config.py +++ b/keymapper/config.py @@ -30,17 +30,7 @@ from keymapper.logger import logger _config = None -_defaults = { - 'pcm_input': 'null', - 'input_use_dsnoop': True, - 'input_use_softvol': True, - 'input_plugin': 'hw', - 'pcm_output': 'null', - 'output_use_dmix': True, - 'output_use_softvol': True, - 'output_channels': 2, - 'output_plugin': 'hw' -} +_defaults = {} def _modify_config(config_contents, key, value): diff --git a/keymapper/data.py b/keymapper/data.py new file mode 100644 index 00000000..46bd1e89 --- /dev/null +++ b/keymapper/data.py @@ -0,0 +1,47 @@ +#!/usr/bin/python3 +# -*- coding: utf-8 -*- +# ALSA-Control - ALSA configuration interface +# Copyright (C) 2020 sezanzeb +# +# This file is part of ALSA-Control. +# +# ALSA-Control is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# ALSA-Control is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with ALSA-Control. If not, see . + + +"""Query settings.""" + + +import os +import site +import pkg_resources + + +def get_data_path(): + """Depending on the installation prefix, return the data dir.""" + source_path = pkg_resources.require('keymapper')[0].location + + # depending on where this file is installed to, make sure to use the proper + # prefix path for data + # https://docs.python.org/3/distutils/setupscript.html?highlight=package_data#installing-additional-files # noqa + if source_path.startswith(site.USER_BASE): + data_path = os.path.join(site.USER_BASE, 'share/key-mapper') + elif source_path.startswith('/usr/local/'): + data_path = '/usr/local/share/key-mapper' + elif source_path.startswith('/usr/'): + data_path = '/usr/share/key-mapper' + else: + # installed with -e, running from the cloned git source + data_path = os.path.join(source_path, 'data') + + return data_path