aboutsummaryrefslogtreecommitdiff
path: root/.local/share/Anki2/addons21
diff options
context:
space:
mode:
authorLoek Le Blansch <loek@pipeframe.xyz>2024-05-28 09:57:23 +0200
committerLoek Le Blansch <loek@pipeframe.xyz>2024-05-28 09:57:23 +0200
commit53445eeb3210b43079182a2c9cb1659a995ecbe8 (patch)
tree6a55c254161065ea44f3e0ffd8caa076e28b6d77 /.local/share/Anki2/addons21
parent5a0fe3f9b3ff73329c6d38d23540f2b36d01dee8 (diff)
automatically change anki light/dark mode to mode theme
Diffstat (limited to '.local/share/Anki2/addons21')
-rw-r--r--.local/share/Anki2/addons21/mode/__init__.py18
1 files changed, 18 insertions, 0 deletions
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))
+