2020-10-26 22:45:22 +00:00
|
|
|
#!/usr/bin/python3
|
|
|
|
# -*- coding: utf-8 -*-
|
2020-10-31 13:43:09 +00:00
|
|
|
# key-mapper - GUI for device specific keyboard mappings
|
2021-02-22 18:48:20 +00:00
|
|
|
# Copyright (C) 2020 sezanzeb <proxima@sezanzeb.de>
|
2020-10-26 22:45:22 +00:00
|
|
|
#
|
2020-10-31 13:02:59 +00:00
|
|
|
# This file is part of key-mapper.
|
2020-10-26 22:45:22 +00:00
|
|
|
#
|
2020-10-31 13:02:59 +00:00
|
|
|
# key-mapper is free software: you can redistribute it and/or modify
|
2020-10-26 22:45:22 +00:00
|
|
|
# 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.
|
|
|
|
#
|
2020-10-31 13:02:59 +00:00
|
|
|
# key-mapper is distributed in the hope that it will be useful,
|
2020-10-26 22:45:22 +00:00
|
|
|
# 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
|
2020-10-31 13:02:59 +00:00
|
|
|
# along with key-mapper. If not, see <https://www.gnu.org/licenses/>.
|
2020-10-26 22:45:22 +00:00
|
|
|
|
|
|
|
|
2020-11-09 22:43:34 +00:00
|
|
|
"""Starts the user interface."""
|
|
|
|
|
2020-10-26 22:45:22 +00:00
|
|
|
|
|
|
|
import sys
|
2020-11-18 12:17:49 +00:00
|
|
|
import atexit
|
2020-10-26 22:45:22 +00:00
|
|
|
from argparse import ArgumentParser
|
|
|
|
|
|
|
|
import gi
|
|
|
|
gi.require_version('Gtk', '3.0')
|
|
|
|
gi.require_version('GLib', '2.0')
|
2020-12-04 16:45:51 +00:00
|
|
|
from gi.repository import Gtk
|
2020-10-26 22:45:22 +00:00
|
|
|
|
2021-02-07 14:00:36 +00:00
|
|
|
# https://github.com/Nuitka/Nuitka/issues/607#issuecomment-650217096
|
|
|
|
Gtk.init()
|
|
|
|
|
2020-11-22 20:04:09 +00:00
|
|
|
from keymapper.logger import update_verbosity, log_info
|
2020-10-31 16:43:21 +00:00
|
|
|
|
|
|
|
|
2020-10-26 22:45:22 +00:00
|
|
|
if __name__ == '__main__':
|
|
|
|
parser = ArgumentParser()
|
|
|
|
parser.add_argument(
|
|
|
|
'-d', '--debug', action='store_true', dest='debug',
|
|
|
|
help='Displays additional debug information',
|
|
|
|
default=False
|
|
|
|
)
|
|
|
|
|
|
|
|
options = parser.parse_args(sys.argv[1:])
|
|
|
|
update_verbosity(options.debug)
|
2021-03-21 18:15:20 +00:00
|
|
|
log_info('key-mapper-gtk')
|
2020-10-26 22:45:22 +00:00
|
|
|
|
2021-02-07 14:00:36 +00:00
|
|
|
# import key-mapper stuff after setting the log verbosity
|
2021-02-13 19:34:33 +00:00
|
|
|
from keymapper.gui.window import Window
|
2021-02-07 14:00:36 +00:00
|
|
|
from keymapper.daemon import Daemon
|
2021-03-21 18:15:20 +00:00
|
|
|
from keymapper.daemon import config
|
|
|
|
|
|
|
|
config.load_config()
|
2021-02-07 14:00:36 +00:00
|
|
|
|
2020-11-09 22:47:54 +00:00
|
|
|
window = Window()
|
2020-11-08 20:08:07 +00:00
|
|
|
|
2020-11-30 18:40:17 +00:00
|
|
|
def stop():
|
2020-11-22 20:04:09 +00:00
|
|
|
if isinstance(window.dbus, Daemon):
|
|
|
|
# it created its own temporary daemon inside the process
|
|
|
|
# because none was running
|
2021-02-07 14:00:36 +00:00
|
|
|
window.dbus.stop_all()
|
2020-12-04 14:06:47 +00:00
|
|
|
|
2020-11-30 18:40:17 +00:00
|
|
|
window.on_close()
|
2020-11-18 12:17:49 +00:00
|
|
|
|
2020-11-30 18:40:17 +00:00
|
|
|
atexit.register(stop)
|
2020-11-18 12:17:49 +00:00
|
|
|
|
2020-11-09 22:43:34 +00:00
|
|
|
Gtk.main()
|