1
0
Fork 0
mirror of https://github.com/Zedfrigg/ironbar.git synced 2025-04-19 19:34:24 +02:00
ironbar/src/ipc/mod.rs
Jake Stanger 9dd711235f
feat!: improve CLI structure, add new commands
This splits most CLI/IPC commands into two categories:

- `var` for ironvars
- `bar` for controlling individual bars.

It also introduces more commands for visibility, as well as breaking existing ones.

New commands:

- `show`
- `hide`
- `toggle_visible`
- `set_popup_visible`
- `get_popup_visible`

Lastly, the implementation of some existing commands has been improved.

BREAKING CHANGE: All IPC commands have changed. Namely, `type` has been changed to `command`, and bar/var related commands are now under a `subcommand`. The full spec can be found on the wiki.

BREAKING CHANGE: Several CLI commands are now located under the `var` and `bar` categories. Usage of any commands to get/set Ironvars or control bar visibility will need to be updated.

BREAKING CHANGE: The `open_popup` and `close_popup` IPC commands are now called `show_popup` and `hide_popup` respectively.

BREAKING CHANGE: The popup `name` argument has been renamed to `widget_name` on all IPC commands.

BREAKING CHANGE: The `set-visibility` CLI command now takes a `true`/`false` positional argument in place of the `-v` flag.

BREAKING CHANGE: `ok_value` responses will no longer print `ok` as the first line when using the CLI
2024-06-01 17:04:51 +01:00

37 lines
841 B
Rust

mod client;
pub mod commands;
pub mod responses;
mod server;
use std::path::{Path, PathBuf};
use tracing::warn;
pub use commands::*;
pub use responses::Response;
#[derive(Debug)]
pub struct Ipc {
path: PathBuf,
}
impl Ipc {
/// Creates a new IPC instance.
/// This can be used as both a server and client.
pub fn new() -> Self {
let ipc_socket_file = std::env::var("XDG_RUNTIME_DIR")
.map_or_else(|_| PathBuf::from("/tmp"), PathBuf::from)
.join("ironbar-ipc.sock");
if format!("{}", ipc_socket_file.display()).len() > 100 {
warn!("The IPC socket file's absolute path exceeds 100 bytes, the socket may fail to create.");
}
Self {
path: ipc_socket_file,
}
}
pub fn path(&self) -> &Path {
self.path.as_path()
}
}