mirror of
https://github.com/Noratrieb/clippyboard.git
synced 2026-03-14 14:36:09 +01:00
parent
13bd759ded
commit
75b6f3eef2
3 changed files with 26 additions and 31 deletions
13
Cargo.lock
generated
13
Cargo.lock
generated
|
|
@ -529,6 +529,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "cb9f6e1368bd4621d2c86baa7e37de77a938adf5221e5dd3d6133340101b309e"
|
checksum = "cb9f6e1368bd4621d2c86baa7e37de77a938adf5221e5dd3d6133340101b309e"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bitflags 2.9.4",
|
"bitflags 2.9.4",
|
||||||
|
"nix",
|
||||||
"polling",
|
"polling",
|
||||||
"rustix 1.1.2",
|
"rustix 1.1.2",
|
||||||
"slab",
|
"slab",
|
||||||
|
|
@ -650,7 +651,6 @@ dependencies = [
|
||||||
"calloop-wayland-source 0.4.1",
|
"calloop-wayland-source 0.4.1",
|
||||||
"ciborium",
|
"ciborium",
|
||||||
"clippyboard-shared",
|
"clippyboard-shared",
|
||||||
"ctrlc",
|
|
||||||
"dirs",
|
"dirs",
|
||||||
"eyre",
|
"eyre",
|
||||||
"serde",
|
"serde",
|
||||||
|
|
@ -783,17 +783,6 @@ version = "0.2.4"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "460fbee9c2c2f33933d720630a6a0bac33ba7053db5344fac858d4b8952d77d5"
|
checksum = "460fbee9c2c2f33933d720630a6a0bac33ba7053db5344fac858d4b8952d77d5"
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "ctrlc"
|
|
||||||
version = "3.5.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "881c5d0a13b2f1498e2306e82cbada78390e152d4b1378fb28a84f4dcd0dc4f3"
|
|
||||||
dependencies = [
|
|
||||||
"dispatch",
|
|
||||||
"nix",
|
|
||||||
"windows-sys 0.61.0",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "cursor-icon"
|
name = "cursor-icon"
|
||||||
version = "1.2.0"
|
version = "1.2.0"
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,6 @@ edition = "2024"
|
||||||
[dependencies]
|
[dependencies]
|
||||||
clippyboard-shared = { path = "../clippyboard-shared" }
|
clippyboard-shared = { path = "../clippyboard-shared" }
|
||||||
ciborium = "0.2.2"
|
ciborium = "0.2.2"
|
||||||
ctrlc = "3.5.0"
|
|
||||||
dirs = "6.0.0"
|
dirs = "6.0.0"
|
||||||
eyre = "0.6.12"
|
eyre = "0.6.12"
|
||||||
serde = "1.0.219"
|
serde = "1.0.219"
|
||||||
|
|
@ -15,5 +14,5 @@ tracing-subscriber = { version = "0.3.20", features = ["env-filter"] }
|
||||||
wayland-backend = { version = "0.3.11", features = ["client_system"] }
|
wayland-backend = { version = "0.3.11", features = ["client_system"] }
|
||||||
wayland-client = "0.31.11"
|
wayland-client = "0.31.11"
|
||||||
wayland-protocols = { version = "0.32.9", features = ["staging", "client"] }
|
wayland-protocols = { version = "0.32.9", features = ["staging", "client"] }
|
||||||
calloop = "0.14.3"
|
calloop = { version = "0.14.3", features = ["signals"] }
|
||||||
calloop-wayland-source = "0.4.1"
|
calloop-wayland-source = "0.4.1"
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,8 @@ use calloop::EventLoop;
|
||||||
use calloop::Interest;
|
use calloop::Interest;
|
||||||
use calloop::Mode;
|
use calloop::Mode;
|
||||||
use calloop::generic::Generic;
|
use calloop::generic::Generic;
|
||||||
|
use calloop::signals::Signal;
|
||||||
|
use calloop::signals::Signals;
|
||||||
use calloop_wayland_source::WaylandSource;
|
use calloop_wayland_source::WaylandSource;
|
||||||
use clippyboard_shared::HistoryItem;
|
use clippyboard_shared::HistoryItem;
|
||||||
use eyre::Context;
|
use eyre::Context;
|
||||||
|
|
@ -12,7 +14,6 @@ use std::convert::Infallible;
|
||||||
use std::io;
|
use std::io;
|
||||||
use std::io::ErrorKind;
|
use std::io::ErrorKind;
|
||||||
use std::io::{BufReader, BufWriter, PipeWriter, Read, Write};
|
use std::io::{BufReader, BufWriter, PipeWriter, Read, Write};
|
||||||
use std::ops::Deref;
|
|
||||||
use std::os::fd::AsFd;
|
use std::os::fd::AsFd;
|
||||||
use std::os::unix::net::{UnixListener, UnixStream};
|
use std::os::unix::net::{UnixListener, UnixStream};
|
||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
|
|
@ -58,13 +59,6 @@ struct SharedState {
|
||||||
deferred_seats: Vec<WlSeat>,
|
deferred_seats: Vec<WlSeat>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Deref for SharedState {
|
|
||||||
type Target = SharedStateInner;
|
|
||||||
fn deref(&self) -> &Self::Target {
|
|
||||||
&self.inner
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
struct InProgressOffer {
|
struct InProgressOffer {
|
||||||
mime_types: Mutex<HashSet<String>>,
|
mime_types: Mutex<HashSet<String>>,
|
||||||
time: Duration,
|
time: Duration,
|
||||||
|
|
@ -89,13 +83,14 @@ impl Dispatch<WlRegistry, ()> for SharedState {
|
||||||
info!("A new seat was connected");
|
info!("A new seat was connected");
|
||||||
let seat: WlSeat = proxy.bind(name, 1, qhandle, ());
|
let seat: WlSeat = proxy.bind(name, 1, qhandle, ());
|
||||||
|
|
||||||
match state.data_control_manager.get() {
|
match state.inner.data_control_manager.get() {
|
||||||
None => {
|
None => {
|
||||||
state.deferred_seats.push(seat);
|
state.deferred_seats.push(seat);
|
||||||
}
|
}
|
||||||
Some(manager) => {
|
Some(manager) => {
|
||||||
let device = manager.get_data_device(&seat, qhandle, ());
|
let device = manager.get_data_device(&seat, qhandle, ());
|
||||||
state
|
state
|
||||||
|
.inner
|
||||||
.data_control_devices
|
.data_control_devices
|
||||||
.lock()
|
.lock()
|
||||||
.unwrap()
|
.unwrap()
|
||||||
|
|
@ -116,6 +111,7 @@ impl Dispatch<WlRegistry, ()> for SharedState {
|
||||||
}
|
}
|
||||||
|
|
||||||
state
|
state
|
||||||
|
.inner
|
||||||
.data_control_manager
|
.data_control_manager
|
||||||
.set(manager)
|
.set(manager)
|
||||||
.expect("ext_data_control_manager_v1 already set, global appeared twice?");
|
.expect("ext_data_control_manager_v1 already set, global appeared twice?");
|
||||||
|
|
@ -123,7 +119,12 @@ impl Dispatch<WlRegistry, ()> for SharedState {
|
||||||
}
|
}
|
||||||
wayland_client::protocol::wl_registry::Event::GlobalRemove { name } => {
|
wayland_client::protocol::wl_registry::Event::GlobalRemove { name } => {
|
||||||
// try to remove, if it's not a wl_seat it may not exist
|
// try to remove, if it's not a wl_seat it may not exist
|
||||||
state.data_control_devices.lock().unwrap().remove(&name);
|
state
|
||||||
|
.inner
|
||||||
|
.data_control_devices
|
||||||
|
.lock()
|
||||||
|
.unwrap()
|
||||||
|
.remove(&name);
|
||||||
}
|
}
|
||||||
_ => {}
|
_ => {}
|
||||||
}
|
}
|
||||||
|
|
@ -446,12 +447,6 @@ fn read_fd_into_history(
|
||||||
fn main() -> eyre::Result<()> {
|
fn main() -> eyre::Result<()> {
|
||||||
let socket_path = clippyboard_shared::socket_path()?;
|
let socket_path = clippyboard_shared::socket_path()?;
|
||||||
|
|
||||||
let socket_path2 = socket_path.clone();
|
|
||||||
let _ = ctrlc::set_handler(move || {
|
|
||||||
cleanup(&socket_path2);
|
|
||||||
std::process::exit(130); // sigint
|
|
||||||
});
|
|
||||||
|
|
||||||
let Err(err) = main_inner(&socket_path);
|
let Err(err) = main_inner(&socket_path);
|
||||||
|
|
||||||
if let Some(ioerr) = err.downcast_ref::<io::Error>()
|
if let Some(ioerr) = err.downcast_ref::<io::Error>()
|
||||||
|
|
@ -496,7 +491,7 @@ pub fn main_inner(socket_path: &PathBuf) -> eyre::Result<Infallible> {
|
||||||
.roundtrip(&mut shared_state)
|
.roundtrip(&mut shared_state)
|
||||||
.wrap_err("failed to set up wayland state")?;
|
.wrap_err("failed to set up wayland state")?;
|
||||||
|
|
||||||
if shared_state.data_control_manager.get().is_none() {
|
if shared_state.inner.data_control_manager.get().is_none() {
|
||||||
bail!(
|
bail!(
|
||||||
"{} not found, the ext-data-control-v1 Wayland extension is likely unsupported by your compositor.\n\
|
"{} not found, the ext-data-control-v1 Wayland extension is likely unsupported by your compositor.\n\
|
||||||
check https://wayland.app/protocols/ext-data-control-v1#compositor-support\
|
check https://wayland.app/protocols/ext-data-control-v1#compositor-support\
|
||||||
|
|
@ -512,6 +507,18 @@ pub fn main_inner(socket_path: &PathBuf) -> eyre::Result<Infallible> {
|
||||||
.insert(event_loop.handle())
|
.insert(event_loop.handle())
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
|
event_loop
|
||||||
|
.handle()
|
||||||
|
.insert_source(
|
||||||
|
Signals::new(&[Signal::SIGINT, Signal::SIGTERM])
|
||||||
|
.wrap_err("failed to create signal listener")?,
|
||||||
|
|_, _, _| {
|
||||||
|
cleanup(socket_path);
|
||||||
|
std::process::exit(0);
|
||||||
|
},
|
||||||
|
)
|
||||||
|
.wrap_err("failed to register signalfd handlers")?;
|
||||||
|
|
||||||
event_loop
|
event_loop
|
||||||
.handle()
|
.handle()
|
||||||
.insert_source(
|
.insert_source(
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue