-
-
Notifications
You must be signed in to change notification settings - Fork 140
✨ zb: Add a function to create a builder for IBus #1040
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
7e1565f
a26e176
370f6d7
20302d9
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -6,6 +6,8 @@ use static_assertions::assert_impl_all; | |
| use std::net::TcpStream; | ||
| #[cfg(all(unix, not(feature = "tokio")))] | ||
| use std::os::unix::net::UnixStream; | ||
| #[cfg(feature = "ibus")] | ||
| use std::process::Stdio; | ||
| use std::{ | ||
| collections::{HashMap, HashSet}, | ||
| vec, | ||
|
|
@@ -23,6 +25,9 @@ use vsock::VsockStream; | |
|
|
||
| use zvariant::ObjectPath; | ||
|
|
||
| #[cfg(feature = "ibus")] | ||
| use crate::process::Command; | ||
|
|
||
| use crate::{ | ||
| address::{self, Address}, | ||
| names::{InterfaceName, WellKnownName}, | ||
|
|
@@ -85,6 +90,36 @@ impl<'a> Builder<'a> { | |
| Ok(Self::new(Target::Address(Address::system()?))) | ||
| } | ||
|
|
||
| /// Create a builder for the [IBus] daemon. | ||
| /// | ||
| /// [IBus]: https://en.wikipedia.org/wiki/Intelligent_Input_Bus | ||
| #[cfg(feature = "ibus")] | ||
| pub async fn ibus() -> Result<Self> { | ||
| let child_process = Command::new("ibus") | ||
| .args(["address"]) | ||
| .stdout(Stdio::piped()) | ||
| .spawn() | ||
| .expect("Fail to call `ibus address`"); | ||
|
|
||
| #[cfg(not(feature = "tokio"))] | ||
| let output = child_process | ||
| .output() | ||
| .await | ||
| .expect("Fail to run `ibus address`"); | ||
|
|
||
| #[cfg(feature = "tokio")] | ||
| let output = child_process | ||
| .wait_with_output() | ||
| .await | ||
| .expect("Fail to run `ibus address`"); | ||
|
Comment on lines
+104
to
+114
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sorry, just noticed this part. Why do they need to be different? Actually, |
||
|
|
||
| let ibus_address = std::str::from_utf8(&output.stdout) | ||
| .expect("Invalid utf8 when getting stdout") | ||
| .trim(); | ||
|
|
||
| Builder::address(ibus_address) | ||
| } | ||
|
|
||
| /// Create a builder for a connection that will use the given [D-Bus bus address]. | ||
| /// | ||
| /// # Example | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.