Add check command
This commit is contained in:
parent
e822aa55ad
commit
3ae11400ad
@ -1,4 +1,38 @@
|
|||||||
|
use std::io::BufRead;
|
||||||
|
|
||||||
|
use colored::Colorize;
|
||||||
|
|
||||||
|
use crate::config::get_device_peripherals;
|
||||||
|
|
||||||
pub fn check_tablet(tablet_name: &str) -> i32 {
|
pub fn check_tablet(tablet_name: &str) -> i32 {
|
||||||
todo!()
|
// Get the peripheral list for the tablet
|
||||||
|
let peripherals = get_device_peripherals(tablet_name).unwrap();
|
||||||
|
|
||||||
|
// Use `xsetwacom` to check if the tablet is connected
|
||||||
|
let xsetwacom = std::process::Command::new("xsetwacom")
|
||||||
|
.arg("--list")
|
||||||
|
.output()
|
||||||
|
.unwrap();
|
||||||
|
let xsetwacom_output = xsetwacom.stdout;
|
||||||
|
|
||||||
|
// Check if the tablet is connected
|
||||||
|
let mut is_connected = false;
|
||||||
|
for line in xsetwacom_output.lines() {
|
||||||
|
let line = line.unwrap();
|
||||||
|
for peripheral in &peripherals {
|
||||||
|
if line.contains(peripheral) {
|
||||||
|
is_connected = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Print the message and return the status code
|
||||||
|
if is_connected {
|
||||||
|
println!("{} is {}", tablet_name, "connected".green());
|
||||||
|
0
|
||||||
|
} else {
|
||||||
|
println!("{} is {}", tablet_name, "not connected".red());
|
||||||
|
1
|
||||||
|
}
|
||||||
}
|
}
|
@ -2,6 +2,7 @@ use colored::Colorize;
|
|||||||
|
|
||||||
use crate::config::{get_config_dir, get_device_name, get_device_peripherals, get_device_profiles};
|
use crate::config::{get_config_dir, get_device_name, get_device_peripherals, get_device_profiles};
|
||||||
|
|
||||||
|
|
||||||
pub fn list_tablets() {
|
pub fn list_tablets() {
|
||||||
// Get the config directory
|
// Get the config directory
|
||||||
let config_dir = get_config_dir().unwrap();
|
let config_dir = get_config_dir().unwrap();
|
||||||
|
Reference in New Issue
Block a user