From 53445eeb3210b43079182a2c9cb1659a995ecbe8 Mon Sep 17 00:00:00 2001 From: Loek Le Blansch Date: Tue, 28 May 2024 09:57:23 +0200 Subject: automatically change anki light/dark mode to mode theme --- .local/share/Anki2/addons21/mode/__init__.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 .local/share/Anki2/addons21/mode/__init__.py (limited to '.local/share/Anki2/addons21') diff --git a/.local/share/Anki2/addons21/mode/__init__.py b/.local/share/Anki2/addons21/mode/__init__.py new file mode 100644 index 0000000..78d0d58 --- /dev/null +++ b/.local/share/Anki2/addons21/mode/__init__.py @@ -0,0 +1,18 @@ +#!/bin/python3 +from aqt import mw +from aqt.utils import tr +from aqt.theme import Theme +from os import environ +from pathlib import Path + +THEME_DARK = 2 +THEME_LIGHT = 1 + +path = Path(environ['XDG_CACHE_HOME'], 'mode/state/mode') +with path.open() as file: + mode = file.read().strip() + if mode == "dark": + mw.set_theme(Theme(THEME_DARK)) + if mode == "light": + mw.set_theme(Theme(THEME_LIGHT)) + -- cgit v1.2.3