#!/usr/bin/env python3

# breezydesktop.in
#
# Copyright 2024 Unknown
#
# 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 <https://www.gnu.org/licenses/>.
#
# SPDX-License-Identifier: GPL-3.0-or-later

import os
import sys

xdg_data_home = os.getenv('XDG_DATA_HOME', os.path.join(os.path.expanduser('~'), '.local', 'share'))
appdir = os.getenv('APPDIR', xdg_data_home) 
locale_dir = os.path.join(appdir, 'locale')
pkgdatadir = os.path.join(appdir, 'breezydesktop')
sys.path.insert(1, pkgdatadir)

lib_dir = os.path.join(pkgdatadir, 'breezydesktop', 'lib')
sys.path.insert(0, lib_dir)

import signal
import locale
import gettext

VERSION = '2.1.6'

signal.signal(signal.SIGINT, signal.SIG_DFL)
locale.textdomain('breezydesktop')
locale.setlocale(locale.LC_ALL, locale.getlocale())
locale.bindtextdomain('breezydesktop', locale_dir)
gettext.install('breezydesktop', locale_dir)
gettext.bindtextdomain('breezydesktop', locale_dir)
gettext.textdomain('breezydesktop')

if __name__ == '__main__':
    import gi

    from gi.repository import Gio
    resource = Gio.Resource.load(os.path.join(pkgdatadir, 'breezydesktop.gresource'))
    resource._register()

    from breezydesktop import main
    sys.exit(main.main(VERSION))
