| 1 | //! System font configuration. |
| 2 | use crate::title::font_preference::FontPreference; |
| 3 | use std::process::Command; |
| 4 | |
| 5 | /// Query system for which font to use for window titles. |
| 6 | pub(crate) fn titlebar_font() -> Option<FontPreference> { |
| 7 | // outputs something like: `'Cantarell Bold 12'` |
| 8 | let stdout: String = CommandOption::new(program:"gsettings" ) |
| 9 | .args(["get" , "org.gnome.desktop.wm.preferences" , "titlebar-font" ]) |
| 10 | .output() |
| 11 | .ok() |
| 12 | .and_then(|out: Output| String::from_utf8(vec:out.stdout).ok())?; |
| 13 | |
| 14 | FontPreference::from_name_style_size( |
| 15 | conf:stdout |
| 16 | .trim() |
| 17 | .trim_end_matches(' \'' ) |
| 18 | .trim_start_matches(' \'' ), |
| 19 | ) |
| 20 | } |
| 21 | |