mirror of
https://github.com/feschber/lan-mouse.git
synced 2026-03-28 23:50:55 +03:00
Compare commits
3 Commits
build-on-2
...
update-cac
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
1bec5915e6 | ||
|
|
ad63b6ba20 | ||
|
|
e80625648e |
64
.github/workflows/cachix.yml
vendored
64
.github/workflows/cachix.yml
vendored
@@ -1,40 +1,46 @@
|
|||||||
name: Binary Cache
|
name: Nix Binary Cache
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches: ["main"]
|
||||||
|
pull_request:
|
||||||
|
branches: ["main"]
|
||||||
|
workflow_dispatch:
|
||||||
|
|
||||||
on: [push, pull_request, workflow_dispatch]
|
|
||||||
jobs:
|
jobs:
|
||||||
nix:
|
nix:
|
||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
os:
|
os:
|
||||||
- ubuntu-latest
|
- ubuntu-latest
|
||||||
- macos-15-intel
|
- macos-15-intel
|
||||||
- macos-14
|
- macos-latest
|
||||||
name: "Build"
|
name: "Build"
|
||||||
runs-on: ${{ matrix.os }}
|
runs-on: ${{ matrix.os }}
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
with:
|
with:
|
||||||
submodules: recursive
|
submodules: recursive
|
||||||
|
|
||||||
- uses: DeterminateSystems/nix-installer-action@main
|
# - uses: DeterminateSystems/nix-installer-action@main
|
||||||
with:
|
# with:
|
||||||
logger: pretty
|
# logger: pretty
|
||||||
- uses: DeterminateSystems/magic-nix-cache-action@main
|
# - uses: DeterminateSystems/magic-nix-cache-action@main
|
||||||
- uses: cachix/cachix-action@v14
|
- uses: cachix/install-nix-action@v31
|
||||||
with:
|
- uses: cachix/cachix-action@v16
|
||||||
name: lan-mouse
|
with:
|
||||||
authToken: '${{ secrets.CACHIX_AUTH_TOKEN }}'
|
name: lan-mouse
|
||||||
|
authToken: "${{ secrets.CACHIX_AUTH_TOKEN }}"
|
||||||
|
|
||||||
- name: Build lan-mouse (x86_64-linux)
|
- name: Build lan-mouse (x86_64-linux)
|
||||||
if: matrix.os == 'ubuntu-latest'
|
if: matrix.os == 'ubuntu-latest'
|
||||||
run: nix build --print-build-logs --show-trace .#packages.x86_64-linux.lan-mouse
|
run: nix build --print-build-logs --show-trace .#packages.x86_64-linux.lan-mouse
|
||||||
|
|
||||||
- name: Build lan-mouse (x86_64-darwin)
|
- name: Build lan-mouse (x86_64-darwin)
|
||||||
if: matrix.os == 'macos-15-intel'
|
if: matrix.os == 'macos-15-intel'
|
||||||
run: nix build --print-build-logs --show-trace .#packages.x86_64-darwin.lan-mouse
|
run: nix build --print-build-logs --show-trace .#packages.x86_64-darwin.lan-mouse
|
||||||
|
|
||||||
- name: Build lan-mouse (aarch64-darwin)
|
|
||||||
if: matrix.os == 'macos-14'
|
|
||||||
run: nix build --print-build-logs --show-trace .#packages.aarch64-darwin.lan-mouse
|
|
||||||
|
|
||||||
|
- name: Build lan-mouse (aarch64-darwin)
|
||||||
|
if: matrix.os == 'macos-latest'
|
||||||
|
run: nix build --print-build-logs --show-trace .#packages.aarch64-darwin.lan-mouse
|
||||||
|
|||||||
2
.github/workflows/pre-release.yml
vendored
2
.github/workflows/pre-release.yml
vendored
@@ -11,7 +11,7 @@ env:
|
|||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
linux-release-build:
|
linux-release-build:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-22.04
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
- name: install dependencies
|
- name: install dependencies
|
||||||
|
|||||||
2
.github/workflows/tagged-release.yml
vendored
2
.github/workflows/tagged-release.yml
vendored
@@ -7,7 +7,7 @@ on:
|
|||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
linux-release-build:
|
linux-release-build:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-22.04
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
- name: install dependencies
|
- name: install dependencies
|
||||||
|
|||||||
@@ -1,7 +1,8 @@
|
|||||||
use futures::{StreamExt, future};
|
use futures::{StreamExt, future};
|
||||||
use std::{
|
use std::{
|
||||||
io,
|
env, fs, io,
|
||||||
os::{fd::OwnedFd, unix::net::UnixStream},
|
os::{fd::OwnedFd, unix::net::UnixStream},
|
||||||
|
path::PathBuf,
|
||||||
sync::{
|
sync::{
|
||||||
Arc, Mutex, RwLock,
|
Arc, Mutex, RwLock,
|
||||||
atomic::{AtomicBool, Ordering},
|
atomic::{AtomicBool, Ordering},
|
||||||
@@ -50,10 +51,45 @@ pub(crate) struct LibeiEmulation<'a> {
|
|||||||
session: Session<'a, RemoteDesktop<'a>>,
|
session: Session<'a, RemoteDesktop<'a>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Get the path to the RemoteDesktop token file
|
||||||
|
fn get_token_file_path() -> PathBuf {
|
||||||
|
let cache_dir = env::var("XDG_CACHE_HOME")
|
||||||
|
.ok()
|
||||||
|
.map(PathBuf::from)
|
||||||
|
.unwrap_or_else(|| {
|
||||||
|
let home = env::var("HOME").expect("HOME not set");
|
||||||
|
PathBuf::from(home).join(".cache")
|
||||||
|
});
|
||||||
|
|
||||||
|
cache_dir.join("lan-mouse").join("remote-desktop.token")
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Read the RemoteDesktop token from file
|
||||||
|
fn read_token() -> Option<String> {
|
||||||
|
let token_path = get_token_file_path();
|
||||||
|
match fs::read_to_string(&token_path) {
|
||||||
|
Ok(token) => Some(token.trim().to_string()),
|
||||||
|
Err(_) => None,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Write the RemoteDesktop token to file
|
||||||
|
fn write_token(token: &str) -> io::Result<()> {
|
||||||
|
let token_path = get_token_file_path();
|
||||||
|
if let Some(parent) = token_path.parent() {
|
||||||
|
fs::create_dir_all(parent)?;
|
||||||
|
}
|
||||||
|
|
||||||
|
fs::write(&token_path, token)?;
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
async fn get_ei_fd<'a>()
|
async fn get_ei_fd<'a>()
|
||||||
-> Result<(RemoteDesktop<'a>, Session<'a, RemoteDesktop<'a>>, OwnedFd), ashpd::Error> {
|
-> Result<(RemoteDesktop<'a>, Session<'a, RemoteDesktop<'a>>, OwnedFd), ashpd::Error> {
|
||||||
let remote_desktop = RemoteDesktop::new().await?;
|
let remote_desktop = RemoteDesktop::new().await?;
|
||||||
|
|
||||||
|
let restore_token = read_token();
|
||||||
|
|
||||||
log::debug!("creating session ...");
|
log::debug!("creating session ...");
|
||||||
let session = remote_desktop.create_session().await?;
|
let session = remote_desktop.create_session().await?;
|
||||||
|
|
||||||
@@ -62,13 +98,20 @@ async fn get_ei_fd<'a>()
|
|||||||
.select_devices(
|
.select_devices(
|
||||||
&session,
|
&session,
|
||||||
DeviceType::Keyboard | DeviceType::Pointer,
|
DeviceType::Keyboard | DeviceType::Pointer,
|
||||||
None,
|
restore_token.as_deref(),
|
||||||
PersistMode::ExplicitlyRevoked,
|
PersistMode::ExplicitlyRevoked,
|
||||||
)
|
)
|
||||||
.await?;
|
.await?;
|
||||||
|
|
||||||
log::info!("requesting permission for input emulation");
|
log::info!("requesting permission for input emulation");
|
||||||
let _devices = remote_desktop.start(&session, None).await?.response()?;
|
let start_response = remote_desktop.start(&session, None).await?.response()?;
|
||||||
|
|
||||||
|
// The restore token is only valid once, we need to re-save it each time
|
||||||
|
if let Some(token_str) = start_response.restore_token() {
|
||||||
|
if let Err(e) = write_token(token_str) {
|
||||||
|
log::warn!("failed to save RemoteDesktop token: {}", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
let fd = remote_desktop.connect_to_eis(&session).await?;
|
let fd = remote_desktop.connect_to_eis(&session).await?;
|
||||||
Ok((remote_desktop, session, fd))
|
Ok((remote_desktop, session, fd))
|
||||||
|
|||||||
Reference in New Issue
Block a user