Support new {output_name} spec in formats

timeout_old
Tassilo Horn 3 years ago
parent 20f040cc4f
commit 4c17f110f4
  1. 3
      NEWS.md
  2. 5
      src/cmds.rs
  3. 7
      src/config.rs
  4. 18
      src/tree.rs

@ -3,7 +3,8 @@ swayr v0.11.0
- New command: `configure-outputs` lets you repeatedly issue output commands
until you abort the menu program.
- Formats can now include a `{output_name}` placeholder which is replaced by
the name of the output containing the shown workspace, container or window.
swayr v0.10.0
=============

@ -719,7 +719,10 @@ pub fn focus_window_in_direction(
if consider_wins == &ConsiderWindows::CurrentWorkspace {
let cur_ws = tree.get_current_workspace();
wins.retain(|w| {
tree.get_workspace_node(w.node.id).unwrap().id == cur_ws.id
tree.get_parent_node_of_type(w.node.id, t::Type::Workspace)
.unwrap()
.id
== cur_ws.id
});
}

@ -217,19 +217,22 @@ impl Default for Format {
Format {
workspace_format: Some(
"{indent}<b>Workspace {name} [{layout}]</b> \
on output {output_name} \
<span alpha=\"20000\">({id})</span>"
.to_string(),
),
container_format: Some(
"{indent}<b>Container [{layout}]</b> \
on workspace {workspace_name} <i>{marks}</i> \
<i>{marks}</i> \
on workspace {workspace_name} \
<span alpha=\"20000\">({id})</span>"
.to_string(),
),
window_format: Some(
"img:{app_icon}:text:{indent}<i>{app_name}</i> \
{urgency_start}<b>{title}</b>{urgency_end} \
on workspace {workspace_name} <i>{marks}</i> \
<i>{marks}</i> \
on workspace {workspace_name} / {output_name} \
<span alpha=\"20000\">({id})</span>"
.to_string(),
),

@ -196,12 +196,16 @@ impl<'a> Tree<'a> {
self.id_parent.get(&id).map(|pid| self.get_node_by_id(*pid))
}
pub fn get_workspace_node(&self, id: i64) -> Option<&&s::Node> {
pub fn get_parent_node_of_type(
&self,
id: i64,
t: Type,
) -> Option<&&s::Node> {
let n = self.get_node_by_id(id);
if n.get_type() == Type::Workspace {
if n.get_type() == t {
Some(n)
} else if let Some(pid) = self.id_parent.get(&id) {
self.get_workspace_node(*pid)
self.get_parent_node_of_type(*pid, t)
} else {
None
}
@ -482,12 +486,12 @@ impl DisplayFormat for DisplayNode<'_> {
&maybe_html_escape(html_escape, self.node.get_app_name()),
)
.replace(
"{workspace_name}",
"{output_name}",
&maybe_html_escape(
html_escape,
self.tree
.get_workspace_node(self.node.id)
.map_or("<no_workspace>", |w| w.get_name()),
.get_parent_node_of_type(self.node.id, Type::Output)
.map_or("<no_output>", |w| w.get_name()),
),
)
.replace(
@ -495,7 +499,7 @@ impl DisplayFormat for DisplayNode<'_> {
&maybe_html_escape(
html_escape,
self.tree
.get_workspace_node(self.node.id)
.get_parent_node_of_type(self.node.id, Type::Workspace)
.map_or("<no_workspace>", |w| w.get_name()),
),
)

Loading…
Cancel
Save