diff --git a/Cargo.toml b/Cargo.toml index 9e0d4f8..31e84a1 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -45,6 +45,7 @@ tokio-stream = "0.1.9" toml = "0.5" unicode-width = "0.1.9" url = "2.2" +[target.'cfg(target_os = "linux")'.dependencies] wl-clipboard-rs = {version = "0.6", optional = true} [dependencies.rspotify] @@ -73,10 +74,9 @@ pancurses_backend = ["cursive/pancurses-backend", "pancurses/win32"] portaudio_backend = ["librespot-playback/portaudio-backend"] pulseaudio_backend = ["librespot-playback/pulseaudio-backend"] rodio_backend = ["librespot-playback/rodio-backend"] -share_clipboard = ["clipboard"] # Share a link to the system clipboard -share_selection = ["clipboard", "wl-clipboard-rs"] # Use the primary selection for sharing - linux only +share_clipboard = ["clipboard", "wl-clipboard-rs"] # Share a link to the system clipboard +share_selection = ["clipboard", "wl-clipboard-rs"] # Use the primary selection for sharing - linux and bsd only termion_backend = ["cursive/termion-backend"] -wayland_clipboard = ["wl-clipboard-rs"] # Support wayland clipboard - linux only [package.metadata.deb] assets = [ diff --git a/src/sharing.rs b/src/sharing.rs index 3779a1a..69cecec 100644 --- a/src/sharing.rs +++ b/src/sharing.rs @@ -1,7 +1,7 @@ #![cfg(feature = "share_clipboard")] use std::env; -#[cfg(feature = "wayland_clipboard")] +#[cfg(all(feature = "wl-clipboard-rs", target_os = "linux"))] use { std::io::Read, wl_clipboard_rs::{ @@ -14,7 +14,10 @@ use { #[cfg(feature = "share_selection")] use clipboard::{x11_clipboard, x11_clipboard::X11ClipboardContext}; -#[cfg(all(feature = "share_selection", feature = "wayland_clipboard"))] +#[cfg(all( + feature = "share_selection", + all(feature = "wl-clipboard-rs", target_os = "linux") +))] use wl_clipboard_rs::utils::{is_primary_selection_supported, PrimarySelectionCheckError}; #[cfg(not(feature = "share_selection"))] @@ -39,7 +42,7 @@ pub fn read_share() -> Option { if is_wayland() { #[allow(unused_mut, unused_assignments)] let mut string = None; - #[cfg(feature = "wayland_clipboard")] + #[cfg(all(feature = "wl-clipboard-rs", target_os = "linux"))] { //use wayland clipboard let result = get_contents( @@ -77,7 +80,7 @@ pub fn read_share() -> Option { if is_wayland() { #[allow(unused_mut, unused_assignments)] let mut string = None; - #[cfg(feature = "wayland_clipboard")] + #[cfg(all(feature = "wl-clipboard-rs", target_os = "linux"))] { //use wayland clipboard string = match is_primary_selection_supported() { @@ -138,7 +141,7 @@ pub fn write_share(url: String) -> Option<()> { if is_wayland() { #[allow(unused_mut, unused_assignments)] let mut option = None; - #[cfg(feature = "wayland_clipboard")] + #[cfg(all(feature = "wl-clipboard-rs", target_os = "linux"))] { //use wayland clipboard let opts = Options::new(); @@ -167,7 +170,7 @@ pub fn write_share(url: String) -> Option<()> { if is_wayland() { #[allow(unused_mut, unused_assignments)] let mut option = None; - #[cfg(feature = "wayland_clipboard")] + #[cfg(all(feature = "wl-clipboard-rs", target_os = "linux"))] { //use wayland clipboard let mut opts = Options::new();