mirror of
https://github.com/Starlio-app/StarlioX
synced 2024-12-25 14:03:46 +03:00
Added Linux support
This commit is contained in:
parent
be9c3c2093
commit
8240cb1fba
1 changed files with 63 additions and 0 deletions
63
src/linux/main.py
Normal file
63
src/linux/main.py
Normal file
|
@ -0,0 +1,63 @@
|
|||
from pystray import MenuItem, Menu, Icon
|
||||
from PIL import Image
|
||||
|
||||
import notify2
|
||||
import schedule
|
||||
import os
|
||||
import sys
|
||||
import psutil
|
||||
import time
|
||||
|
||||
path = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
||||
sys.path.insert(0, path)
|
||||
|
||||
# noinspection PyUnresolvedReferences
|
||||
from functions.wallpaper import Wallpaper
|
||||
|
||||
|
||||
class Nasa(Wallpaper):
|
||||
def __init__(self):
|
||||
super().__init__()
|
||||
|
||||
@staticmethod
|
||||
def resource_path(relative_path):
|
||||
base_path = getattr(sys, '_MEIPASS', os.path.dirname(os.path.abspath(__file__)))
|
||||
return os.path.join(base_path, relative_path)
|
||||
|
||||
def tray(self):
|
||||
tray = Icon("EveryNasa",
|
||||
title="EveryNasa",
|
||||
icon=Image.open(self.resource_path("./icons/icon.ico")),
|
||||
menu=Menu(
|
||||
MenuItem("Выход",
|
||||
self.kill_program),
|
||||
))
|
||||
tray.run()
|
||||
|
||||
def kill_program(self):
|
||||
for proc in psutil.process_iter():
|
||||
if proc.name() == "EveryNasa":
|
||||
proc.kill()
|
||||
|
||||
@staticmethod
|
||||
def notify(title, message):
|
||||
notify2.init("EveryNasa")
|
||||
notice = notify2.Notification(title, message)
|
||||
notice.show()
|
||||
return
|
||||
|
||||
def main(self):
|
||||
wall_check = Wallpaper.check(self)
|
||||
Wallpaper.download(self)
|
||||
wall_set = Wallpaper.set()
|
||||
self.notify("EveryNasa", wall_check or wall_set)
|
||||
|
||||
|
||||
nasa = Nasa()
|
||||
nasa.main()
|
||||
|
||||
schedule.every(3).hours.do(nasa.main)
|
||||
while True:
|
||||
schedule.run_pending()
|
||||
nasa.tray()
|
||||
time.sleep(1)
|
Loading…
Add table
Reference in a new issue