Skip to content

Commit

Permalink
Merge pull request #123 from cathaysia/cathaysia-kvantum-fluent
Browse files Browse the repository at this point in the history
feat: show all themes
  • Loading branch information
l0drex authored Oct 22, 2022
2 parents 9b84292 + a501524 commit f867b03
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions src/plugins/kvantum.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

from src.plugins._plugin import PluginCommandline
from pathlib import Path
import os


class Kvantum(PluginCommandline):
Expand All @@ -11,20 +12,25 @@ def __init__(self):
self.theme_light = 'KvFlatLight'
self.theme_dark = 'KvFlat'

@classmethod
def get_kvantum_theme_from_dir(cls, dir):
result = set()
for _, _, filenames in os.walk(dir):
for filename in filenames:
if filename.endswith('.kvconfig'):
result.add(filename[:-9])
return list(result)

@property
def available_themes(self) -> dict:
if not self.available:
return {}

paths = ['/usr/share/Kvantum', str(Path.home()) + '/.config/Kvantum']
# At present, it seems that the function of finding themes is based
# on dirs, but .kvconfig. So some theme will not be recognized. This
# may be fixed next time
themes = []
themes = list()
for path in paths:
with scandir(path) as entries:
themes = list(itertools.chain(themes, (f.name for f in entries if f.is_dir())))

themes = themes + self.get_kvantum_theme_from_dir(path)
themes_dict: dict = {}
assert len(themes) > 0, 'No themes were found'

themes.sort()
Expand Down

0 comments on commit f867b03

Please sign in to comment.