wayland_wf_shell/
lib.rs

1// todo: use pkg-config to find wayfire instead of hardcoding the path maybe
2
3use wayland_client;
4use wayland_client::protocol::*;
5
6use self::interfaces::*;
7
8use pkg_config;
9
10// const WF_PROTO_PATH: String = "/usr/share/wayfire/protocols/unstable/wayfire-shell-unstable-v2.xml".to_owned();
11
12// i have a feeling this won't work
13pub fn wayfire_proto_path() -> String {
14    // look up wayfire dependency field pkgdatadir and append 'unstable/wayfire-shell-unstable-v2.xml' to the path
15    let wayfire = pkg_config::Config::new()
16        .atleast_version("0.7.0")
17        .probe("wayfire")
18        .unwrap();
19
20    // ex: /usr/share/wayfire/protocols/unstable/wayfire-shell-unstable-v2.xml
21    wayfire.include_paths[0].to_str().unwrap().to_string()
22        + "/unstable/wayfire-shell-unstable-v2.xml"
23}
24
25pub mod interfaces {
26    use wayland_client::protocol::__interfaces::*;
27
28    #[cfg(feature = "system_proto")]
29    wayland_scanner::generate_interfaces!(
30        "/usr/share/wayfire/protocols/unstable/wayfire-shell-unstable-v2.xml"
31    );
32
33    // default feature
34    #[cfg(not(feature = "system_proto"))]
35    wayland_scanner::generate_interfaces!("src/proto/wayfire-shell-unstable-v2.xml");
36}
37
38#[cfg(feature = "system_proto")]
39wayland_scanner::generate_client_code!(
40    "/usr/share/wayfire/protocols/unstable/wayfire-shell-unstable-v2.xml"
41);
42#[cfg(not(feature = "system_proto"))]
43wayland_scanner::generate_client_code!("src/proto/wayfire-shell-unstable-v2.xml");
44
45// okay maybe then