Add an option to skip the hotkey overlay at startup
Browse files at this commitdc47de178f1d3910bc193973192586e8b118e475Parent: 65e86494 changed files +28 -3
- niri-config/src/lib.rs +15 -0
- resources/default-config.kdl +6 -0
- src/hotkey_overlay.rs +1 -2
- src/niri.rs +6 -1
niri-config/src/lib.rsmodified+15 -0
| @@ -34,6 +34,8 @@ pub struct Config { | |||
| 34 | ] | 34 | ] |
| 35 | pub screenshot_path: Option<String>, | 35 | pub screenshot_path: Option<String>, |
| 36 | #[knuffel(child, default)] | 36 | #[knuffel(child, default)] |
| 37 | + pub hotkey_overlay: HotkeyOverlay, | ||
| 38 | + #[knuffel(child, default)] | ||
| 37 | pub binds: Binds, | 39 | pub binds: Binds, |
| 38 | #[knuffel(child, default)] | 40 | #[knuffel(child, default)] |
| 39 | pub debug: DebugConfig, | 41 | pub debug: DebugConfig, |
| @@ -336,6 +338,12 @@ pub struct Struts { | |||
| 336 | pub bottom: u16, | 338 | pub bottom: u16, |
| 337 | } | 339 | } |
| 338 | 340 | ||
| 341 | +#[derive(knuffel::Decode, Debug, Default, Clone, Copy, PartialEq, Eq)] | ||
| 342 | +pub struct HotkeyOverlay { | ||
| 343 | + #[knuffel(child)] | ||
| 344 | + pub skip_at_startup: bool, | ||
| 345 | +} | ||
| 346 | + | ||
| 339 | #[derive(knuffel::Decode, Debug, Default, PartialEq)] | 347 | #[derive(knuffel::Decode, Debug, Default, PartialEq)] |
| 340 | pub struct Binds(#[knuffel(children)] pub Vec<Bind>); | 348 | pub struct Binds(#[knuffel(children)] pub Vec<Bind>); |
| 341 | 349 | ||
| @@ -766,6 +774,10 @@ mod tests { | |||
| 766 | 774 | ||
| 767 | screenshot-path "~/Screenshots/screenshot.png" | 775 | screenshot-path "~/Screenshots/screenshot.png" |
| 768 | 776 | ||
| 777 | + hotkey-overlay { | ||
| 778 | + skip-at-startup | ||
| 779 | + } | ||
| 780 | + | ||
| 769 | binds { | 781 | binds { |
| 770 | Mod+T { spawn "alacritty"; } | 782 | Mod+T { spawn "alacritty"; } |
| 771 | Mod+Q { close-window; } | 783 | Mod+Q { close-window; } |
| @@ -881,6 +893,9 @@ mod tests { | |||
| 881 | xcursor_size: 16, | 893 | xcursor_size: 16, |
| 882 | }, | 894 | }, |
| 883 | screenshot_path: Some(String::from("~/Screenshots/screenshot.png")), | 895 | screenshot_path: Some(String::from("~/Screenshots/screenshot.png")), |
| 896 | + hotkey_overlay: HotkeyOverlay { | ||
| 897 | + skip_at_startup: true, | ||
| 898 | + }, | ||
| 884 | binds: Binds(vec![ | 899 | binds: Binds(vec![ |
| 885 | Bind { | 900 | Bind { |
| 886 | key: Key { | 901 | key: Key { |
resources/default-config.kdlmodified+6 -0
| @@ -179,6 +179,12 @@ screenshot-path "~/Pictures/Screenshots/Screenshot from %Y-%m-%d %H-%M-%S.png" | |||
| 179 | // You can also set this to null to disable saving screenshots to disk. | 179 | // You can also set this to null to disable saving screenshots to disk. |
| 180 | // screenshot-path null | 180 | // screenshot-path null |
| 181 | 181 | ||
| 182 | +// Settings for the "Important Hotkeys" overlay. | ||
| 183 | +hotkey-overlay { | ||
| 184 | + // Uncomment this line if you don't want to see the hotkey help at niri startup. | ||
| 185 | + // skip-at-startup | ||
| 186 | +} | ||
| 187 | + | ||
| 182 | binds { | 188 | binds { |
| 183 | // Keys consist of modifiers separated by + signs, followed by an XKB key name | 189 | // Keys consist of modifiers separated by + signs, followed by an XKB key name |
| 184 | // in the end. To find an XKB name for a particular key, you may use a program | 190 | // in the end. To find an XKB name for a particular key, you may use a program |
src/hotkey_overlay.rsmodified+1 -2
| @@ -45,8 +45,7 @@ pub type HotkeyOverlayRenderElement<R> = RelocateRenderElement<MemoryRenderBuffe | |||
| 45 | impl HotkeyOverlay { | 45 | impl HotkeyOverlay { |
| 46 | pub fn new(config: Rc<RefCell<Config>>, comp_mod: CompositorMod) -> Self { | 46 | pub fn new(config: Rc<RefCell<Config>>, comp_mod: CompositorMod) -> Self { |
| 47 | Self { | 47 | Self { |
| 48 | - // Start the compositor with the overlay open. | 48 | + is_open: false, |
| 49 | - is_open: true, | ||
| 50 | config, | 49 | config, |
| 51 | comp_mod, | 50 | comp_mod, |
| 52 | buffers: RefCell::new(HashMap::new()), | 51 | buffers: RefCell::new(HashMap::new()), |
src/niri.rsmodified+6 -1
| @@ -868,7 +868,12 @@ impl Niri { | |||
| 868 | 868 | ||
| 869 | let screenshot_ui = ScreenshotUi::new(); | 869 | let screenshot_ui = ScreenshotUi::new(); |
| 870 | let config_error_notification = ConfigErrorNotification::new(); | 870 | let config_error_notification = ConfigErrorNotification::new(); |
| 871 | - let hotkey_overlay = HotkeyOverlay::new(config.clone(), backend.mod_key()); | 871 | + |
| 872 | + let mut hotkey_overlay = HotkeyOverlay::new(config.clone(), backend.mod_key()); | ||
| 873 | + if !config_.hotkey_overlay.skip_at_startup { | ||
| 874 | + hotkey_overlay.show(); | ||
| 875 | + } | ||
| 876 | + | ||
| 872 | let exit_confirm_dialog = match ExitConfirmDialog::new() { | 877 | let exit_confirm_dialog = match ExitConfirmDialog::new() { |
| 873 | Ok(x) => Some(x), | 878 | Ok(x) => Some(x), |
| 874 | Err(err) => { | 879 | Err(err) => { |