aboutsummaryrefslogtreecommitdiff
path: root/niri-config/src
diff options
context:
space:
mode:
authorChristian Meissl <meissl.christian@gmail.com>2024-10-18 16:00:40 +0200
committerGitHub <noreply@github.com>2024-10-18 14:00:40 +0000
commit79fd309d6cf84163ff1c5c44f222e6a58dfa2872 (patch)
tree00d53946221acc9fdb4f80253cd8c2178b8b4933 /niri-config/src
parentdd8b2be044c6c67a1c9bf07f287b3967e958b8aa (diff)
downloadniri-79fd309d6cf84163ff1c5c44f222e6a58dfa2872.tar.gz
niri-79fd309d6cf84163ff1c5c44f222e6a58dfa2872.tar.bz2
niri-79fd309d6cf84163ff1c5c44f222e6a58dfa2872.zip
support binding actions to switches (#747)
* support spawn action on switch events this adds a new config section named `switch-events` that allows to bind `spawn` action to certain switch toggles. * Expand docs --------- Co-authored-by: Ivan Molodetskikh <yalterz@gmail.com>
Diffstat (limited to 'niri-config/src')
-rw-r--r--niri-config/src/lib.rs43
1 files changed, 43 insertions, 0 deletions
diff --git a/niri-config/src/lib.rs b/niri-config/src/lib.rs
index c4452534..79bddc31 100644
--- a/niri-config/src/lib.rs
+++ b/niri-config/src/lib.rs
@@ -54,6 +54,8 @@ pub struct Config {
#[knuffel(child, default)]
pub binds: Binds,
#[knuffel(child, default)]
+ pub switch_events: SwitchBinds,
+ #[knuffel(child, default)]
pub debug: DebugConfig,
#[knuffel(children(name = "workspace"))]
pub workspaces: Vec<Workspace>,
@@ -1088,6 +1090,24 @@ bitflags! {
}
}
+#[derive(knuffel::Decode, Debug, Default, Clone, PartialEq)]
+pub struct SwitchBinds {
+ #[knuffel(child)]
+ pub lid_open: Option<SwitchAction>,
+ #[knuffel(child)]
+ pub lid_close: Option<SwitchAction>,
+ #[knuffel(child)]
+ pub tablet_mode_on: Option<SwitchAction>,
+ #[knuffel(child)]
+ pub tablet_mode_off: Option<SwitchAction>,
+}
+
+#[derive(knuffel::Decode, Debug, Clone, PartialEq)]
+pub struct SwitchAction {
+ #[knuffel(child, unwrap(arguments))]
+ pub spawn: Vec<String>,
+}
+
// Remember to add new actions to the CLI enum too.
#[derive(knuffel::Decode, Debug, Clone, PartialEq)]
pub enum Action {
@@ -3079,6 +3099,11 @@ mod tests {
Mod+WheelScrollDown cooldown-ms=150 { focus-workspace-down; }
}
+ switch-events {
+ tablet-mode-on { spawn "bash" "-c" "gsettings set org.gnome.desktop.a11y.applications screen-keyboard-enabled true"; }
+ tablet-mode-off { spawn "bash" "-c" "gsettings set org.gnome.desktop.a11y.applications screen-keyboard-enabled false"; }
+ }
+
debug {
render-drm-device "/dev/dri/renderD129"
}
@@ -3426,6 +3451,24 @@ mod tests {
allow_when_locked: false,
},
]),
+ switch_events: SwitchBinds {
+ lid_open: None,
+ lid_close: None,
+ tablet_mode_on: Some(SwitchAction {
+ spawn: vec![
+ "bash".to_owned(),
+ "-c".to_owned(),
+ "gsettings set org.gnome.desktop.a11y.applications screen-keyboard-enabled true".to_owned(),
+ ],
+ }),
+ tablet_mode_off: Some(SwitchAction {
+ spawn: vec![
+ "bash".to_owned(),
+ "-c".to_owned(),
+ "gsettings set org.gnome.desktop.a11y.applications screen-keyboard-enabled false".to_owned(),
+ ],
+ }),
+ },
debug: DebugConfig {
render_drm_device: Some(PathBuf::from("/dev/dri/renderD129")),
..Default::default()