forked from libratbag/piper
-
Notifications
You must be signed in to change notification settings - Fork 0
/
piper.in
executable file
·47 lines (36 loc) · 1.26 KB
/
piper.in
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#!/usr/bin/env python3
import gi
import os
import sys
gi.require_version('Gio', '2.0')
gi.require_version('Gtk', '3.0')
from gi.repository import Gio, Gtk
gtk_version = Gtk.get_major_version(), Gtk.get_minor_version()
if gtk_version < (@gtk_major_version@, @gtk_minor_version@):
print("Version of GTK is too old, @gtk_major_version@.@gtk_minor_version@ required", file=sys.stderr)
sys.exit(1)
@devel@
resource = Gio.resource_load(os.path.join('@pkgdatadir@', 'piper.gresource'))
Gio.Resource._register(resource)
def install_excepthook():
"""Make sure we exit when an unhandled exception occurs."""
old_hook = sys.excepthook
def new_hook(etype, evalue, etb):
old_hook(etype, evalue, etb)
while Gtk.main_level():
Gtk.main_quit()
sys.exit()
sys.excepthook = new_hook
if __name__ == "__main__":
import gettext
import locale
import signal
from piper.application import Application
install_excepthook()
locale.bindtextdomain('piper', '@localedir@')
locale.textdomain('piper')
gettext.bindtextdomain('piper', '@localedir@')
gettext.textdomain('piper')
signal.signal(signal.SIGINT, signal.SIG_DFL)
exit_status = Application(@RATBAGD_API_VERSION@).run(sys.argv)
sys.exit(exit_status)