From 3591f6f4f9b6dbdd00a9643615e0d84c37fbb2a3 Mon Sep 17 00:00:00 2001 From: Julian Orth Date: Tue, 15 Feb 2022 23:15:00 +0100 Subject: [PATCH] autocommit 2022-02-15 23:15:00 CET --- Cargo.lock | 91 --------------------------------------- Cargo.toml | 1 - default-config/src/lib.rs | 5 ++- src/forker.rs | 23 +++++----- 4 files changed, 15 insertions(+), 105 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 9bb93b60..ef5ed02b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -320,7 +320,6 @@ dependencies = [ "num-derive", "num-traits", "once_cell", - "parking_lot", "rand", "renderdoc", "repc", @@ -367,15 +366,6 @@ dependencies = [ "winapi", ] -[[package]] -name = "lock_api" -version = "0.4.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "88943dd7ef4a2e5a4bfa2753aaab3013e34ce2533d1996fb18ef591e315e2b3b" -dependencies = [ - "scopeguard", -] - [[package]] name = "log" version = "0.4.14" @@ -446,29 +436,6 @@ version = "1.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "da32515d9f6e6e489d7bc9d84c71b060db7247dc035bbe44eac88cf87486d8d5" -[[package]] -name = "parking_lot" -version = "0.12.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "87f5ec2493a61ac0506c0f4199f99070cbe83857b0337006a30f3e6719b8ef58" -dependencies = [ - "lock_api", - "parking_lot_core", -] - -[[package]] -name = "parking_lot_core" -version = "0.9.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "28141e0cc4143da2443301914478dc976a61ffdb3f043058310c70df2fed8954" -dependencies = [ - "cfg-if 1.0.0", - "libc", - "redox_syscall", - "smallvec", - "windows-sys", -] - [[package]] name = "pin-project-lite" version = "0.2.8" @@ -545,15 +512,6 @@ dependencies = [ "rand_core", ] -[[package]] -name = "redox_syscall" -version = "0.2.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8383f39639269cde97d255a32bdb68c047337295414940c68bdd30c2e13203ff" -dependencies = [ - "bitflags", -] - [[package]] name = "regex" version = "1.5.4" @@ -619,12 +577,6 @@ version = "0.1.21" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7ef03e0a2b150c7a90d01faf6254c9c48a41e95fb2a8c2ac1c6f0d2b9aefc342" -[[package]] -name = "scopeguard" -version = "1.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd" - [[package]] name = "slab" version = "0.4.5" @@ -769,49 +721,6 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" -[[package]] -name = "windows-sys" -version = "0.32.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3df6e476185f92a12c072be4a189a0210dcdcf512a1891d6dff9edb874deadc6" -dependencies = [ - "windows_aarch64_msvc", - "windows_i686_gnu", - "windows_i686_msvc", - "windows_x86_64_gnu", - "windows_x86_64_msvc", -] - -[[package]] -name = "windows_aarch64_msvc" -version = "0.32.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d8e92753b1c443191654ec532f14c199742964a061be25d77d7a96f09db20bf5" - -[[package]] -name = "windows_i686_gnu" -version = "0.32.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6a711c68811799e017b6038e0922cb27a5e2f43a2ddb609fe0b6f3eeda9de615" - -[[package]] -name = "windows_i686_msvc" -version = "0.32.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "146c11bb1a02615db74680b32a68e2d61f553cc24c4eb5b4ca10311740e44172" - -[[package]] -name = "windows_x86_64_gnu" -version = "0.32.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c912b12f7454c6620635bbff3450962753834be2a594819bd5e945af18ec64bc" - -[[package]] -name = "windows_x86_64_msvc" -version = "0.32.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "504a2476202769977a040c6364301a3f65d0cc9e3fb08600b2bda150a0488316" - [[package]] name = "wio" version = "0.2.2" diff --git a/Cargo.toml b/Cargo.toml index 09d18399..55c60838 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -16,7 +16,6 @@ codegen-units = 1 [dependencies] uapi = "0.2.7" -parking_lot = "0.12.0" thiserror = "1.0.30" ahash = "0.7.6" log = "0.4.14" diff --git a/default-config/src/lib.rs b/default-config/src/lib.rs index 150a7811..1230e500 100644 --- a/default-config/src/lib.rs +++ b/default-config/src/lib.rs @@ -1,5 +1,5 @@ use i4config::keyboard::mods::{Modifiers, ALT, CTRL, SHIFT}; -use i4config::keyboard::syms::{SYM_Super_L, SYM_h, SYM_j, SYM_k, SYM_l, SYM_r, SYM_t, SYM_x}; +use i4config::keyboard::syms::{SYM_Super_L, SYM_h, SYM_j, SYM_k, SYM_l, SYM_r, SYM_t, SYM_x, SYM_y}; use i4config::Direction::{Down, Left, Right, Up}; use i4config::{config, create_seat, input_devices, on_new_input_device, Seat, Command}; @@ -35,6 +35,9 @@ fn configure_seat(s: Seat) { s.bind(SYM_x, || { Command::new("alacritty").spawn() }); + s.bind(SYM_y, || { + Command::new("sleep").arg("100").spawn() + }); } pub fn configure() { diff --git a/src/forker.rs b/src/forker.rs index 9bb9685f..35404d93 100644 --- a/src/forker.rs +++ b/src/forker.rs @@ -9,7 +9,6 @@ use crate::{AsyncEngine, AsyncQueue, ErrorFmt, EventLoop, State, Wheel}; use bincode::{Decode, Encode}; use i4config::_private::bincode_ops; use log::Level; -use parking_lot::Mutex; use std::cell::Cell; use std::ffi::OsStr; use std::io::Read; @@ -17,7 +16,7 @@ use std::io::Write; use std::os::unix::ffi::OsStrExt; use std::rc::Rc; use thiserror::Error; -use uapi::{c, pipe2, IntoUstr, OwnedFd, UstrPtr}; +use uapi::{c, pipe2, IntoUstr, OwnedFd, UstrPtr, Fd}; pub struct ForkerProxy { pidfd: Rc, @@ -181,29 +180,29 @@ struct Forker { } impl Forker { - fn handle(mut socket: OwnedFd) -> ! { + fn handle(socket: OwnedFd) -> ! { std::env::set_var("XDG_SESSION_TYPE", "wayland"); std::env::remove_var("DISPLAY"); std::env::remove_var("WAYLAND_DISPLAY"); setup_deathsig(); reset_signals(); - socket = setup_fds(socket); + let socket = Rc::new(setup_fds(socket)); std::panic::set_hook({ - let socket = Mutex::new(uapi::fcntl_dupfd_cloexec(socket.raw(), 0).unwrap()); + let socket = socket.raw(); Box::new(move |pi| { let msg = ForkerMessage::Log { level: log::Level::Error as _, msg: format!("The ol' forker panicked: {}", pi), }; let msg = bincode::encode_to_vec(&msg, bincode_ops()).unwrap(); - let _ = socket.lock().write_all(&msg); + let _ = Fd::new(socket).write_all(&msg); }) }); let el = EventLoop::new().unwrap(); let wheel = Wheel::install(&el).unwrap(); let ae = AsyncEngine::install(&el, &wheel).unwrap(); let forker = Rc::new(Forker { - socket: ae.fd(&Rc::new(socket)).unwrap(), + socket: ae.fd(&socket).unwrap(), ae: ae.clone(), outgoing: Default::default(), pending_spawns: Default::default(), @@ -259,7 +258,7 @@ impl Forker { } fn handle_spawn(self: &Rc, prog: String, args: Vec, env: Vec<(String, String)>) { - let (mut read, mut write) = pipe2(c::O_CLOEXEC).unwrap(); + let (read, mut write) = pipe2(c::O_CLOEXEC).unwrap(); let res = match fork_with_pidfd(false) { Ok(o) => o, Err(e) => { @@ -271,14 +270,14 @@ impl Forker { } }; match res { - Forked::Parent { pidfd, pid } => { + Forked::Parent { pid, .. } => { drop(write); let slf = self.clone(); let spawn = self.ae.spawn(async move { - let pidfd = slf.ae.fd(&Rc::new(pidfd)).unwrap(); - let _ = pidfd.readable().await; + let read = slf.ae.fd(&Rc::new(read)).unwrap(); + let _ = read.readable().await; let mut s = String::new(); - let _ = read.read_to_string(&mut s); + let _ = Fd::new(read.raw()).read_to_string(&mut s); if s.len() > 0 { slf.outgoing.push(ForkerMessage::Log { level: log::Level::Error as _,