xkbcommon_rs_codegen/
config.rs1use std::fs::File;
4use std::io::{BufWriter, Write};
5use std::path::Path;
6
7fn xkb_config_root() -> &'static str {
8 "/usr/share/X11/xkb"
12}
13fn xkb_config_extra_path() -> &'static str {
14 "/etc/xkb"
17}
18
19fn xkb_default_rules() -> &'static str {
20 "evdev"
22}
23fn xkb_default_model() -> &'static str {
24 "pc105"
26}
27fn xkb_default_layout() -> &'static str {
28 "us"
30}
31fn xkb_default_variant() -> &'static str {
32 ""
34}
35fn xkb_default_options() -> &'static str {
36 ""
38}
39
40pub fn make_config(out_path: &Path) {
41 let mut out_file = BufWriter::new(File::create(out_path).unwrap());
42
43 let vars = vec![
44 ("DFLT_XKB_CONFIG_ROOT", xkb_config_root()),
45 ("DFLT_XKB_CONFIG_EXTRA_PATH", xkb_config_extra_path()),
46 ("DEFAULT_XKB_RULES", xkb_default_rules()),
47 ("DEFAULT_XKB_MODEL", xkb_default_model()),
48 ("DEFAULT_XKB_LAYOUT", xkb_default_layout()),
49 ("DEFAULT_XKB_VARIANT", xkb_default_variant()),
50 ("DEFAULT_XKB_OPTIONS", xkb_default_options()),
51 ];
53
54 writeln!(
55 &mut out_file,
56 "// This file was autogenerated by `build_tools/src/config.rs"
57 )
58 .unwrap();
59
60 for (varname, value) in vars {
61 writeln!(
62 &mut out_file,
63 "pub(crate) const {}: &str = \"{}\";",
64 varname, value
65 )
66 .unwrap();
67 }
68}