1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
//! System font configuration.
use crate::title::font_preference::FontPreference;
use std::process::Command;

/// Query system for which font to use for window titles.
pub(crate) fn titlebar_font() -> Option<FontPreference> {
    // outputs something like: `'Cantarell Bold 12'`
    let stdout = Command::new("gsettings")
        .args(["get", "org.gnome.desktop.wm.preferences", "titlebar-font"])
        .output()
        .ok()
        .and_then(|out| String::from_utf8(out.stdout).ok())?;

    FontPreference::from_name_style_size(
        stdout
            .trim()
            .trim_end_matches('\'')
            .trim_start_matches('\''),
    )
}