Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add timer for checking themes #325

Open
wants to merge 1 commit into
base: beta
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions yin_yang/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,30 @@
from argparse import ArgumentParser
from logging.handlers import RotatingFileHandler
from pathlib import Path
from threading import Timer

from PySide6 import QtWidgets
from PySide6.QtCore import QTranslator, QLibraryInfo, QLocale, QObject
from PySide6.QtGui import QIcon
from PySide6.QtWidgets import QSystemTrayIcon, QMenu
from systemd import journal

from yin_yang.helpers import is_flatpak
from yin_yang.notification_handler import NotificationHandler
from yin_yang import daemon_handler
from yin_yang.meta import ConfigEvent
from yin_yang import theme_switcher
from yin_yang.config import config, Modes
from yin_yang.repeat_timer import RepeatTimer
from yin_yang.ui import main_window_connector

logger = logging.getLogger()
timer = RepeatTimer(45, theme_switcher.set_desired_theme)

if is_flatpak():
timer.daemon = True
timer.name = "Yin-Yang Timer"
timer.start()


def setup_logger(use_systemd_journal: bool):
Expand Down
7 changes: 7 additions & 0 deletions yin_yang/repeat_timer.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
from threading import Timer


class RepeatTimer(Timer):
def run(self):
while not self.finished.wait(self.interval):
self.function(*self.args, **self.kwargs)