mirror of
https://github.com/labwc/labwc.git
synced 2026-04-01 07:15:52 -04:00
theme: support theme setting override
...by reading <config-dir>/themerc-override where <config-dir> is normally $HOME/.config/labwc can be other locations as described in labwc-config(5) and can also be specified by the command line option -C. The reason for supporting theme override is to give users more fine- grained control of settings without making local copies and modifying themes.
This commit is contained in:
parent
d82d8117f7
commit
af56b68041
7 changed files with 58 additions and 7 deletions
14
README.md
14
README.md
|
|
@ -168,12 +168,13 @@ For a step-by-step initial configuration guide, see [getting-started]
|
||||||
User config files are located at `${XDG_CONFIG_HOME:-$HOME/.config/labwc/}`
|
User config files are located at `${XDG_CONFIG_HOME:-$HOME/.config/labwc/}`
|
||||||
with the following four files being used:
|
with the following four files being used:
|
||||||
|
|
||||||
| file | man page
|
| file | man page
|
||||||
| ------------- | --------
|
| ------------------ | --------
|
||||||
| [rc.xml] | [labwc-config(5)], [labwc-actions(5)]
|
| [rc.xml] | [labwc-config(5)], [labwc-actions(5)]
|
||||||
| [menu.xml] | [labwc-menu(5)]
|
| [menu.xml] | [labwc-menu(5)]
|
||||||
| [autostart] | [labwc(1)]
|
| [autostart] | [labwc(1)]
|
||||||
| [environment] | [labwc-config(5)]
|
| [environment] | [labwc-config(5)]
|
||||||
|
| [themerc-override] | [labwc-theme(5)]
|
||||||
|
|
||||||
The example [rc.xml] has been kept simple. For all options and default values,
|
The example [rc.xml] has been kept simple. For all options and default values,
|
||||||
see [rc.xml.all]
|
see [rc.xml.all]
|
||||||
|
|
@ -259,6 +260,7 @@ See [integration] for further details.
|
||||||
[autostart]: docs/autostart
|
[autostart]: docs/autostart
|
||||||
[environment]: docs/environment
|
[environment]: docs/environment
|
||||||
[themerc]: docs/themerc
|
[themerc]: docs/themerc
|
||||||
|
[themerc-override]: docs/themerc
|
||||||
|
|
||||||
[labwc(1)]: https://labwc.github.io/labwc.1.html
|
[labwc(1)]: https://labwc.github.io/labwc.1.html
|
||||||
[labwc-config(5)]: https://labwc.github.io/labwc-config.5.html
|
[labwc-config(5)]: https://labwc.github.io/labwc-config.5.html
|
||||||
|
|
|
||||||
|
|
@ -3,5 +3,7 @@ Config layout for ~/.config/labwc/
|
||||||
- environment
|
- environment
|
||||||
- menu.xml
|
- menu.xml
|
||||||
- rc.xml
|
- rc.xml
|
||||||
|
- themerc-override
|
||||||
|
|
||||||
|
See `man labwc-config and `man labwc-theme` for further details.
|
||||||
|
|
||||||
See man labwc-config for further details.
|
|
||||||
|
|
|
||||||
|
|
@ -18,6 +18,9 @@ searched for in the following order:
|
||||||
- ${XDG_CONFIG_HOME:-$HOME/.config}/labwc
|
- ${XDG_CONFIG_HOME:-$HOME/.config}/labwc
|
||||||
- ${XDG_CONFIG_DIRS:-/etc/xdg}/labwc
|
- ${XDG_CONFIG_DIRS:-/etc/xdg}/labwc
|
||||||
|
|
||||||
|
The configuration directory location can be override with the -C command line
|
||||||
|
option.
|
||||||
|
|
||||||
All configuration and theme files except autostart are re-loaded on receiving
|
All configuration and theme files except autostart are re-loaded on receiving
|
||||||
signal SIGHUP.
|
signal SIGHUP.
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -20,6 +20,11 @@ the rc.xml configuration file (labwc-config(5)).
|
||||||
|
|
||||||
A theme consists of a themerc file and optionally some xbm icons.
|
A theme consists of a themerc file and optionally some xbm icons.
|
||||||
|
|
||||||
|
Theme settings specified in themerc can be overridden by creating a
|
||||||
|
'themerc-override' file in the configuration directory, which is normally
|
||||||
|
$HOME/.config/labwc/ but can be a few other locations as described in
|
||||||
|
labwc-config(5).
|
||||||
|
|
||||||
# DATA TYPES
|
# DATA TYPES
|
||||||
|
|
||||||
*color RGB values*
|
*color RGB values*
|
||||||
|
|
|
||||||
|
|
@ -30,6 +30,7 @@ install_data(
|
||||||
'environment',
|
'environment',
|
||||||
'menu.xml',
|
'menu.xml',
|
||||||
'README',
|
'README',
|
||||||
|
'themerc',
|
||||||
'rc.xml',
|
'rc.xml',
|
||||||
'rc.xml.all'
|
'rc.xml.all'
|
||||||
],
|
],
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,10 @@
|
||||||
|
# This file contains all themerc options with default values
|
||||||
|
#
|
||||||
|
# System-wide and local themes can be overridden by creating a copy of this
|
||||||
|
# file and renaming it to $HOME/.config/labwc/themerc-override. Be careful
|
||||||
|
# though - if you only want to override a small number of specific options,
|
||||||
|
# make sure all other lines are commented out or deleted.
|
||||||
|
|
||||||
# general
|
# general
|
||||||
border.width: 1
|
border.width: 1
|
||||||
padding.height: 3
|
padding.height: 3
|
||||||
|
|
|
||||||
31
src/theme.c
31
src/theme.c
|
|
@ -372,6 +372,32 @@ theme_read(struct theme *theme, const char *theme_name)
|
||||||
fclose(stream);
|
fclose(stream);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
theme_read_override(struct theme *theme)
|
||||||
|
{
|
||||||
|
char f[4096] = { 0 };
|
||||||
|
snprintf(f, sizeof(f), "%s/themerc-override", rc.config_dir);
|
||||||
|
|
||||||
|
FILE *stream = fopen(f, "r");
|
||||||
|
if (!stream) {
|
||||||
|
wlr_log(WLR_INFO, "no theme override '%s'", f);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
wlr_log(WLR_INFO, "read theme-override %s", f);
|
||||||
|
char *line = NULL;
|
||||||
|
size_t len = 0;
|
||||||
|
while (getline(&line, &len, stream) != -1) {
|
||||||
|
char *p = strrchr(line, '\n');
|
||||||
|
if (p) {
|
||||||
|
*p = '\0';
|
||||||
|
}
|
||||||
|
process_line(theme, line);
|
||||||
|
}
|
||||||
|
free(line);
|
||||||
|
fclose(stream);
|
||||||
|
}
|
||||||
|
|
||||||
struct rounded_corner_ctx {
|
struct rounded_corner_ctx {
|
||||||
struct wlr_box *box;
|
struct wlr_box *box;
|
||||||
double radius;
|
double radius;
|
||||||
|
|
@ -552,7 +578,12 @@ theme_init(struct theme *theme, const char *theme_name)
|
||||||
*/
|
*/
|
||||||
theme_builtin(theme);
|
theme_builtin(theme);
|
||||||
|
|
||||||
|
/* Read <data-dir>/share/themes/$theme_name/openbox-3/themerc */
|
||||||
theme_read(theme, theme_name);
|
theme_read(theme, theme_name);
|
||||||
|
|
||||||
|
/* Read <config-dir>/labwc/themerc-override */
|
||||||
|
theme_read_override(theme);
|
||||||
|
|
||||||
post_processing(theme);
|
post_processing(theme);
|
||||||
create_corners(theme);
|
create_corners(theme);
|
||||||
xbm_load(theme);
|
xbm_load(theme);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue