50 lines
1.4 KiB
Python
50 lines
1.4 KiB
Python
#!/usr/bin/env python3
|
|
|
|
from .. import versions
|
|
from ..utilities.config import Configuration
|
|
from gi.repository import Astal, Gio, AstalIO
|
|
from gi.events import GLibEventLoopPolicy
|
|
from pathlib import Path
|
|
import sys
|
|
import logging
|
|
import asyncio
|
|
from sdbus import request_default_bus_name_async, sd_bus_open_user, set_default_bus
|
|
|
|
asyncio.set_event_loop_policy(GLibEventLoopPolicy())
|
|
|
|
logger = logging.getLogger(__name__)
|
|
|
|
|
|
class App(Astal.Application):
|
|
|
|
def do_astal_application_request(self, msg: str, conn: Gio.SocketConnection):
|
|
print(msg)
|
|
AstalIO.write_sock(conn, "hello")
|
|
|
|
def do_activate(self) -> None:
|
|
self.hold()
|
|
logger.info("Loading configuration")
|
|
config = Configuration(Path("~/.config/VoidShell/config").expanduser())
|
|
self.apply_css(str(config.css_file), True)
|
|
set_default_bus(sd_bus_open_user())
|
|
asyncio.get_event_loop().create_task(
|
|
request_default_bus_name_async("dev.ezri.VoidShell")
|
|
)
|
|
logger.info("VoidShell up and running")
|
|
# TODO: implement application startup logic
|
|
|
|
|
|
def doStartup(app: App):
|
|
logging.basicConfig(level=logging.INFO)
|
|
app.acquire_socket()
|
|
app.run(None)
|
|
|
|
|
|
def main():
|
|
app = App(instance_name="VoidShell")
|
|
try:
|
|
doStartup(app)
|
|
except Exception:
|
|
print("Error: VoidShell is already running")
|
|
sys.exit(1)
|