#[cfg(not(target_os = "android"))]
use std::sync::Arc;
#[cfg(not(target_os = "android"))]
use crate::mpris::{MprisConfig, PlayerSnapshot};
#[cfg(not(target_os = "android"))]
use crate::process::{MediaSession, MediaSessionFactory, ProcessServices, SpeechFactory};
#[cfg(target_os = "android")]
pub use super::android::services;
#[cfg(not(target_os = "android"))]
pub fn services(app_id: Option<&str>) -> ProcessServices {
ProcessServices::system(app_id)
}
#[cfg(not(target_os = "android"))]
pub(crate) fn with_native_backends(services: ProcessServices) -> ProcessServices {
let unattended = std::env::var_os(tilo_dialogs::portal::SAVE_DIRECTORY_ENV)
.filter(|directory| !directory.is_empty())
.and_then(|directory| tilo_dialogs::unattended_picker(directory.into()));
let elsewhere = unattended.unwrap_or_else(tilo_dialogs::unavailable_picker);
let files = tilo_dialogs::inherited_shell_picker(elsewhere)
.unwrap_or_else(tilo_dialogs::unavailable_picker);
let opener = tilo_dialogs::inherited_shell_opener(services.opener.clone())
.unwrap_or_else(|| services.opener.clone());
ProcessServices {
files,
opener,
speech: Arc::new(SystemSpeech),
media_session: Arc::new(super::mpris::DesktopMediaSessions),
screen_capture: Arc::new(super::capture::DesktopScreenCapture),
..services
}
}
pub fn install_default_if_unset(app_id: Option<&str>) -> bool {
crate::process::install_default_if_unset(|| services(app_id))
}
pub use tilo_process::environment::process_environment;
#[cfg(not(target_os = "android"))]
use self::desktop_media::SystemSpeech;
#[cfg(not(target_os = "android"))]
mod desktop_media {
use super::{MediaSession, MediaSessionFactory, MprisConfig, PlayerSnapshot, SpeechFactory};
pub(super) struct SystemSpeech;
impl SpeechFactory for SystemSpeech {
fn make(&self) -> Box<dyn tts::Speaker> {
tts::default_speaker()
}
}
impl MediaSessionFactory for super::super::mpris::DesktopMediaSessions {
fn start(&self, config: MprisConfig, initial: PlayerSnapshot) -> Option<MediaSession> {
super::super::mpris::start_desktop_session(config, initial)
}
}
}