From 25c9ed9fa395ad900f8d0fbb287baa3d963edf50 Mon Sep 17 00:00:00 2001 From: Vinicius Moreira Date: Thu, 25 Nov 2021 15:57:59 -0300 Subject: [PATCH] [api] refactoring: custom themes dir for root user is now /usr/share/bauh/themes --- CHANGELOG.md | 1 + README.md | 2 +- bauh/api/paths.py | 2 +- bauh/stylesheet.py | 4 ++-- 4 files changed, 5 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 97a9445f..96618bb1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). - configuration: `/etc/bauh` - temp dir: `/tmp/bauh@root` (`/tmp/bauh@$USER` for non root users) - autostart: `/etc/xdg/autostart` (only used by the Web gem at the moment) + - custom themes: `/usr/share/bauh/themes` - UI - settings panel: diff --git a/README.md b/README.md index a12b7d9a..a0d07e6b 100644 --- a/README.md +++ b/README.md @@ -416,7 +416,7 @@ boot: #### Custom themes -- Custom themes can be provided by adding their files at `~/.local/share/bauh/themes` (sub-folders are allowed). +- Custom themes can be provided by adding their files at `~/.local/share/bauh/themes` (or `/usr/share/bauh/themes` for **root**). Sub-folders are allowed. - Themes are composed by 2 required and 1 optional files sharing the same name: - `my_theme.qss`: file with the qss rules. Full example: [light.qss](https://github.com/vinifmor/bauh/blob/master/bauh/view/resources/style/light/light.qss) - `my_theme.meta`: file defining the theme's data. Full example: [light.meta](https://github.com/vinifmor/bauh/blob/master/bauh/view/resources/style/light/light.meta) diff --git a/bauh/api/paths.py b/bauh/api/paths.py index 62e9522e..88be86c4 100644 --- a/bauh/api/paths.py +++ b/bauh/api/paths.py @@ -6,7 +6,7 @@ from bauh.api import user CACHE_PATH = f'/var/cache/{__app_name__}' if user.is_root() else f'{Path.home()}/.cache/{__app_name__}' CONFIG_DIR = f'/etc/{__app_name__}' if user.is_root() else f'{Path.home()}/.config/{__app_name__}' -USER_THEMES_PATH = '{}/.local/share/bauh/themes'.format(str(Path.home())) +USER_THEMES_DIR = f'/usr/share/{__app_name__}/themes' if user.is_root() else f'{Path.home()}/.local/share/{__app_name__}/themes' DESKTOP_ENTRIES_DIR = '{}/.local/share/applications'.format(str(Path.home())) TEMP_DIR = f'/tmp/{__app_name__}@{getuser()}' LOGS_DIR = f'{TEMP_DIR}/logs' diff --git a/bauh/stylesheet.py b/bauh/stylesheet.py index 445ff9ba..37584c6e 100644 --- a/bauh/stylesheet.py +++ b/bauh/stylesheet.py @@ -3,7 +3,7 @@ import os import re from typing import Optional, Dict, Tuple, Set -from bauh.api.paths import USER_THEMES_PATH +from bauh.api.paths import USER_THEMES_DIR from bauh.view.util import resource from bauh.view.util.translation import I18n @@ -114,7 +114,7 @@ def read_default_themes() -> Dict[str, str]: def read_user_themes() -> Dict[str, str]: - return {f: f for f in glob.glob('{}/**/*.qss'.format(USER_THEMES_PATH), recursive=True)} + return {f: f for f in glob.glob('{}/**/*.qss'.format(USER_THEMES_DIR), recursive=True)} def read_all_themes_metadata() -> Set[ThemeMetadata]: