Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,22 @@ fn tray_icon_name() -> String {
/*******************************************************************************************************************/
/* Clipboard functions for different OSes */

#[cfg(target_os = "linux")]
fn copy_to_clipboard(s: &str) {
let _ = Command::new("/usr/bin/xclip").stdin(Stdio::piped()).stdout(Stdio::inherit()).stderr(Stdio::inherit()).spawn().map(|mut c| {
c.stdin.take().map(|mut stdin| {
let _ = stdin.write_all(s.as_bytes());
});
let _ = c.wait();
});
}

#[cfg(target_os = "linux")]
fn read_from_clipboard() -> String {
Command::new("/usr/bin/xclip").output().map_or_else(|_| String::new(), |out| String::from_utf8(out.stdout).map_or_else(|_| String::new(), |s| s))
}

#[cfg(windows)]

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be here?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think your question is related to the issue (#8) you opened for Wayland support? We probably can use a rust library for cross-platform copy paste including Wayland support. I will mention that in the opened issue.

Or did you mean something else?

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or did you mean something else?

I meant the above line specifically #[cfg(windows)], it seems potentially out of place/like an accidental inclusion?

#[cfg(target_os = "macos")]
fn copy_to_clipboard(s: &str) {
let _ = Command::new("/usr/bin/pbcopy").stdin(Stdio::piped()).stdout(Stdio::inherit()).stderr(Stdio::inherit()).spawn().map(|mut c| {
Expand Down
9 changes: 9 additions & 0 deletions src/tray.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,15 @@ pub struct Tray {
tray_initialized: bool,
}

#[cfg(target_os = "linux")]
extern "C" {
fn tray_init(tray: *const CTray) -> c_int;
fn tray_loop(blocking: c_int) -> c_int;
fn tray_update(tray: *const CTray);
fn tray_exit();
}


#[cfg(target_os = "macos")]
#[link(name = "Cocoa", kind = "framework")]
extern "C" {
Expand Down