forge
Explore
Log in

Don't you dare go Hollow

Implement focus-monitor to focus a specific monitor by output.

Browse files at this commit

993c5ce8afc78229fa42c2c7f90813eb40c34c54Annika HannigParent: 47dd338
niri-config/src/lib.rsmodified+21 -0
@@ -1568,6 +1568,7 @@ pub enum Action {
15681568 FocusMonitorUp,
15691569 FocusMonitorPrevious,
15701570 FocusMonitorNext,
1571+ FocusMonitor(#[knuffel(argument)] String),
15711572 MoveWindowToMonitorLeft,
15721573 MoveWindowToMonitorRight,
15731574 MoveWindowToMonitorDown,
@@ -1770,6 +1771,7 @@ impl From<niri_ipc::Action> for Action {
17701771 niri_ipc::Action::FocusMonitorUp {} => Self::FocusMonitorUp,
17711772 niri_ipc::Action::FocusMonitorPrevious {} => Self::FocusMonitorPrevious,
17721773 niri_ipc::Action::FocusMonitorNext {} => Self::FocusMonitorNext,
1774+ niri_ipc::Action::FocusMonitor { output } => Self::FocusMonitor(output),
17731775 niri_ipc::Action::MoveWindowToMonitorLeft {} => Self::MoveWindowToMonitorLeft,
17741776 niri_ipc::Action::MoveWindowToMonitorRight {} => Self::MoveWindowToMonitorRight,
17751777 niri_ipc::Action::MoveWindowToMonitorDown {} => Self::MoveWindowToMonitorDown,
@@ -3770,6 +3772,7 @@ mod tests {
37703772 Mod+T allow-when-locked=true { spawn "alacritty"; }
37713773 Mod+Q hotkey-overlay-title=null { close-window; }
37723774 Mod+Shift+H { focus-monitor-left; }
3775+ Mod+Shift+O { focus-monitor "eDP-1"; }
37733776 Mod+Ctrl+Shift+L { move-window-to-monitor-right; }
37743777 Mod+Comma { consume-window-into-column; }
37753778 Mod+1 { focus-workspace 1; }
@@ -4606,6 +4609,24 @@ mod tests {
46064609 allow_inhibiting: true,
46074610 hotkey_overlay_title: None,
46084611 },
4612+ Bind {
4613+ key: Key {
4614+ trigger: Keysym(
4615+ XK_o,
4616+ ),
4617+ modifiers: Modifiers(
4618+ SHIFT | COMPOSITOR,
4619+ ),
4620+ },
4621+ action: FocusMonitor(
4622+ "eDP-1",
4623+ ),
4624+ repeat: true,
4625+ cooldown: None,
4626+ allow_when_locked: false,
4627+ allow_inhibiting: true,
4628+ hotkey_overlay_title: None,
4629+ },
46094630 Bind {
46104631 key: Key {
46114632 trigger: Keysym(
niri-ipc/src/lib.rsmodified+6 -0
@@ -457,6 +457,12 @@ pub enum Action {
457457 FocusMonitorPrevious {},
458458 /// Focus the next monitor.
459459 FocusMonitorNext {},
460+ /// Focus a monitor by name.
461+ FocusMonitor {
462+ /// Name of the output to focus.
463+ #[cfg_attr(feature = "clap", arg())]
464+ output: String,
465+ },
460466 /// Move the focused window to the monitor to the left.
461467 MoveWindowToMonitorLeft {},
462468 /// Move the focused window to the monitor to the right.
src/input/mod.rsmodified+9 -0
@@ -1386,6 +1386,15 @@ impl State {
13861386 self.niri.layer_shell_on_demand_focus = None;
13871387 }
13881388 }
1389+ Action::FocusMonitor(output) => {
1390+ if let Some(output) = self.niri.output_by_name_match(&output).cloned() {
1391+ self.niri.layout.focus_output(&output);
1392+ if !self.maybe_warp_cursor_to_focus_centered() {
1393+ self.move_cursor_to_output(&output);
1394+ }
1395+ self.niri.layer_shell_on_demand_focus = None;
1396+ }
1397+ }
13891398 Action::MoveWindowToMonitorLeft => {
13901399 if let Some(output) = self.niri.output_left() {
13911400 self.niri.layout.move_to_output(None, &output, None);