macos: enable running lan-mouse on macos (#42)

* macos: initial support

- adapted conditional compilation
- moved lan-mouse socket to ~/Library/Caches/lan-mouse-socket.sock instead of XDG_RUNTIME_DIR
- support for mouse input emulation
TODO: Keycode translation, input capture
This commit is contained in:
Ferdinand Schober
2023-12-09 01:35:08 +01:00
committed by GitHub
parent 5a7e0cf89c
commit e3f9947284
13 changed files with 419 additions and 21 deletions

View File

@@ -126,7 +126,7 @@ pub struct FrontendListener {
}
impl FrontendListener {
#[cfg(unix)]
#[cfg(all(unix, not(target_os = "macos")))]
pub fn socket_path() -> Result<PathBuf> {
let xdg_runtime_dir = match env::var("XDG_RUNTIME_DIR") {
Ok(d) => d,
@@ -136,6 +136,20 @@ impl FrontendListener {
Ok(xdg_runtime_dir.join("lan-mouse-socket.sock"))
}
#[cfg(all(unix, target_os = "macos"))]
pub fn socket_path() -> Result<PathBuf> {
let home = match env::var("HOME") {
Ok(d) => d,
Err(e) => return Err(anyhow!("could not find HOME: {e}")),
};
let home = Path::new(home.as_str());
let path = home
.join("Library")
.join("Caches")
.join("lan-mouse-socket.sock");
Ok(path)
}
pub async fn new() -> Option<Result<Self>> {
#[cfg(unix)]
let (socket_path, listener) = {