#!/usr/bin/python3

# oversteer
#
# Copyright (C) 2019 Bernat Arlandis <berarma@hotmail.com>
#
# This program 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.
#
# This program 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 this program.  If not, see <http://www.gnu.org/licenses/>.

import os
import sys
import signal
import locale

sys.path.insert(1, '/usr/lib/python3.13/site-packages/')

version = '0.8.3'
pkgdatadir = '/usr/share/oversteer'
localedir = '/usr/share/locale'
icondir = '/usr/share/icons/hicolor/scalable/apps'
builddir = os.environ.get('MESON_BUILD_ROOT')
if builddir:
    srcdir = os.environ['MESON_SOURCE_ROOT']
    pkgdatadir = os.path.join(builddir, 'data')
    sys.dont_write_bytecode = True
    sys.path.insert(1, srcdir)
    icondir = os.path.join(srcdir, 'data')
    if not os.path.exists(os.path.join(builddir, 'data/udev')):
        os.symlink(os.path.join(srcdir, 'data/udev'),
                os.path.join(builddir, 'data/udev'))

signal.signal(signal.SIGINT, signal.SIG_DFL)

locale.bindtextdomain('oversteer', localedir)
locale.textdomain('oversteer')
if 'LC_ALL' in os.environ and os.environ['LC_ALL'] == 'C' and 'LANG' in os.environ and os.environ['LANG']:
    os.environ['LC_ALL'] = os.environ['LANG']
locale.setlocale(locale.LC_ALL, '')

if __name__ == '__main__':
    from oversteer.application import Application
    app = Application(version, pkgdatadir, icondir)
    sys.exit(app.run(sys.argv))
