-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
74 lines (60 loc) · 2.28 KB
/
main.py
File metadata and controls
74 lines (60 loc) · 2.28 KB
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
#!/usr/bin/env python
# M O O N L I G H T
# _..._ _..._ _..._ _..._ _..._
# .:::::::. .::::. `. .:::: `. .::' `. .' `.
# ::::::::::: :::::::. : :::::: : ::: : : :
# ::::::::::: :::::::: : :::::: : ::: : : :
# `:::::::::' `::::::' .' `::::: .' `::. .' `. .'
# `':::'' `'::'-' `'::.-' `':..-' `-...-'
#
# ---------------------------------------------------------------------->
# ┌┬┐┌─┐┌─┐┌┐┌┬ ┬┌─┐┬ ┬┌┬┐
# ││││ ││ │││││ ││ ┬├─┤ │
# ┴ ┴└─┘└─┘┘└┘┴─┘┴└─┘┴ ┴ ┴
# ---------------------------------->
# -------------------------->
#
# Copyright (c) 2025 maarutan. \ Marat Arzymatov All Rights Reserved.
# Author: Marat Arzymatov \ maarutan
# Github.com: https://github.com/maarutan
# License: MIT
#
import os
import sys
import signal
import atexit
from loguru import logger
from widgets.core.widgets_handler import WidgetsHandler
from fabric.utils.helpers import idle_add
# from modules.cavalade.utils import kill_all_cava_pids
Handler = WidgetsHandler()
# killall active cava instances if app is closed
# atexit.register(kill_all_cava_pids)
def restart():
logger.info("\n\nRestarting Moonlight...\n")
try:
# kill_all_cava_pids()
Handler.app.quit()
except Exception as e:
logger.warning(f"\nGraceful quit failed: {e}")
finally:
os.execv(sys.executable, [sys.executable] + sys.argv)
def handle_sighup(*_):
idle_add(restart)
def main():
signal.signal(signal.SIGHUP, handle_sighup)
Handler.app.run()
if __name__ == "__main__":
try:
main()
except KeyboardInterrupt:
# kill_all_cava_pids()
Handler.app.quit()
except Exception as e:
# kill_all_cava_pids()
logger.error(f"Failed to run the application: {e}")
sys.exit(1)
# ---------------------------------------------------------------------------->
# ---------------------------------------------------------------------->
# -------------------------------------------------------------->
# ----------------------------------------------->