diff options
author | Christian Duerr <contact@christianduerr.com> | 2024-10-15 18:32:50 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-10-15 18:32:50 +0000 |
commit | 2a2db5b6fd23adea88906b8c2ee81512cd44cd53 (patch) | |
tree | 46c314a8cfb6a94e2693f5e3e5e79e02877875f0 /alacritty/src/ipc.rs | |
parent | 6ba69f8dd469e1a9aff0b48b3ae10ce4510ca1e3 (diff) | |
download | r-alacritty-2a2db5b6fd23adea88906b8c2ee81512cd44cd53.tar.gz r-alacritty-2a2db5b6fd23adea88906b8c2ee81512cd44cd53.tar.bz2 r-alacritty-2a2db5b6fd23adea88906b8c2ee81512cd44cd53.zip |
Add headless mode
This patch adds a daemon mode to Alacritty which allows starting the
Alacritty process without spawning an initial window.
While this does not provide any significant advantage over the existing
behavior of always spawning a window, it does integrate nicer with some
setups and is a pretty trivial addition.
Diffstat (limited to 'alacritty/src/ipc.rs')
-rw-r--r-- | alacritty/src/ipc.rs | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/alacritty/src/ipc.rs b/alacritty/src/ipc.rs index d06d395e..3d14c4ce 100644 --- a/alacritty/src/ipc.rs +++ b/alacritty/src/ipc.rs @@ -20,13 +20,13 @@ const ALACRITTY_SOCKET_ENV: &str = "ALACRITTY_SOCKET"; /// Create an IPC socket. pub fn spawn_ipc_socket(options: &Options, event_proxy: EventLoopProxy<Event>) -> Option<PathBuf> { - // Create the IPC socket and export its path as env variable if necessary. + // Create the IPC socket and export its path as env. + let socket_path = options.socket.clone().unwrap_or_else(|| { let mut path = socket_dir(); path.push(format!("{}-{}.sock", socket_prefix(), process::id())); path }); - env::set_var(ALACRITTY_SOCKET_ENV, socket_path.as_os_str()); let listener = match UnixListener::bind(&socket_path) { Ok(listener) => listener, @@ -36,6 +36,11 @@ pub fn spawn_ipc_socket(options: &Options, event_proxy: EventLoopProxy<Event>) - }, }; + env::set_var(ALACRITTY_SOCKET_ENV, socket_path.as_os_str()); + if options.daemon { + println!("ALACRITTY_SOCKET={}; export ALACRITTY_SOCKET", socket_path.display()); + } + // Spawn a thread to listen on the IPC socket. thread::spawn_named("socket listener", move || { let mut data = String::new(); |