mirror of
https://github.com/feschber/lan-mouse.git
synced 2026-03-07 20:09:59 +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:
|
||||
nix:
|
||||
strategy:
|
||||
matrix:
|
||||
os:
|
||||
- ubuntu-latest
|
||||
- macos-15-intel
|
||||
- macos-14
|
||||
os:
|
||||
- ubuntu-latest
|
||||
- macos-15-intel
|
||||
- macos-latest
|
||||
name: "Build"
|
||||
runs-on: ${{ matrix.os }}
|
||||
runs-on: ${{ matrix.os }}
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
submodules: recursive
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
submodules: recursive
|
||||
|
||||
- uses: DeterminateSystems/nix-installer-action@main
|
||||
with:
|
||||
logger: pretty
|
||||
- uses: DeterminateSystems/magic-nix-cache-action@main
|
||||
- uses: cachix/cachix-action@v14
|
||||
with:
|
||||
name: lan-mouse
|
||||
authToken: '${{ secrets.CACHIX_AUTH_TOKEN }}'
|
||||
# - uses: DeterminateSystems/nix-installer-action@main
|
||||
# with:
|
||||
# logger: pretty
|
||||
# - uses: DeterminateSystems/magic-nix-cache-action@main
|
||||
- uses: cachix/install-nix-action@v31
|
||||
- uses: cachix/cachix-action@v16
|
||||
with:
|
||||
name: lan-mouse
|
||||
authToken: "${{ secrets.CACHIX_AUTH_TOKEN }}"
|
||||
|
||||
- name: Build lan-mouse (x86_64-linux)
|
||||
if: matrix.os == 'ubuntu-latest'
|
||||
run: nix build --print-build-logs --show-trace .#packages.x86_64-linux.lan-mouse
|
||||
- name: Build lan-mouse (x86_64-linux)
|
||||
if: matrix.os == 'ubuntu-latest'
|
||||
run: nix build --print-build-logs --show-trace .#packages.x86_64-linux.lan-mouse
|
||||
|
||||
- name: Build lan-mouse (x86_64-darwin)
|
||||
if: matrix.os == 'macos-15-intel'
|
||||
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 (x86_64-darwin)
|
||||
if: matrix.os == 'macos-15-intel'
|
||||
run: nix build --print-build-logs --show-trace .#packages.x86_64-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:
|
||||
linux-release-build:
|
||||
runs-on: ubuntu-latest
|
||||
runs-on: ubuntu-22.04
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- name: install dependencies
|
||||
|
||||
2
.github/workflows/tagged-release.yml
vendored
2
.github/workflows/tagged-release.yml
vendored
@@ -7,7 +7,7 @@ on:
|
||||
|
||||
jobs:
|
||||
linux-release-build:
|
||||
runs-on: ubuntu-latest
|
||||
runs-on: ubuntu-22.04
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- name: install dependencies
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
use futures::{StreamExt, future};
|
||||
use std::{
|
||||
io,
|
||||
env, fs, io,
|
||||
os::{fd::OwnedFd, unix::net::UnixStream},
|
||||
path::PathBuf,
|
||||
sync::{
|
||||
Arc, Mutex, RwLock,
|
||||
atomic::{AtomicBool, Ordering},
|
||||
@@ -50,10 +51,45 @@ pub(crate) struct LibeiEmulation<'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>()
|
||||
-> Result<(RemoteDesktop<'a>, Session<'a, RemoteDesktop<'a>>, OwnedFd), ashpd::Error> {
|
||||
let remote_desktop = RemoteDesktop::new().await?;
|
||||
|
||||
let restore_token = read_token();
|
||||
|
||||
log::debug!("creating session ...");
|
||||
let session = remote_desktop.create_session().await?;
|
||||
|
||||
@@ -62,13 +98,20 @@ async fn get_ei_fd<'a>()
|
||||
.select_devices(
|
||||
&session,
|
||||
DeviceType::Keyboard | DeviceType::Pointer,
|
||||
None,
|
||||
restore_token.as_deref(),
|
||||
PersistMode::ExplicitlyRevoked,
|
||||
)
|
||||
.await?;
|
||||
|
||||
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?;
|
||||
Ok((remote_desktop, session, fd))
|
||||
|
||||
Reference in New Issue
Block a user