Skip to content

Commit a51b5d2

Browse files
committed
add {toggle,set,unset}-urgent cli actions
1 parent 6556063 commit a51b5d2

File tree

3 files changed

+58
-0
lines changed

3 files changed

+58
-0
lines changed

niri-config/src/lib.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1736,6 +1736,12 @@ pub enum Action {
17361736
SetDynamicCastWindowById(u64),
17371737
SetDynamicCastMonitor(#[knuffel(argument)] Option<String>),
17381738
ClearDynamicCastTarget,
1739+
#[knuffel(skip)]
1740+
ToggleUrgent(u64),
1741+
#[knuffel(skip)]
1742+
SetUrgent(u64),
1743+
#[knuffel(skip)]
1744+
UnsetUrgent(u64),
17391745
}
17401746

17411747
impl From<niri_ipc::Action> for Action {
@@ -2000,6 +2006,9 @@ impl From<niri_ipc::Action> for Action {
20002006
Self::SetDynamicCastMonitor(output)
20012007
}
20022008
niri_ipc::Action::ClearDynamicCastTarget {} => Self::ClearDynamicCastTarget,
2009+
niri_ipc::Action::ToggleUrgent { id } => Self::ToggleUrgent(id),
2010+
niri_ipc::Action::SetUrgent { id } => Self::SetUrgent(id),
2011+
niri_ipc::Action::UnsetUrgent { id } => Self::UnsetUrgent(id),
20032012
}
20042013
}
20052014
}

niri-ipc/src/lib.rs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -764,6 +764,24 @@ pub enum Action {
764764
},
765765
/// Clear the dynamic cast target, making it show nothing.
766766
ClearDynamicCastTarget {},
767+
/// Toggle urgent status of a window.
768+
ToggleUrgent {
769+
/// Id of the window to toggle urgent.
770+
#[cfg_attr(feature = "clap", arg(long))]
771+
id: u64,
772+
},
773+
/// Set urgent status of a window.
774+
SetUrgent {
775+
/// Id of the window to set urgent.
776+
#[cfg_attr(feature = "clap", arg(long))]
777+
id: u64,
778+
},
779+
/// Unset urgent status of a window.
780+
UnsetUrgent {
781+
/// Id of the window to unset urgent.
782+
#[cfg_attr(feature = "clap", arg(long))]
783+
id: u64,
784+
},
767785
}
768786

769787
/// Change in window or column size.

src/input/mod.rs

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1915,6 +1915,37 @@ impl State {
19151915
Action::ClearDynamicCastTarget => {
19161916
self.set_dynamic_cast_target(CastTarget::Nothing);
19171917
}
1918+
Action::ToggleUrgent(id) => {
1919+
let window = self
1920+
.niri
1921+
.layout
1922+
.workspaces_mut()
1923+
.find_map(|ws| ws.windows_mut().find(|w| w.id().get() == id));
1924+
if let Some(window) = window {
1925+
let urgent = window.is_urgent();
1926+
window.set_urgent(!urgent);
1927+
}
1928+
}
1929+
Action::SetUrgent(id) => {
1930+
let window = self
1931+
.niri
1932+
.layout
1933+
.workspaces_mut()
1934+
.find_map(|ws| ws.windows_mut().find(|w| w.id().get() == id));
1935+
if let Some(window) = window {
1936+
window.set_urgent(true);
1937+
}
1938+
}
1939+
Action::UnsetUrgent(id) => {
1940+
let window = self
1941+
.niri
1942+
.layout
1943+
.workspaces_mut()
1944+
.find_map(|ws| ws.windows_mut().find(|w| w.id().get() == id));
1945+
if let Some(window) = window {
1946+
window.set_urgent(false);
1947+
}
1948+
}
19181949
}
19191950
}
19201951

0 commit comments

Comments
 (0)