diff --git a/config.ron b/config.ron index e00ec3b8..451dcecd 100644 --- a/config.ron +++ b/config.ron @@ -1,91 +1,90 @@ ( key_bindings: { - (modifiers: [Super, Shift], key: Some("Escape")): Terminate, - (modifiers: [Super], key: Some("Escape")): Debug, - (modifiers: [Super], key: Some("q")): Close, + (modifiers: [Super, Shift], key: "Escape"): Terminate, + (modifiers: [Super], key: "Escape"): Debug, + (modifiers: [Super], key: "q"): Close, - (modifiers: [Super], key: Some("1")): Workspace(1), - (modifiers: [Super], key: Some("2")): Workspace(2), - (modifiers: [Super], key: Some("3")): Workspace(3), - (modifiers: [Super], key: Some("4")): Workspace(4), - (modifiers: [Super], key: Some("5")): Workspace(5), - (modifiers: [Super], key: Some("6")): Workspace(6), - (modifiers: [Super], key: Some("7")): Workspace(7), - (modifiers: [Super], key: Some("8")): Workspace(8), - (modifiers: [Super], key: Some("9")): Workspace(9), - (modifiers: [Super], key: Some("0")): LastWorkspace, - (modifiers: [Super, Shift], key: Some("1")): MoveToWorkspace(1), - (modifiers: [Super, Shift], key: Some("2")): MoveToWorkspace(2), - (modifiers: [Super, Shift], key: Some("3")): MoveToWorkspace(3), - (modifiers: [Super, Shift], key: Some("4")): MoveToWorkspace(4), - (modifiers: [Super, Shift], key: Some("5")): MoveToWorkspace(5), - (modifiers: [Super, Shift], key: Some("6")): MoveToWorkspace(6), - (modifiers: [Super, Shift], key: Some("7")): MoveToWorkspace(7), - (modifiers: [Super, Shift], key: Some("8")): MoveToWorkspace(8), - (modifiers: [Super, Shift], key: Some("9")): MoveToWorkspace(9), - (modifiers: [Super, Shift], key: Some("0")): MoveToLastWorkspace, + (modifiers: [Super], key: "1"): Workspace(1), + (modifiers: [Super], key: "2"): Workspace(2), + (modifiers: [Super], key: "3"): Workspace(3), + (modifiers: [Super], key: "4"): Workspace(4), + (modifiers: [Super], key: "5"): Workspace(5), + (modifiers: [Super], key: "6"): Workspace(6), + (modifiers: [Super], key: "7"): Workspace(7), + (modifiers: [Super], key: "8"): Workspace(8), + (modifiers: [Super], key: "9"): Workspace(9), + (modifiers: [Super], key: "0"): LastWorkspace, + (modifiers: [Super, Shift], key: "1"): MoveToWorkspace(1), + (modifiers: [Super, Shift], key: "2"): MoveToWorkspace(2), + (modifiers: [Super, Shift], key: "3"): MoveToWorkspace(3), + (modifiers: [Super, Shift], key: "4"): MoveToWorkspace(4), + (modifiers: [Super, Shift], key: "5"): MoveToWorkspace(5), + (modifiers: [Super, Shift], key: "6"): MoveToWorkspace(6), + (modifiers: [Super, Shift], key: "7"): MoveToWorkspace(7), + (modifiers: [Super, Shift], key: "8"): MoveToWorkspace(8), + (modifiers: [Super, Shift], key: "9"): MoveToWorkspace(9), + (modifiers: [Super, Shift], key: "0"): MoveToLastWorkspace, - (modifiers: [Super, Ctrl, Alt], key: Some("Down")): MoveToNextOutput, - (modifiers: [Super, Ctrl, Alt], key: Some("Up")): MoveToPreviousOutput, - (modifiers: [Super, Ctrl, Alt], key: Some("j")): MoveToNextOutput, - (modifiers: [Super, Ctrl, Alt], key: Some("k")): MoveToPreviousOutput, + (modifiers: [Super, Ctrl, Alt], key: "Down"): MoveToNextOutput, + (modifiers: [Super, Ctrl, Alt], key: "Up"): MoveToPreviousOutput, + (modifiers: [Super, Ctrl, Alt], key: "j"): MoveToNextOutput, + (modifiers: [Super, Ctrl, Alt], key: "k"): MoveToPreviousOutput, - (modifiers: [Super], key: Some("Period")): NextOutput, - (modifiers: [Super], key: Some("Comma")): PreviousOutput, - (modifiers: [Super, Shift], key: Some("Period")): MoveToNextOutput, - (modifiers: [Super, Shift], key: Some("Comma")): MoveToPreviousOutput, + (modifiers: [Super], key: "Period"): NextOutput, + (modifiers: [Super], key: "Comma"): PreviousOutput, + (modifiers: [Super, Shift], key: "Period"): MoveToNextOutput, + (modifiers: [Super, Shift], key: "Comma"): MoveToPreviousOutput, - (modifiers: [Super], key: Some("Left")): Focus(Left), - (modifiers: [Super], key: Some("Right")): Focus(Right), - (modifiers: [Super], key: Some("Up")): Focus(Up), - (modifiers: [Super], key: Some("Down")): Focus(Down), - (modifiers: [Super], key: Some("h")): Focus(Left), - (modifiers: [Super], key: Some("j")): Focus(Down), - (modifiers: [Super], key: Some("k")): Focus(Up), - (modifiers: [Super], key: Some("l")): Focus(Right), - (modifiers: [Super], key: Some("u")): Focus(Out), - (modifiers: [Super], key: Some("i")): Focus(In), + (modifiers: [Super], key: "Left"): Focus(Left), + (modifiers: [Super], key: "Right"): Focus(Right), + (modifiers: [Super], key: "Up"): Focus(Up), + (modifiers: [Super], key: "Down"): Focus(Down), + (modifiers: [Super], key: "h"): Focus(Left), + (modifiers: [Super], key: "j"): Focus(Down), + (modifiers: [Super], key: "k"): Focus(Up), + (modifiers: [Super], key: "l"): Focus(Right), + (modifiers: [Super], key: "u"): Focus(Out), + (modifiers: [Super], key: "i"): Focus(In), - (modifiers: [Super, Shift], key: Some("Left")): Move(Left), - (modifiers: [Super, Shift], key: Some("Right")): Move(Right), - (modifiers: [Super, Shift], key: Some("Up")): Move(Up), - (modifiers: [Super, Shift], key: Some("Down")): Move(Down), - (modifiers: [Super, Shift], key: Some("h")): Move(Left), - (modifiers: [Super, Shift], key: Some("j")): Move(Down), - (modifiers: [Super, Shift], key: Some("k")): Move(Up), - (modifiers: [Super, Shift], key: Some("l")): Move(Right), + (modifiers: [Super, Shift], key: "Left"): Move(Left), + (modifiers: [Super, Shift], key: "Right"): Move(Right), + (modifiers: [Super, Shift], key: "Up"): Move(Up), + (modifiers: [Super, Shift], key: "Down"): Move(Down), + (modifiers: [Super, Shift], key: "h"): Move(Left), + (modifiers: [Super, Shift], key: "j"): Move(Down), + (modifiers: [Super, Shift], key: "k"): Move(Up), + (modifiers: [Super, Shift], key: "l"): Move(Right), - (modifiers: [Super], key: Some("o")): ToggleOrientation, - (modifiers: [Super], key: Some("s")): ToggleStacking, - (modifiers: [Super], key: Some("y")): ToggleTiling, - (modifiers: [Super], key: Some("g")): ToggleWindowFloating, - (modifiers: [Super], key: Some("x")): SwapWindow, + (modifiers: [Super], key: "o"): ToggleOrientation, + (modifiers: [Super], key: "s"): ToggleStacking, + (modifiers: [Super], key: "y"): ToggleTiling, + (modifiers: [Super], key: "g"): ToggleWindowFloating, + (modifiers: [Super], key: "x"): SwapWindow, - (modifiers: [Super], key: Some("m")): Maximize, - (modifiers: [Super], key: Some("r")): Resizing(Outwards), - (modifiers: [Super, Shift], key: Some("r")): Resizing(Inwards), + (modifiers: [Super], key: "m"): Maximize, + (modifiers: [Super], key: "r"): Resizing(Outwards), + (modifiers: [Super, Shift], key: "r"): Resizing(Inwards), //TODO: ability to select default web browser - (modifiers: [Super], key: Some("b")): Spawn("firefox"), + (modifiers: [Super], key: "b"): Spawn("firefox"), //TODO: ability to select default file browser - (modifiers: [Super], key: Some("f")): Spawn("nautilus"), + (modifiers: [Super], key: "f"): Spawn("nautilus"), //TODO: ability to select default terminal - (modifiers: [Super], key: Some("t")): Spawn("gnome-terminal"), + (modifiers: [Super], key: "t"): Spawn("gnome-terminal"), - (modifiers: [Super], key: Some("a")): Spawn("busctl --user call com.system76.CosmicAppLibrary /com/system76/CosmicAppLibrary com.system76.CosmicAppLibrary Toggle"), - (modifiers: [Super], key: Some("w")): Spawn("busctl --user call com.system76.CosmicWorkspaces /com/system76/CosmicWorkspaces com.system76.CosmicWorkspaces Toggle"), - (modifiers: [Super], key: Some("slash")): Spawn("busctl --user call com.system76.CosmicLauncher /com/system76/CosmicLauncher com.system76.CosmicLauncher Toggle"), - (modifiers: [Super], key: None): Spawn("busctl --user call com.system76.CosmicLauncher /com/system76/CosmicLauncher com.system76.CosmicLauncher Toggle"), + (modifiers: [Super], key: "a"): Spawn("busctl --user call com.system76.CosmicAppLibrary /com/system76/CosmicAppLibrary com.system76.CosmicAppLibrary Toggle"), + (modifiers: [Super], key: "w"): Spawn("busctl --user call com.system76.CosmicWorkspaces /com/system76/CosmicWorkspaces com.system76.CosmicWorkspaces Toggle"), + (modifiers: [Super], key: "slash"): Spawn("busctl --user call com.system76.CosmicLauncher /com/system76/CosmicLauncher com.system76.CosmicLauncher Toggle"), + (modifiers: [Super]): Spawn("busctl --user call com.system76.CosmicLauncher /com/system76/CosmicLauncher com.system76.CosmicLauncher Toggle"), - - (modifiers: [], key: Some("XF86AudioRaiseVolume")): Spawn("amixer sset Master 5%+"), - (modifiers: [], key: Some("XF86AudioLowerVolume")): Spawn("amixer sset Master 5%-"), - (modifiers: [], key: Some("XF86AudioMute")): Spawn("amixer sset Master toggle"), - (modifiers: [], key: Some("XF86MonBrightnessUp")): Spawn("busctl --user call com.system76.CosmicSettingsDaemon /com/system76/CosmicSettingsDaemon com.system76.CosmicSettingsDaemon IncreaseDisplayBrightness"), - (modifiers: [], key: Some("XF86MonBrightnessDown")): Spawn("busctl --user call com.system76.CosmicSettingsDaemon /com/system76/CosmicSettingsDaemon com.system76.CosmicSettingsDaemon DecreaseDisplayBrightness"), + (modifiers: [], key: "XF86AudioRaiseVolume"): Spawn("amixer sset Master 5%+"), + (modifiers: [], key: "XF86AudioLowerVolume"): Spawn("amixer sset Master 5%-"), + (modifiers: [], key: "XF86AudioMute"): Spawn("amixer sset Master toggle"), + (modifiers: [], key: "XF86MonBrightnessUp"): Spawn("busctl --user call com.system76.CosmicSettingsDaemon /com/system76/CosmicSettingsDaemon com.system76.CosmicSettingsDaemon IncreaseDisplayBrightness"), + (modifiers: [], key: "XF86MonBrightnessDown"): Spawn("busctl --user call com.system76.CosmicSettingsDaemon /com/system76/CosmicSettingsDaemon com.system76.CosmicSettingsDaemon DecreaseDisplayBrightness"), }, workspace_mode: OutputBound, workspace_amount: Dynamic, workspace_layout: Vertical, tiling_enabled: false, -) +) \ No newline at end of file diff --git a/src/config/key_bindings.rs b/src/config/key_bindings.rs index 1eba1f7a..985d4b8f 100644 --- a/src/config/key_bindings.rs +++ b/src/config/key_bindings.rs @@ -89,7 +89,7 @@ pub struct KeyPattern { #[serde(deserialize_with = "deserialize_KeyModifiers")] pub modifiers: KeyModifiers, /// The actual key, that was pressed - #[serde(deserialize_with = "deserialize_Keysym")] + #[serde(deserialize_with = "deserialize_Keysym", default)] pub key: Option, } diff --git a/src/config/types.rs b/src/config/types.rs index 33a96c50..03fa4eb7 100644 --- a/src/config/types.rs +++ b/src/config/types.rs @@ -62,12 +62,7 @@ where { use serde::de::{Error, Unexpected}; - let name: Option = Option::deserialize(deserializer)?; - if name.is_none() { - return Ok(None); - } - - let name = name.unwrap(); + let name = String::deserialize(deserializer)?; //let name = format!("KEY_{}", code); match xkb::keysym_from_name(&name, xkb::KEYSYM_NO_FLAGS) { KeySyms::KEY_NoSymbol => match xkb::keysym_from_name(&name, xkb::KEYSYM_CASE_INSENSITIVE) {