Skip to content

Commit

Permalink
Add timer to automatically change theme
Browse files Browse the repository at this point in the history
  • Loading branch information
chase9 committed Jan 14, 2025
1 parent 508b167 commit ffb5837
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
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)

0 comments on commit ffb5837

Please sign in to comment.