mirror of
https://github.com/Zedfrigg/ironbar.git
synced 2025-07-03 19:51:03 +02:00
feat(ipc): ironvar list command
This commit is contained in:
parent
7e7b3039eb
commit
cfaba87f2f
4 changed files with 38 additions and 3 deletions
|
@ -32,6 +32,9 @@ pub enum Command {
|
|||
key: Box<str>,
|
||||
},
|
||||
|
||||
/// Gets the current value of all `ironvar`s.
|
||||
List,
|
||||
|
||||
/// Load an additional CSS stylesheet.
|
||||
/// The sheet is automatically hot-reloaded.
|
||||
LoadCss {
|
||||
|
|
|
@ -153,6 +153,20 @@ impl Ipc {
|
|||
None => Response::error("Variable not found"),
|
||||
}
|
||||
}
|
||||
Command::List => {
|
||||
let variable_manager = Ironbar::variable_manager();
|
||||
|
||||
let mut values = read_lock!(variable_manager)
|
||||
.get_all()
|
||||
.iter()
|
||||
.map(|(k, v)| format!("{k}: {}", v.get().unwrap_or_default()))
|
||||
.collect::<Vec<_>>();
|
||||
|
||||
values.sort();
|
||||
let value = values.join("\n");
|
||||
|
||||
Response::OkValue { value }
|
||||
}
|
||||
Command::LoadCss { path } => {
|
||||
if path.exists() {
|
||||
load_css(path);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue