espanso/src/check.rs

60 lines
1.7 KiB
Rust
Raw Normal View History

2019-09-15 16:29:11 +00:00
/*
* This file is part of espanso.
*
* Copyright (C) 2019 Federico Terzi
*
* espanso is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* espanso is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with espanso. If not, see <https://www.gnu.org/licenses/>.
*/
2019-09-15 13:39:18 +00:00
// This functions are used to check if the required dependencies are satisfied
// before starting espanso
#[cfg(target_os = "linux")]
pub fn check_dependencies() -> bool {
use std::process::Command;
let mut result = true;
// Make sure notify-send is installed
let status = Command::new("notify-send")
.arg("-v")
.output();
2019-09-28 08:44:25 +00:00
if status.is_err() {
2019-09-15 13:39:18 +00:00
println!("Error: 'notify-send' command is needed for espanso to work correctly, please install it.");
result = false;
}
// Make sure xclip is installed
let status = Command::new("xclip")
.arg("-version")
.output();
2019-09-28 08:44:25 +00:00
if status.is_err() {
2019-09-15 13:39:18 +00:00
println!("Error: 'xclip' command is needed for espanso to work correctly, please install it.");
result = false;
}
result
}
#[cfg(target_os = "macos")]
pub fn check_dependencies() -> bool {
// Nothing to do here
2019-09-16 15:52:33 +00:00
true
2019-09-15 13:39:18 +00:00
}
#[cfg(target_os = "windows")]
pub fn check_dependencies() -> bool {
// Nothing needed on windows
true
}