File: kcolorschemewatcher.py

package info (click to toggle)
kf6-kguiaddons 6.23.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,152 kB
  • sloc: cpp: 6,656; xml: 401; python: 108; java: 74; ansic: 18; sh: 13; makefile: 11
file content (31 lines) | stat: -rwxr-xr-x 861 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#!/usr/bin/env python3

# SPDX-FileCopyrightText: 2025 Nicolas Fella <nicolas.fella@gmx.de>
# SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL

import sys

from KGuiAddons import KColorSchemeWatcher

from PySide6 import QtCore

def print_preference(preference):
    if preference == KColorSchemeWatcher.NoPreference:
        print("No preference")
    if preference == KColorSchemeWatcher.PreferDark:
        print("Dark")
    if preference == KColorSchemeWatcher.PreferLight:
        print("Light")
    if preference == KColorSchemeWatcher.PreferHighContrast:
        print("High Contrast")


app = QtCore.QCoreApplication()

watcher = KColorSchemeWatcher()

print_preference(watcher.systemPreference())

watcher.systemPreferenceChanged.connect(lambda: print_preference(watcher.systemPreference()))

sys.exit(app.exec())