Use xremap's original extension to talk to GNOME

This commit is contained in:
Takashi Kokubun 2022-05-06 23:09:08 -07:00
parent 0a775b6aa6
commit 7d0d829647
No known key found for this signature in database
GPG Key ID: 6FFC433B12EE23DD

View File

@ -31,23 +31,17 @@ impl Client for GnomeClient {
None => return None,
};
let code = "
const actor = global.get_window_actors().find(a=>a.meta_window.has_focus()===true)
actor && actor.get_meta_window().get_wm_class()
";
if let Ok(message) = connection.call_method(
Some("org.gnome.Shell"),
"/org/gnome/Shell",
Some("org.gnome.Shell"),
"Eval",
&(code),
"/com/k0kubun/Xremap",
Some("com.k0kubun.Xremap"),
"WMClass",
&(),
) {
if let Ok((_actor, json)) = message.body::<(bool, String)>() {
if let Ok(wm_class) = serde_json::from_str::<String>(&json) {
if let Ok(wm_class) = message.body::<String>() {
return Some(wm_class);
}
}
}
None
}
}