1
0
Fork 0
forked from wry/wry

theme: add title-font and bar-font settings

This commit is contained in:
Julian Orth 2025-09-17 18:37:13 +02:00
parent 01f9c094ee
commit 035e2972de
14 changed files with 116 additions and 11 deletions

View file

@ -197,6 +197,8 @@ pub struct Theme {
pub title_height: Option<i32>,
pub bar_height: Option<i32>,
pub font: Option<String>,
pub title_font: Option<String>,
pub bar_font: Option<String>,
}
#[derive(Debug, Clone)]

View file

@ -60,7 +60,9 @@ impl Parser for ThemeParser<'_> {
title_height,
bar_height,
font,
title_font,
),
(bar_font,),
) = ext.extract((
(
opt(val("attention-requested-bg-color")),
@ -84,7 +86,9 @@ impl Parser for ThemeParser<'_> {
recover(opt(s32("title-height"))),
recover(opt(s32("bar-height"))),
recover(opt(str("font"))),
recover(opt(str("title-font"))),
),
(recover(opt(str("bar-font"))),),
))?;
macro_rules! color {
($e:expr) => {
@ -120,6 +124,8 @@ impl Parser for ThemeParser<'_> {
title_height: title_height.despan(),
bar_height: bar_height.despan(),
font: font.map(|f| f.value.to_string()),
title_font: title_font.map(|f| f.value.to_string()),
bar_font: bar_font.map(|f| f.value.to_string()),
})
}
}

View file

@ -41,7 +41,7 @@ use {
set_show_float_pin_icon, set_ui_drag_enabled, set_ui_drag_threshold,
status::{set_i3bar_separator, set_status, set_status_command, unset_status_command},
switch_to_vt,
theme::{reset_colors, reset_font, reset_sizes, set_font},
theme::{reset_colors, reset_font, reset_sizes, set_bar_font, set_font, set_title_font},
toggle_float_above_fullscreen, toggle_show_bar,
video::{
ColorSpace, Connector, DrmDevice, Eotf, connectors, drm_devices,
@ -894,9 +894,16 @@ impl State {
size!(BORDER_WIDTH, border_width);
size!(TITLE_HEIGHT, title_height);
size!(BAR_HEIGHT, bar_height);
if let Some(font) = &theme.font {
set_font(font);
macro_rules! font {
($fun:ident, $field:ident) => {
if let Some(font) = &theme.$field {
$fun(font);
}
};
}
font!(set_font, font);
font!(set_title_font, title_font);
font!(set_bar_font, bar_font);
}
fn handle_switch_device(self: &Rc<Self>, dev: InputDevice, actions: &Rc<SwitchActions>) {