summaryrefslogtreecommitdiff
path: root/alacritty_terminal/src/tty
diff options
context:
space:
mode:
authorChristian Duerr <contact@christianduerr.com>2022-08-31 22:48:38 +0000
committerGitHub <noreply@github.com>2022-09-01 01:48:38 +0300
commit4ddb608563d985060d69594d1004550a680ae3bd (patch)
tree0b02a330b3e59300cff80a147f3c1bdab7f9ea57 /alacritty_terminal/src/tty
parent18f9c2793924aec91c80a69ccb45f529adaffae5 (diff)
downloadalacritty-4ddb608563d985060d69594d1004550a680ae3bd.tar.gz
alacritty-4ddb608563d985060d69594d1004550a680ae3bd.zip
Add IPC config subcommand
This patch adds a new mechanism for changing configuration options without editing the configuration file, by sending options to running instances through `alacritty msg`. Each window will load Alacritty's configuration file by default and then accept IPC messages for config updates using the `alacritty msg config` subcommand. By default all windows will be updated, individual windows can be addressed using `alacritty msg config --window-id "$ALACRITTY_WINDOW_ID"`. Each option will replace the config's current value and cannot be reset until Alacritty is restarted or the option is overwritten with a new value. Configuration options are passed in the format `field.subfield=value`, where `value` is interpreted as yaml. Closes #472.
Diffstat (limited to 'alacritty_terminal/src/tty')
-rw-r--r--alacritty_terminal/src/tty/unix.rs9
-rw-r--r--alacritty_terminal/src/tty/windows/mod.rs2
2 files changed, 6 insertions, 5 deletions
diff --git a/alacritty_terminal/src/tty/unix.rs b/alacritty_terminal/src/tty/unix.rs
index f52f0920..63da4f9c 100644
--- a/alacritty_terminal/src/tty/unix.rs
+++ b/alacritty_terminal/src/tty/unix.rs
@@ -148,7 +148,7 @@ fn default_shell_command(pw: &Passwd<'_>) -> Command {
}
/// Create a new TTY and return a handle to interact with it.
-pub fn new(config: &PtyConfig, window_size: WindowSize, window_id: Option<usize>) -> Result<Pty> {
+pub fn new(config: &PtyConfig, window_size: WindowSize, window_id: u64) -> Result<Pty> {
let (master, slave) = make_pty(window_size.to_winsize())?;
#[cfg(any(target_os = "linux", target_os = "macos"))]
@@ -178,13 +178,14 @@ pub fn new(config: &PtyConfig, window_size: WindowSize, window_id: Option<usize>
builder.stdout(unsafe { Stdio::from_raw_fd(slave) });
// Setup shell environment.
+ let window_id = window_id.to_string();
+ builder.env("ALACRITTY_WINDOW_ID", &window_id);
builder.env("LOGNAME", pw.name);
builder.env("USER", pw.name);
builder.env("HOME", pw.dir);
- if let Some(window_id) = window_id {
- builder.env("WINDOWID", format!("{}", window_id));
- }
+ // Set Window ID for clients relying on X11 hacks.
+ builder.env("WINDOWID", window_id);
unsafe {
builder.pre_exec(move || {
diff --git a/alacritty_terminal/src/tty/windows/mod.rs b/alacritty_terminal/src/tty/windows/mod.rs
index aa21ce14..57925f4c 100644
--- a/alacritty_terminal/src/tty/windows/mod.rs
+++ b/alacritty_terminal/src/tty/windows/mod.rs
@@ -27,7 +27,7 @@ pub struct Pty {
child_watcher: ChildExitWatcher,
}
-pub fn new(config: &PtyConfig, window_size: WindowSize, _window_id: Option<usize>) -> Result<Pty> {
+pub fn new(config: &PtyConfig, window_size: WindowSize, _window_id: u64) -> Result<Pty> {
conpty::new(config, window_size)
.ok_or_else(|| Error::new(ErrorKind::Other, "failed to spawn conpty"))
}