forge
Explore
Log in

Don't you dare go Hollow

Add configuration file

Browse files at this commit

5225bc9e558cd87ed54271e47dcddaac2d5bcf62Ivan MolodetskikhParent: bdc8603
Cargo.lockmodified+268 -0
@@ -2,12 +2,32 @@
22 # It is not intended for manual editing.
33 version = 3
44
5+[[package]]
6+name = "addr2line"
7+version = "0.21.0"
8+source = "registry+https://github.com/rust-lang/crates.io-index"
9+checksum = "8a30b2e23b9e17a9f90641c7ab1549cd9b44f296d3ccbf309d2863cfe398a0cb"
10+dependencies = [
11+ "gimli",
12+]
13+
514 [[package]]
615 name = "adler"
716 version = "1.0.2"
817 source = "registry+https://github.com/rust-lang/crates.io-index"
918 checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe"
1019
20+[[package]]
21+name = "ahash"
22+version = "0.7.6"
23+source = "registry+https://github.com/rust-lang/crates.io-index"
24+checksum = "fcb51a0695d8f838b1ee009b3fbf66bda078cd64590202a864a8f3e8c4315c47"
25+dependencies = [
26+ "getrandom",
27+ "once_cell",
28+ "version_check",
29+]
30+
1131 [[package]]
1232 name = "aho-corasick"
1333 version = "1.0.5"
@@ -244,6 +264,36 @@ version = "1.1.0"
244264 source = "registry+https://github.com/rust-lang/crates.io-index"
245265 checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa"
246266
267+[[package]]
268+name = "backtrace"
269+version = "0.3.69"
270+source = "registry+https://github.com/rust-lang/crates.io-index"
271+checksum = "2089b7e3f35b9dd2d0ed921ead4f6d318c27680d4a5bd167b3ee120edb105837"
272+dependencies = [
273+ "addr2line",
274+ "cc",
275+ "cfg-if",
276+ "libc",
277+ "miniz_oxide",
278+ "object",
279+ "rustc-demangle",
280+]
281+
282+[[package]]
283+name = "backtrace-ext"
284+version = "0.2.1"
285+source = "registry+https://github.com/rust-lang/crates.io-index"
286+checksum = "537beee3be4a18fb023b570f80e3ae28003db9167a751266b259926e25539d50"
287+dependencies = [
288+ "backtrace",
289+]
290+
291+[[package]]
292+name = "base64"
293+version = "0.21.3"
294+source = "registry+https://github.com/rust-lang/crates.io-index"
295+checksum = "414dcefbc63d77c526a76b3afcf6fbb9b5e2791c19c3aa2297733208750c6e53"
296+
247297 [[package]]
248298 name = "bitflags"
249299 version = "1.3.2"
@@ -377,6 +427,15 @@ dependencies = [
377427 "num-traits",
378428 ]
379429
430+[[package]]
431+name = "chumsky"
432+version = "0.9.2"
433+source = "registry+https://github.com/rust-lang/crates.io-index"
434+checksum = "23170228b96236b5a7299057ac284a321457700bc8c41a4476052f0f4ba5349d"
435+dependencies = [
436+ "hashbrown 0.12.3",
437+]
438+
380439 [[package]]
381440 name = "clap"
382441 version = "4.4.2"
@@ -844,6 +903,12 @@ dependencies = [
844903 "wasi",
845904 ]
846905
906+[[package]]
907+name = "gimli"
908+version = "0.28.0"
909+source = "registry+https://github.com/rust-lang/crates.io-index"
910+checksum = "6fb8d784f27acf97159b40fc4db5ecd8aa23b9ad5ef69cdd136d3bc80665f0c0"
911+
847912 [[package]]
848913 name = "gl_generator"
849914 version = "0.14.0"
@@ -860,6 +925,9 @@ name = "hashbrown"
860925 version = "0.12.3"
861926 source = "registry+https://github.com/rust-lang/crates.io-index"
862927 checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888"
928+dependencies = [
929+ "ahash",
930+]
863931
864932 [[package]]
865933 name = "hashbrown"
@@ -872,6 +940,9 @@ name = "heck"
872940 version = "0.4.1"
873941 source = "registry+https://github.com/rust-lang/crates.io-index"
874942 checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8"
943+dependencies = [
944+ "unicode-segmentation",
945+]
875946
876947 [[package]]
877948 name = "hermit-abi"
@@ -964,6 +1035,23 @@ dependencies = [
9641035 "windows-sys 0.48.0",
9651036 ]
9661037
1038+[[package]]
1039+name = "is-terminal"
1040+version = "0.4.9"
1041+source = "registry+https://github.com/rust-lang/crates.io-index"
1042+checksum = "cb0889898416213fab133e1d33a0e5858a48177452750691bde3666d0fdbaf8b"
1043+dependencies = [
1044+ "hermit-abi",
1045+ "rustix 0.38.11",
1046+ "windows-sys 0.48.0",
1047+]
1048+
1049+[[package]]
1050+name = "is_ci"
1051+version = "1.1.1"
1052+source = "registry+https://github.com/rust-lang/crates.io-index"
1053+checksum = "616cde7c720bb2bb5824a224687d8f77bfd38922027f01d825cd7453be5099fb"
1054+
9671055 [[package]]
9681056 name = "itoa"
9691057 version = "1.0.9"
@@ -1009,6 +1097,33 @@ version = "3.1.0"
10091097 source = "registry+https://github.com/rust-lang/crates.io-index"
10101098 checksum = "e2db585e1d738fc771bf08a151420d3ed193d9d895a36df7f6f8a9456b911ddc"
10111099
1100+[[package]]
1101+name = "knuffel"
1102+version = "3.2.0"
1103+source = "registry+https://github.com/rust-lang/crates.io-index"
1104+checksum = "04bee6ddc6071011314b1ce4f7705fef6c009401dba4fd22cb0009db6a177413"
1105+dependencies = [
1106+ "base64",
1107+ "chumsky",
1108+ "knuffel-derive",
1109+ "miette",
1110+ "thiserror",
1111+ "unicode-width",
1112+]
1113+
1114+[[package]]
1115+name = "knuffel-derive"
1116+version = "3.2.0"
1117+source = "registry+https://github.com/rust-lang/crates.io-index"
1118+checksum = "91977f56c49cfb961e3d840e2e7c6e4a56bde7283898cf606861f1421348283d"
1119+dependencies = [
1120+ "heck",
1121+ "proc-macro-error",
1122+ "proc-macro2",
1123+ "quote",
1124+ "syn 1.0.109",
1125+]
1126+
10121127 [[package]]
10131128 name = "lazy_static"
10141129 version = "1.4.0"
@@ -1159,6 +1274,38 @@ dependencies = [
11591274 "autocfg",
11601275 ]
11611276
1277+[[package]]
1278+name = "miette"
1279+version = "5.10.0"
1280+source = "registry+https://github.com/rust-lang/crates.io-index"
1281+checksum = "59bb584eaeeab6bd0226ccf3509a69d7936d148cf3d036ad350abe35e8c6856e"
1282+dependencies = [
1283+ "backtrace",
1284+ "backtrace-ext",
1285+ "is-terminal",
1286+ "miette-derive",
1287+ "once_cell",
1288+ "owo-colors",
1289+ "supports-color",
1290+ "supports-hyperlinks",
1291+ "supports-unicode",
1292+ "terminal_size",
1293+ "textwrap",
1294+ "thiserror",
1295+ "unicode-width",
1296+]
1297+
1298+[[package]]
1299+name = "miette-derive"
1300+version = "5.10.0"
1301+source = "registry+https://github.com/rust-lang/crates.io-index"
1302+checksum = "49e7bc1560b95a3c4a25d03de42fe76ca718ab92d1a22a55b9b4cf67b3ae635c"
1303+dependencies = [
1304+ "proc-macro2",
1305+ "quote",
1306+ "syn 2.0.31",
1307+]
1308+
11621309 [[package]]
11631310 name = "minimal-lexical"
11641311 version = "0.2.1"
@@ -1226,9 +1373,12 @@ dependencies = [
12261373 "directories",
12271374 "image",
12281375 "keyframe",
1376+ "knuffel",
12291377 "logind-zbus",
1378+ "miette",
12301379 "profiling",
12311380 "sd-notify",
1381+ "serde",
12321382 "smithay",
12331383 "smithay-drm-extras",
12341384 "time",
@@ -1405,6 +1555,15 @@ dependencies = [
14051555 "objc-sys",
14061556 ]
14071557
1558+[[package]]
1559+name = "object"
1560+version = "0.32.1"
1561+source = "registry+https://github.com/rust-lang/crates.io-index"
1562+checksum = "9cf5f9dd3933bd50a9e1f149ec995f39ae2c496d31fd772c1fd45ebc27e902b0"
1563+dependencies = [
1564+ "memchr",
1565+]
1566+
14081567 [[package]]
14091568 name = "once_cell"
14101569 version = "1.18.0"
@@ -1442,6 +1601,12 @@ version = "0.1.1"
14421601 source = "registry+https://github.com/rust-lang/crates.io-index"
14431602 checksum = "b15813163c1d831bf4a13c3610c05c0d03b39feb07f7e09fa234dac9b15aaf39"
14441603
1604+[[package]]
1605+name = "owo-colors"
1606+version = "3.5.0"
1607+source = "registry+https://github.com/rust-lang/crates.io-index"
1608+checksum = "c1b04fb49957986fdce4d6ee7a65027d55d4b6d2265e5848bbb507b58ccfdb6f"
1609+
14451610 [[package]]
14461611 name = "parking"
14471612 version = "2.1.0"
@@ -1517,6 +1682,30 @@ dependencies = [
15171682 "toml_edit",
15181683 ]
15191684
1685+[[package]]
1686+name = "proc-macro-error"
1687+version = "1.0.4"
1688+source = "registry+https://github.com/rust-lang/crates.io-index"
1689+checksum = "da25490ff9892aab3fcf7c36f08cfb902dd3e71ca0f9f9517bea02a73a5ce38c"
1690+dependencies = [
1691+ "proc-macro-error-attr",
1692+ "proc-macro2",
1693+ "quote",
1694+ "syn 1.0.109",
1695+ "version_check",
1696+]
1697+
1698+[[package]]
1699+name = "proc-macro-error-attr"
1700+version = "1.0.4"
1701+source = "registry+https://github.com/rust-lang/crates.io-index"
1702+checksum = "a1be40180e52ecc98ad80b184934baf3d0d29f979574e439af5a55274b35f869"
1703+dependencies = [
1704+ "proc-macro2",
1705+ "quote",
1706+ "version_check",
1707+]
1708+
15201709 [[package]]
15211710 name = "proc-macro2"
15221711 version = "1.0.66"
@@ -1673,6 +1862,12 @@ version = "0.7.5"
16731862 source = "registry+https://github.com/rust-lang/crates.io-index"
16741863 checksum = "dbb5fb1acd8a1a18b3dd5be62d25485eb770e05afb408a9627d14d451bae12da"
16751864
1865+[[package]]
1866+name = "rustc-demangle"
1867+version = "0.1.23"
1868+source = "registry+https://github.com/rust-lang/crates.io-index"
1869+checksum = "d626bb9dae77e28219937af045c257c28bfd3f69333c512553507f5f9798cb76"
1870+
16761871 [[package]]
16771872 name = "rustix"
16781873 version = "0.37.23"
@@ -1824,6 +2019,12 @@ version = "1.11.0"
18242019 source = "registry+https://github.com/rust-lang/crates.io-index"
18252020 checksum = "62bb4feee49fdd9f707ef802e22365a35de4b7b299de4763d44bfea899442ff9"
18262021
2022+[[package]]
2023+name = "smawk"
2024+version = "0.3.1"
2025+source = "registry+https://github.com/rust-lang/crates.io-index"
2026+checksum = "f67ad224767faa3c7d8b6d91985b78e70a1324408abcb1cfcc2be4c06bc06043"
2027+
18272028 [[package]]
18282029 name = "smithay"
18292030 version = "0.3.0"
@@ -1917,6 +2118,34 @@ version = "0.10.0"
19172118 source = "registry+https://github.com/rust-lang/crates.io-index"
19182119 checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623"
19192120
2121+[[package]]
2122+name = "supports-color"
2123+version = "2.0.0"
2124+source = "registry+https://github.com/rust-lang/crates.io-index"
2125+checksum = "4950e7174bffabe99455511c39707310e7e9b440364a2fcb1cc21521be57b354"
2126+dependencies = [
2127+ "is-terminal",
2128+ "is_ci",
2129+]
2130+
2131+[[package]]
2132+name = "supports-hyperlinks"
2133+version = "2.1.0"
2134+source = "registry+https://github.com/rust-lang/crates.io-index"
2135+checksum = "f84231692eb0d4d41e4cdd0cabfdd2e6cd9e255e65f80c9aa7c98dd502b4233d"
2136+dependencies = [
2137+ "is-terminal",
2138+]
2139+
2140+[[package]]
2141+name = "supports-unicode"
2142+version = "2.0.0"
2143+source = "registry+https://github.com/rust-lang/crates.io-index"
2144+checksum = "4b6c2cb240ab5dd21ed4906895ee23fe5a48acdbd15a3ce388e7b62a9b66baf7"
2145+dependencies = [
2146+ "is-terminal",
2147+]
2148+
19202149 [[package]]
19212150 name = "syn"
19222151 version = "1.0.109"
@@ -1952,6 +2181,27 @@ dependencies = [
19522181 "windows-sys 0.48.0",
19532182 ]
19542183
2184+[[package]]
2185+name = "terminal_size"
2186+version = "0.1.17"
2187+source = "registry+https://github.com/rust-lang/crates.io-index"
2188+checksum = "633c1a546cee861a1a6d0dc69ebeca693bf4296661ba7852b9d21d159e0506df"
2189+dependencies = [
2190+ "libc",
2191+ "winapi",
2192+]
2193+
2194+[[package]]
2195+name = "textwrap"
2196+version = "0.15.2"
2197+source = "registry+https://github.com/rust-lang/crates.io-index"
2198+checksum = "b7b3e525a49ec206798b40326a44121291b530c963cfb01018f63e135bac543d"
2199+dependencies = [
2200+ "smawk",
2201+ "unicode-linebreak",
2202+ "unicode-width",
2203+]
2204+
19552205 [[package]]
19562206 name = "thiserror"
19572207 version = "1.0.48"
@@ -2144,6 +2394,24 @@ version = "1.0.11"
21442394 source = "registry+https://github.com/rust-lang/crates.io-index"
21452395 checksum = "301abaae475aa91687eb82514b328ab47a211a533026cb25fc3e519b86adfc3c"
21462396
2397+[[package]]
2398+name = "unicode-linebreak"
2399+version = "0.1.5"
2400+source = "registry+https://github.com/rust-lang/crates.io-index"
2401+checksum = "3b09c83c3c29d37506a3e260c08c03743a6bb66a9cd432c6934ab501a190571f"
2402+
2403+[[package]]
2404+name = "unicode-segmentation"
2405+version = "1.10.1"
2406+source = "registry+https://github.com/rust-lang/crates.io-index"
2407+checksum = "1dd624098567895118886609431a7c3b8f516e41d30e0643f03d94592a147e36"
2408+
2409+[[package]]
2410+name = "unicode-width"
2411+version = "0.1.10"
2412+source = "registry+https://github.com/rust-lang/crates.io-index"
2413+checksum = "c0edd1e5b14653f783770bce4a4dabb4a5108a5370a5f5d8cfe8710c361f6c8b"
2414+
21472415 [[package]]
21482416 name = "utf8parse"
21492417 version = "0.2.1"
Cargo.tomlmodified+3 -0
@@ -13,9 +13,12 @@ clap = { version = "4.3.21", features = ["derive"] }
1313 directories = "5.0.1"
1414 image = { version = "0.24.7", default-features = false, features = ["png"] }
1515 keyframe = { version = "1.1.1", default-features = false }
16+knuffel = "3.2.0"
1617 logind-zbus = "3.1.2"
18+miette = { version = "5.10.0", features = ["fancy"] }
1719 profiling = "1.0.9"
1820 sd-notify = "0.4.1"
21+serde = { version = "1.0.188", features = ["derive"] }
1922 time = { version = "0.3.28", features = ["formatting", "local-offset", "macros"] }
2023 tracing = { version = "0.1.37", features = ["max_level_trace", "release_max_level_debug"] }
2124 tracing-subscriber = { version = "0.3.17", features = ["env-filter"] }
README.mdmodified+9 -5
@@ -50,7 +50,7 @@ You can also autostart systemd services like [mako] by symlinking them into `$HO
5050
5151 Niri also somewhat-works with xdg-desktop-portal-gnome for Flatpak apps.
5252
53-## Hotkeys
53+## Default Hotkeys
5454
5555 When running on a TTY, the Mod key is <kbd>Super</kbd>.
5656 When running in a window, the Mod key is <kbd>Alt</kbd>.
@@ -60,11 +60,9 @@ The general system is: if a hotkey switches somewhere, then adding <kbd>Ctrl</kb
6060 | Hotkey | Description |
6161 | ------ | ----------- |
6262 | <kbd>Mod</kbd><kbd>T</kbd> | Spawn `alacritty` |
63-| <kbd>Mod</kbd><kbd>D</kbd> | Spawn `fuzzel` |
64-| <kbd>Mod</kbd><kbd>N</kbd> | Spawn `nautilus` |
6563 | <kbd>Mod</kbd><kbd>Q</kbd> | Close the focused window |
66-| <kbd>Mod</kbd><kbd>H</kbd> or <kbd>Mod</kbd><kbd>←</kbd> | Focus the window to the left |
67-| <kbd>Mod</kbd><kbd>L</kbd> or <kbd>Mod</kbd><kbd>→</kbd> | Focus the window to the right |
64+| <kbd>Mod</kbd><kbd>H</kbd> or <kbd>Mod</kbd><kbd>←</kbd> | Focus the column to the left |
65+| <kbd>Mod</kbd><kbd>L</kbd> or <kbd>Mod</kbd><kbd>→</kbd> | Focus the column to the right |
6866 | <kbd>Mod</kbd><kbd>J</kbd> or <kbd>Mod</kbd><kbd>↓</kbd> | Focus the window below in a column |
6967 | <kbd>Mod</kbd><kbd>K</kbd> or <kbd>Mod</kbd><kbd>↑</kbd> | Focus the window above in a column |
7068 | <kbd>Mod</kbd><kbd>Ctrl</kbd><kbd>H</kbd> or <kbd>Mod</kbd><kbd>Ctrl</kbd><kbd>←</kbd> | Move the focused column to the left |
@@ -86,6 +84,12 @@ The general system is: if a hotkey switches somewhere, then adding <kbd>Ctrl</kb
8684 | <kbd>Mod</kbd><kbd>Ctrl</kbd><kbd>Shift</kbd><kbd>T</kbd> | Toggle debug tinting of rendered elements |
8785 | <kbd>Mod</kbd><kbd>Shift</kbd><kbd>E</kbd> | Exit niri |
8886
87+## Configuration
88+
89+Niri will load configuration from `$XDG_CONFIG_HOME/.config/niri/config.kdl` or `~/.config/niri/config.kdl`.
90+If this fails, it will load [the default configuration file](resources/default-config.kdl).
91+Please use the default configuration file as the starting point for your custom configuration.
92+
8993 [PaperWM]: https://github.com/paperwm/PaperWM
9094 [mako]: https://github.com/emersion/mako
9195
resources/default-config.kdladded+88 -0
@@ -0,0 +1,88 @@
1+// This config is in the KDL format: https://kdl.dev
2+// "/-" comments out the following node.
3+
4+input {
5+ keyboard {
6+ xkb {
7+ // You can set rules, model, layout, variant and options.
8+ // For more information, see xkeyboard-config(7).
9+
10+ // For example:
11+ /-layout "us,ru"
12+ /-options "grp:win_space_toggle,compose:ralt,ctrl:nocaps"
13+ }
14+ }
15+
16+ // Next sections contain libinput settings.
17+ // Omitting settings disables them, or leaves them at their default values.
18+ touchpad {
19+ tap
20+ natural-scroll
21+ /-accel-speed 0.2
22+ }
23+}
24+
25+binds {
26+ // Keys consist of modifiers separated by + signs, followed by an XKB key name
27+ // in the end. To find an XKB name for a particular key, you may use a program
28+ // like wev.
29+ //
30+ // "Mod" is a special modifier equal to Super when running on a TTY, and to Alt
31+ // when running as a winit window.
32+
33+ Mod+T { spawn "alacritty"; }
34+ Mod+Q { close-window; }
35+
36+ Mod+H { focus-column-left; }
37+ Mod+J { focus-window-down; }
38+ Mod+K { focus-window-up; }
39+ Mod+L { focus-column-right; }
40+ Mod+Left { focus-column-left; }
41+ Mod+Down { focus-window-down; }
42+ Mod+Up { focus-window-up; }
43+ Mod+Right { focus-column-right; }
44+
45+ Mod+Ctrl+H { move-column-left; }
46+ Mod+Ctrl+J { move-window-down; }
47+ Mod+Ctrl+K { move-window-up; }
48+ Mod+Ctrl+L { move-column-right; }
49+ Mod+Ctrl+Left { move-column-left; }
50+ Mod+Ctrl+Down { move-window-down; }
51+ Mod+Ctrl+Up { move-window-up; }
52+ Mod+Ctrl+Right { move-column-right; }
53+
54+ Mod+Shift+H { focus-monitor-left; }
55+ Mod+Shift+J { focus-monitor-down; }
56+ Mod+Shift+K { focus-monitor-up; }
57+ Mod+Shift+L { focus-monitor-right; }
58+ Mod+Shift+Left { focus-monitor-left; }
59+ Mod+Shift+Down { focus-monitor-down; }
60+ Mod+Shift+Up { focus-monitor-up; }
61+ Mod+Shift+Right { focus-monitor-right; }
62+
63+ Mod+Shift+Ctrl+H { move-window-to-monitor-left; }
64+ Mod+Shift+Ctrl+J { move-window-to-monitor-down; }
65+ Mod+Shift+Ctrl+K { move-window-to-monitor-up; }
66+ Mod+Shift+Ctrl+L { move-window-to-monitor-right; }
67+ Mod+Shift+Ctrl+Left { move-window-to-monitor-left; }
68+ Mod+Shift+Ctrl+Down { move-window-to-monitor-down; }
69+ Mod+Shift+Ctrl+Up { move-window-to-monitor-up; }
70+ Mod+Shift+Ctrl+Right { move-window-to-monitor-right; }
71+
72+ Mod+U { focus-workspace-down; }
73+ Mod+I { focus-workspace-up; }
74+ Mod+Ctrl+U { move-window-to-workspace-down; }
75+ Mod+Ctrl+I { move-window-to-workspace-up; }
76+
77+ Mod+Comma { consume-window-into-column; }
78+ Mod+Period { expel-window-from-column; }
79+
80+ Mod+R { switch-preset-column-width; }
81+ Mod+F { maximize-column; }
82+ Mod+Shift+F { fullscreen-window; }
83+
84+ Print { screenshot; }
85+ Mod+Shift+E { quit; }
86+
87+ Mod+Shift+Ctrl+T { toggle-debug-tint; }
88+}
src/config.rsadded+297 -0
@@ -0,0 +1,297 @@
1+use std::path::PathBuf;
2+use std::str::FromStr;
3+
4+use bitflags::bitflags;
5+use directories::ProjectDirs;
6+use miette::{miette, Context, IntoDiagnostic};
7+use smithay::input::keyboard::xkb::{keysym_from_name, KEY_NoSymbol, KEYSYM_CASE_INSENSITIVE};
8+use smithay::input::keyboard::Keysym;
9+
10+#[derive(knuffel::Decode, Debug, PartialEq)]
11+pub struct Config {
12+ #[knuffel(child, default)]
13+ pub input: Input,
14+ #[knuffel(child, default)]
15+ pub binds: Binds,
16+}
17+
18+// FIXME: Add other devices.
19+#[derive(knuffel::Decode, Debug, Default, PartialEq)]
20+pub struct Input {
21+ #[knuffel(child, default)]
22+ pub keyboard: Keyboard,
23+ #[knuffel(child, default)]
24+ pub touchpad: Touchpad,
25+}
26+
27+#[derive(knuffel::Decode, Debug, Default, PartialEq, Eq)]
28+pub struct Keyboard {
29+ #[knuffel(child, default)]
30+ pub xkb: Xkb,
31+}
32+
33+#[derive(knuffel::Decode, Debug, Default, PartialEq, Eq)]
34+pub struct Xkb {
35+ #[knuffel(child, unwrap(argument), default)]
36+ pub rules: String,
37+ #[knuffel(child, unwrap(argument), default)]
38+ pub model: String,
39+ #[knuffel(child, unwrap(argument))]
40+ pub layout: Option<String>,
41+ #[knuffel(child, unwrap(argument), default)]
42+ pub variant: String,
43+ #[knuffel(child, unwrap(argument))]
44+ pub options: Option<String>,
45+}
46+
47+// FIXME: Add the rest of the settings.
48+#[derive(knuffel::Decode, Debug, Default, PartialEq)]
49+pub struct Touchpad {
50+ #[knuffel(child)]
51+ pub tap: bool,
52+ #[knuffel(child)]
53+ pub natural_scroll: bool,
54+ #[knuffel(child, unwrap(argument), default)]
55+ pub accel_speed: f64,
56+}
57+
58+#[derive(knuffel::Decode, Debug, Default, PartialEq, Eq)]
59+pub struct Binds(#[knuffel(children)] pub Vec<Bind>);
60+
61+#[derive(knuffel::Decode, Debug, PartialEq, Eq)]
62+pub struct Bind {
63+ #[knuffel(node_name)]
64+ pub key: Key,
65+ #[knuffel(children)]
66+ pub actions: Vec<Action>,
67+}
68+
69+#[derive(Debug, PartialEq, Eq)]
70+pub struct Key {
71+ pub keysym: Keysym,
72+ pub modifiers: Modifiers,
73+}
74+
75+bitflags! {
76+ #[derive(Debug, Clone, Copy, PartialEq, Eq)]
77+ pub struct Modifiers : u8 {
78+ const CTRL = 1;
79+ const SHIFT = 2;
80+ const ALT = 4;
81+ const SUPER = 8;
82+ const COMPOSITOR = 16;
83+ }
84+}
85+
86+#[derive(knuffel::Decode, Debug, Clone, PartialEq, Eq)]
87+pub enum Action {
88+ #[knuffel(skip)]
89+ None,
90+ Quit,
91+ #[knuffel(skip)]
92+ ChangeVt(i32),
93+ Suspend,
94+ ToggleDebugTint,
95+ Spawn(#[knuffel(arguments)] Vec<String>),
96+ Screenshot,
97+ CloseWindow,
98+ FullscreenWindow,
99+ FocusColumnLeft,
100+ FocusColumnRight,
101+ FocusWindowDown,
102+ FocusWindowUp,
103+ MoveColumnLeft,
104+ MoveColumnRight,
105+ MoveWindowDown,
106+ MoveWindowUp,
107+ ConsumeWindowIntoColumn,
108+ ExpelWindowFromColumn,
109+ FocusWorkspaceDown,
110+ FocusWorkspaceUp,
111+ MoveWindowToWorkspaceDown,
112+ MoveWindowToWorkspaceUp,
113+ FocusMonitorLeft,
114+ FocusMonitorRight,
115+ FocusMonitorDown,
116+ FocusMonitorUp,
117+ MoveWindowToMonitorLeft,
118+ MoveWindowToMonitorRight,
119+ MoveWindowToMonitorDown,
120+ MoveWindowToMonitorUp,
121+ SwitchPresetColumnWidth,
122+ MaximizeColumn,
123+}
124+
125+impl Config {
126+ pub fn load(path: Option<PathBuf>) -> miette::Result<Self> {
127+ let path = if let Some(path) = path {
128+ path
129+ } else {
130+ let mut path = ProjectDirs::from("", "", "niri")
131+ .ok_or_else(|| miette!("error retrieving home directory"))?
132+ .config_dir()
133+ .to_owned();
134+ path.push("config.kdl");
135+ path
136+ };
137+
138+ let contents = std::fs::read_to_string(&path)
139+ .into_diagnostic()
140+ .with_context(|| format!("error reading {path:?}"))?;
141+
142+ let config = Self::parse("config.kdl", &contents).context("error parsing")?;
143+ debug!("loaded config from {path:?}");
144+ Ok(config)
145+ }
146+
147+ pub fn parse(filename: &str, text: &str) -> Result<Self, knuffel::Error> {
148+ knuffel::parse(filename, text)
149+ }
150+}
151+
152+impl Default for Config {
153+ fn default() -> Self {
154+ Config::parse(
155+ "default-config.kdl",
156+ include_str!("../resources/default-config.kdl"),
157+ )
158+ .unwrap()
159+ }
160+}
161+
162+impl FromStr for Key {
163+ type Err = miette::Error;
164+
165+ fn from_str(s: &str) -> Result<Self, Self::Err> {
166+ let mut modifiers = Modifiers::empty();
167+
168+ let mut split = s.split('+');
169+ let key = split.next_back().unwrap();
170+
171+ for part in split {
172+ let part = part.trim();
173+ if part.eq_ignore_ascii_case("mod") {
174+ modifiers |= Modifiers::COMPOSITOR
175+ } else if part.eq_ignore_ascii_case("ctrl") || part.eq_ignore_ascii_case("control") {
176+ modifiers |= Modifiers::CTRL;
177+ } else if part.eq_ignore_ascii_case("shift") {
178+ modifiers |= Modifiers::SHIFT;
179+ } else if part.eq_ignore_ascii_case("alt") {
180+ modifiers |= Modifiers::ALT;
181+ } else if part.eq_ignore_ascii_case("super") || part.eq_ignore_ascii_case("win") {
182+ modifiers |= Modifiers::SUPER;
183+ } else {
184+ return Err(miette!("invalid modifier: {part}"));
185+ }
186+ }
187+
188+ let keysym = keysym_from_name(key, KEYSYM_CASE_INSENSITIVE);
189+ if keysym == KEY_NoSymbol {
190+ return Err(miette!("invalid key: {key}"));
191+ }
192+
193+ Ok(Key { keysym, modifiers })
194+ }
195+}
196+
197+#[cfg(test)]
198+mod tests {
199+ use smithay::input::keyboard::xkb::keysyms::*;
200+
201+ use super::*;
202+
203+ #[track_caller]
204+ fn check(text: &str, expected: Config) {
205+ let parsed = Config::parse("test.kdl", text)
206+ .map_err(miette::Report::new)
207+ .unwrap();
208+ assert_eq!(parsed, expected);
209+ }
210+
211+ #[test]
212+ fn parse() {
213+ check(
214+ r#"
215+ input {
216+ keyboard {
217+ xkb {
218+ layout "us,ru"
219+ options "grp:win_space_toggle"
220+ }
221+ }
222+
223+ touchpad {
224+ tap
225+ accel-speed 0.2
226+ }
227+ }
228+
229+ binds {
230+ Mod+T { spawn "alacritty"; }
231+ Mod+Q { close-window; }
232+ Mod+Shift+H { focus-monitor-left; }
233+ Mod+Ctrl+Shift+L { move-window-to-monitor-right; }
234+ Mod+Comma { consume-window-into-column; }
235+ }
236+ "#,
237+ Config {
238+ input: Input {
239+ keyboard: Keyboard {
240+ xkb: Xkb {
241+ layout: Some("us,ru".to_owned()),
242+ options: Some("grp:win_space_toggle".to_owned()),
243+ ..Default::default()
244+ },
245+ },
246+ touchpad: Touchpad {
247+ tap: true,
248+ natural_scroll: false,
249+ accel_speed: 0.2,
250+ },
251+ },
252+ binds: Binds(vec![
253+ Bind {
254+ key: Key {
255+ keysym: KEY_t,
256+ modifiers: Modifiers::COMPOSITOR,
257+ },
258+ actions: vec![Action::Spawn(vec!["alacritty".to_owned()])],
259+ },
260+ Bind {
261+ key: Key {
262+ keysym: KEY_q,
263+ modifiers: Modifiers::COMPOSITOR,
264+ },
265+ actions: vec![Action::CloseWindow],
266+ },
267+ Bind {
268+ key: Key {
269+ keysym: KEY_h,
270+ modifiers: Modifiers::COMPOSITOR | Modifiers::SHIFT,
271+ },
272+ actions: vec![Action::FocusMonitorLeft],
273+ },
274+ Bind {
275+ key: Key {
276+ keysym: KEY_l,
277+ modifiers: Modifiers::COMPOSITOR | Modifiers::SHIFT | Modifiers::CTRL,
278+ },
279+ actions: vec![Action::MoveWindowToMonitorRight],
280+ },
281+ Bind {
282+ key: Key {
283+ keysym: KEY_comma,
284+ modifiers: Modifiers::COMPOSITOR,
285+ },
286+ actions: vec![Action::ConsumeWindowIntoColumn],
287+ },
288+ ]),
289+ },
290+ );
291+ }
292+
293+ #[test]
294+ fn can_create_default_config() {
295+ let _ = Config::default();
296+ }
297+}
src/input.rsmodified+74 -116
@@ -17,45 +17,10 @@ use smithay::input::pointer::{
1717 use smithay::utils::SERIAL_COUNTER;
1818 use smithay::wayland::tablet_manager::{TabletDescriptor, TabletSeatTrait};
1919
20+use crate::config::{Action, Config, Modifiers};
2021 use crate::niri::State;
2122 use crate::utils::get_monotonic_time;
2223
23-enum Action {
24- None,
25- Quit,
26- ChangeVt(i32),
27- Suspend,
28- ToggleDebugTint,
29- Spawn(String),
30- Screenshot,
31- CloseWindow,
32- ToggleFullscreen,
33- FocusLeft,
34- FocusRight,
35- FocusDown,
36- FocusUp,
37- MoveLeft,
38- MoveRight,
39- MoveDown,
40- MoveUp,
41- ConsumeIntoColumn,
42- ExpelFromColumn,
43- SwitchWorkspaceDown,
44- SwitchWorkspaceUp,
45- MoveToWorkspaceDown,
46- MoveToWorkspaceUp,
47- FocusMonitorLeft,
48- FocusMonitorRight,
49- FocusMonitorDown,
50- FocusMonitorUp,
51- MoveToMonitorLeft,
52- MoveToMonitorRight,
53- MoveToMonitorDown,
54- MoveToMonitorUp,
55- ToggleWidth,
56- ToggleFullWidth,
57-}
58-
5924 pub enum CompositorMod {
6025 Super,
6126 Alt,
@@ -70,13 +35,17 @@ impl From<Action> for FilterResult<Action> {
7035 }
7136 }
7237
73-fn action(comp_mod: CompositorMod, keysym: KeysymHandle, mods: ModifiersState) -> Action {
38+fn action(
39+ config: &Config,
40+ comp_mod: CompositorMod,
41+ keysym: KeysymHandle,
42+ mods: ModifiersState,
43+) -> Action {
7444 use keysyms::*;
7545
76- let modified = keysym.modified_sym();
77-
46+ // Handle hardcoded binds.
7847 #[allow(non_upper_case_globals)] // wat
79- match modified {
48+ match keysym.modified_sym() {
8049 modified @ KEY_XF86Switch_VT_1..=KEY_XF86Switch_VT_12 => {
8150 let vt = (modified - KEY_XF86Switch_VT_1 + 1) as i32;
8251 return Action::ChangeVt(vt);
@@ -85,59 +54,45 @@ fn action(comp_mod: CompositorMod, keysym: KeysymHandle, mods: ModifiersState) -
8554 _ => (),
8655 }
8756
88- let mod_down = match comp_mod {
89- CompositorMod::Super => mods.logo,
90- CompositorMod::Alt => mods.alt,
57+ // Handle configured binds.
58+ let mut modifiers = Modifiers::empty();
59+ if mods.ctrl {
60+ modifiers |= Modifiers::CTRL;
61+ }
62+ if mods.shift {
63+ modifiers |= Modifiers::SHIFT;
64+ }
65+ if mods.alt {
66+ modifiers |= Modifiers::ALT;
67+ }
68+ if mods.logo {
69+ modifiers |= Modifiers::SUPER;
70+ }
71+
72+ let (mod_down, mut comp_mod) = match comp_mod {
73+ CompositorMod::Super => (mods.logo, Modifiers::SUPER),
74+ CompositorMod::Alt => (mods.alt, Modifiers::ALT),
9175 };
76+ if mod_down {
77+ modifiers |= Modifiers::COMPOSITOR;
78+ } else {
79+ comp_mod = Modifiers::empty();
80+ }
9281
93- if !mod_down {
82+ let Some(&raw) = keysym.raw_syms().first() else {
9483 return Action::None;
95- }
84+ };
85+ for bind in &config.binds.0 {
86+ if bind.key.keysym != raw {
87+ continue;
88+ }
9689
97- // FIXME: these don't work in the Russian layout. I guess I'll need to
98- // find a US keymap, then map keys somehow.
99- #[allow(non_upper_case_globals)] // wat
100- match modified {
101- KEY_E => Action::Quit,
102- KEY_t => Action::Spawn("alacritty".to_owned()),
103- KEY_d => Action::Spawn("fuzzel".to_owned()),
104- KEY_n => Action::Spawn("nautilus".to_owned()),
105- // Alt + PrtSc = SysRq
106- KEY_Sys_Req | KEY_Print => Action::Screenshot,
107- KEY_T if mods.shift && mods.ctrl => Action::ToggleDebugTint,
108- KEY_q => Action::CloseWindow,
109- KEY_F => Action::ToggleFullscreen,
110- KEY_comma => Action::ConsumeIntoColumn,
111- KEY_period => Action::ExpelFromColumn,
112- KEY_r => Action::ToggleWidth,
113- KEY_f => Action::ToggleFullWidth,
114- // Move to monitor.
115- KEY_H | KEY_Left if mods.shift && mods.ctrl => Action::MoveToMonitorLeft,
116- KEY_L | KEY_Right if mods.shift && mods.ctrl => Action::MoveToMonitorRight,
117- KEY_J | KEY_Down if mods.shift && mods.ctrl => Action::MoveToMonitorDown,
118- KEY_K | KEY_Up if mods.shift && mods.ctrl => Action::MoveToMonitorUp,
119- // Focus monitor.
120- KEY_H | KEY_Left if mods.shift => Action::FocusMonitorLeft,
121- KEY_L | KEY_Right if mods.shift => Action::FocusMonitorRight,
122- KEY_J | KEY_Down if mods.shift => Action::FocusMonitorDown,
123- KEY_K | KEY_Up if mods.shift => Action::FocusMonitorUp,
124- // Move.
125- KEY_h | KEY_Left if mods.ctrl => Action::MoveLeft,
126- KEY_l | KEY_Right if mods.ctrl => Action::MoveRight,
127- KEY_j | KEY_Down if mods.ctrl => Action::MoveDown,
128- KEY_k | KEY_Up if mods.ctrl => Action::MoveUp,
129- // Focus.
130- KEY_h | KEY_Left => Action::FocusLeft,
131- KEY_l | KEY_Right => Action::FocusRight,
132- KEY_j | KEY_Down => Action::FocusDown,
133- KEY_k | KEY_Up => Action::FocusUp,
134- // Workspaces.
135- KEY_u if mods.ctrl => Action::MoveToWorkspaceDown,
136- KEY_i if mods.ctrl => Action::MoveToWorkspaceUp,
137- KEY_u => Action::SwitchWorkspaceDown,
138- KEY_i => Action::SwitchWorkspaceUp,
139- _ => Action::None,
90+ if bind.key.modifiers | comp_mod == modifiers {
91+ return bind.actions.first().cloned().unwrap_or(Action::None);
92+ }
14093 }
94+
95+ Action::None
14196 }
14297
14398 impl State {
@@ -166,9 +121,9 @@ impl State {
166121 event.state(),
167122 serial,
168123 time,
169- |_, mods, keysym| {
124+ |self_, mods, keysym| {
170125 if event.state() == KeyState::Pressed {
171- action(comp_mod, keysym, *mods).into()
126+ action(&self_.config, comp_mod, keysym, *mods).into()
172127 } else {
173128 FilterResult::Forward
174129 }
@@ -192,8 +147,10 @@ impl State {
192147 self.backend.toggle_debug_tint();
193148 }
194149 Action::Spawn(command) => {
195- if let Err(err) = Command::new(command).spawn() {
196- warn!("error spawning alacritty: {err}");
150+ if let Some((command, args)) = command.split_first() {
151+ if let Err(err) = Command::new(command).args(args).spawn() {
152+ warn!("error spawning {command}: {err}");
153+ }
197154 }
198155 }
199156 Action::Screenshot => {
@@ -211,78 +168,78 @@ impl State {
211168 window.toplevel().send_close();
212169 }
213170 }
214- Action::ToggleFullscreen => {
171+ Action::FullscreenWindow => {
215172 let focus = self.niri.monitor_set.focus().cloned();
216173 if let Some(window) = focus {
217174 self.niri.monitor_set.toggle_fullscreen(&window);
218175 }
219176 }
220- Action::MoveLeft => {
177+ Action::MoveColumnLeft => {
221178 self.niri.monitor_set.move_left();
222179 // FIXME: granular
223180 self.niri.queue_redraw_all();
224181 }
225- Action::MoveRight => {
182+ Action::MoveColumnRight => {
226183 self.niri.monitor_set.move_right();
227184 // FIXME: granular
228185 self.niri.queue_redraw_all();
229186 }
230- Action::MoveDown => {
187+ Action::MoveWindowDown => {
231188 self.niri.monitor_set.move_down();
232189 // FIXME: granular
233190 self.niri.queue_redraw_all();
234191 }
235- Action::MoveUp => {
192+ Action::MoveWindowUp => {
236193 self.niri.monitor_set.move_up();
237194 // FIXME: granular
238195 self.niri.queue_redraw_all();
239196 }
240- Action::FocusLeft => {
197+ Action::FocusColumnLeft => {
241198 self.niri.monitor_set.focus_left();
242199 }
243- Action::FocusRight => {
200+ Action::FocusColumnRight => {
244201 self.niri.monitor_set.focus_right();
245202 }
246- Action::FocusDown => {
203+ Action::FocusWindowDown => {
247204 self.niri.monitor_set.focus_down();
248205 }
249- Action::FocusUp => {
206+ Action::FocusWindowUp => {
250207 self.niri.monitor_set.focus_up();
251208 }
252- Action::MoveToWorkspaceDown => {
209+ Action::MoveWindowToWorkspaceDown => {
253210 self.niri.monitor_set.move_to_workspace_down();
254211 // FIXME: granular
255212 self.niri.queue_redraw_all();
256213 }
257- Action::MoveToWorkspaceUp => {
214+ Action::MoveWindowToWorkspaceUp => {
258215 self.niri.monitor_set.move_to_workspace_up();
259216 // FIXME: granular
260217 self.niri.queue_redraw_all();
261218 }
262- Action::SwitchWorkspaceDown => {
219+ Action::FocusWorkspaceDown => {
263220 self.niri.monitor_set.switch_workspace_down();
264221 // FIXME: granular
265222 self.niri.queue_redraw_all();
266223 }
267- Action::SwitchWorkspaceUp => {
224+ Action::FocusWorkspaceUp => {
268225 self.niri.monitor_set.switch_workspace_up();
269226 // FIXME: granular
270227 self.niri.queue_redraw_all();
271228 }
272- Action::ConsumeIntoColumn => {
229+ Action::ConsumeWindowIntoColumn => {
273230 self.niri.monitor_set.consume_into_column();
274231 // FIXME: granular
275232 self.niri.queue_redraw_all();
276233 }
277- Action::ExpelFromColumn => {
234+ Action::ExpelWindowFromColumn => {
278235 self.niri.monitor_set.expel_from_column();
279236 // FIXME: granular
280237 self.niri.queue_redraw_all();
281238 }
282- Action::ToggleWidth => {
239+ Action::SwitchPresetColumnWidth => {
283240 self.niri.monitor_set.toggle_width();
284241 }
285- Action::ToggleFullWidth => {
242+ Action::MaximizeColumn => {
286243 self.niri.monitor_set.toggle_full_width();
287244 }
288245 Action::FocusMonitorLeft => {
@@ -309,25 +266,25 @@ impl State {
309266 self.move_cursor_to_output(&output);
310267 }
311268 }
312- Action::MoveToMonitorLeft => {
269+ Action::MoveWindowToMonitorLeft => {
313270 if let Some(output) = self.niri.output_left() {
314271 self.niri.monitor_set.move_to_output(&output);
315272 self.move_cursor_to_output(&output);
316273 }
317274 }
318- Action::MoveToMonitorRight => {
275+ Action::MoveWindowToMonitorRight => {
319276 if let Some(output) = self.niri.output_right() {
320277 self.niri.monitor_set.move_to_output(&output);
321278 self.move_cursor_to_output(&output);
322279 }
323280 }
324- Action::MoveToMonitorDown => {
281+ Action::MoveWindowToMonitorDown => {
325282 if let Some(output) = self.niri.output_down() {
326283 self.niri.monitor_set.move_to_output(&output);
327284 self.move_cursor_to_output(&output);
328285 }
329286 }
330- Action::MoveToMonitorUp => {
287+ Action::MoveWindowToMonitorUp => {
331288 if let Some(output) = self.niri.output_up() {
332289 self.niri.monitor_set.move_to_output(&output);
333290 self.move_cursor_to_output(&output);
@@ -740,9 +697,10 @@ impl State {
740697 // According to Mutter code, this setting is specific to touchpads.
741698 let is_touchpad = device.config_tap_finger_count() > 0;
742699 if is_touchpad {
743- let _ = device.config_tap_set_enabled(true);
744- let _ = device.config_scroll_set_natural_scroll_enabled(true);
745- let _ = device.config_accel_set_speed(0.2);
700+ let c = &self.config.input.touchpad;
701+ let _ = device.config_tap_set_enabled(c.tap);
702+ let _ = device.config_scroll_set_natural_scroll_enabled(c.natural_scroll);
703+ let _ = device.config_accel_set_speed(c.accel_speed);
746704 }
747705 }
748706 }
src/main.rsmodified+21 -1
@@ -3,6 +3,7 @@ extern crate tracing;
33
44 mod animation;
55 mod backend;
6+mod config;
67 mod dbus;
78 mod frame_clock;
89 mod handlers;
@@ -13,8 +14,11 @@ mod utils;
1314
1415 use std::env;
1516 use std::ffi::OsString;
17+use std::path::PathBuf;
1618
1719 use clap::Parser;
20+use config::Config;
21+use miette::Context;
1822 use niri::{Niri, State};
1923 use smithay::reexports::calloop::EventLoop;
2024 use smithay::reexports::wayland_server::Display;
@@ -23,6 +27,9 @@ use tracing_subscriber::EnvFilter;
2327 #[derive(Parser)]
2428 #[command(author, version, about, long_about = None)]
2529 struct Cli {
30+ /// Path to config file (default: `$XDG_CONFIG_HOME/niri/config.kdl`).
31+ #[arg(short, long)]
32+ config: Option<PathBuf>,
2633 /// Command to run upon compositor startup.
2734 #[arg(last = true)]
2835 command: Vec<OsString>,
@@ -47,9 +54,22 @@ fn main() {
4754
4855 let _client = tracy_client::Client::start();
4956
57+ let config = match Config::load(cli.config).context("error loading config") {
58+ Ok(config) => config,
59+ Err(err) => {
60+ warn!("{err:?}");
61+ Config::default()
62+ }
63+ };
64+
5065 let mut event_loop = EventLoop::try_new().unwrap();
5166 let mut display = Display::new().unwrap();
52- let state = State::new(event_loop.handle(), event_loop.get_signal(), &mut display);
67+ let state = State::new(
68+ config,
69+ event_loop.handle(),
70+ event_loop.get_signal(),
71+ &mut display,
72+ );
5373 let mut data = LoopData { display, state };
5474
5575 if let Some((command, args)) = cli.command.split_first() {
src/niri.rsmodified+21 -6
@@ -56,6 +56,7 @@ use smithay::wayland::tablet_manager::TabletManagerState;
5656 use time::OffsetDateTime;
5757
5858 use crate::backend::{Backend, Tty, Winit};
59+use crate::config::Config;
5960 use crate::dbus::mutter_service_channel::ServiceChannel;
6061 use crate::frame_clock::FrameClock;
6162 use crate::layout::{MonitorRenderElement, MonitorSet};
@@ -115,12 +116,14 @@ pub struct OutputState {
115116 }
116117
117118 pub struct State {
119+ pub config: Config,
118120 pub backend: Backend,
119121 pub niri: Niri,
120122 }
121123
122124 impl State {
123125 pub fn new(
126+ config: Config,
124127 event_loop: LoopHandle<'static, LoopData>,
125128 stop_signal: LoopSignal,
126129 display: &mut Display<State>,
@@ -134,10 +137,20 @@ impl State {
134137 Backend::Tty(Tty::new(event_loop.clone()))
135138 };
136139
137- let mut niri = Niri::new(event_loop, stop_signal, display, backend.seat_name());
140+ let mut niri = Niri::new(
141+ &config,
142+ event_loop,
143+ stop_signal,
144+ display,
145+ backend.seat_name(),
146+ );
138147 backend.init(&mut niri);
139148
140- Self { backend, niri }
149+ Self {
150+ config,
151+ backend,
152+ niri,
153+ }
141154 }
142155
143156 pub fn move_cursor(&mut self, location: Point<f64, Logical>) {
@@ -178,6 +191,7 @@ impl State {
178191
179192 impl Niri {
180193 pub fn new(
194+ config: &Config,
181195 event_loop: LoopHandle<'static, LoopData>,
182196 stop_signal: LoopSignal,
183197 display: &mut Display<State>,
@@ -202,11 +216,12 @@ impl Niri {
202216 PresentationState::new::<State>(&display_handle, CLOCK_MONOTONIC as u32);
203217
204218 let mut seat: Seat<State> = seat_state.new_wl_seat(&display_handle, seat_name);
205- // FIXME: get Xkb and repeat interval from GNOME dconf.
206219 let xkb = XkbConfig {
207- layout: "us,ru",
208- options: Some("grp:win_space_toggle,compose:ralt,ctrl:nocaps".to_owned()),
209- ..Default::default()
220+ rules: &config.input.keyboard.xkb.rules,
221+ model: &config.input.keyboard.xkb.model,
222+ layout: &config.input.keyboard.xkb.layout.as_deref().unwrap_or("us"),
223+ variant: &config.input.keyboard.xkb.variant,
224+ options: config.input.keyboard.xkb.options.clone(),
210225 };
211226 seat.add_keyboard(xkb, 400, 30).unwrap();
212227 seat.add_pointer();