Merge pull request #31 from tonybanters/various_hotfixes
Browse files
KeySyms, Fullscreen, Drag and Drop, Audio+, ESC Bug fix
+1 −1 Cargo.lock
| @@ -222,7 +222,7 @@ checksum = "04744f49eae99ab78e0d5c0b603ab218f515ea8cfe5a456d7629ad883a3b6e7d" | |||
| 222 | 222 | ||
| 223 | [[package]] | 223 | [[package]] |
| 224 | name = "oxwm" | 224 | name = "oxwm" |
| 225 | -version = "0.4.0" | 225 | +version = "0.5.0" |
| 226 | dependencies = [ | 226 | dependencies = [ |
| 227 | "anyhow", | 227 | "anyhow", |
| 228 | "chrono", | 228 | "chrono", |
+1 −1 Cargo.toml
| @@ -1,6 +1,6 @@ | |||
| 1 | [package] | 1 | [package] |
| 2 | name = "oxwm" | 2 | name = "oxwm" |
| 3 | -version = "0.4.0" | 3 | +version = "0.5.0" |
| 4 | edition = "2024" | 4 | edition = "2024" |
| 5 | 5 | ||
| 6 | [lib] | 6 | [lib] |
+0 −38 PKGBUILD deleted file mode 100644
| @@ -1,38 +0,0 @@ | |||
| 1 | -# Maintainer: Tony, btw <tony@tonybtw.com> | ||
| 2 | -pkgname='oxwm-git' | ||
| 3 | -_pkgname='oxwm' | ||
| 4 | -pkgver=0.4.0.177.g6dc200c | ||
| 5 | -pkgrel=1 | ||
| 6 | -arch=('x86_64') | ||
| 7 | -url="https://github.com/tonybanters/oxwm" | ||
| 8 | -pkgdesc="DWM but better with sane defaults, and not suckless." | ||
| 9 | -license=('GPL-3.0-or-later') | ||
| 10 | -depends=('libx11' 'libxft' 'libxcb' 'fontconfig' 'freetype2' 'libxrender') | ||
| 11 | -makedepends=('cargo' 'git') | ||
| 12 | -provides=('oxwm') | ||
| 13 | -conflicts=('oxwm') | ||
| 14 | -source=("$_pkgname::git+https://github.com/tonybanters/oxwm.git") | ||
| 15 | -sha256sums=('SKIP') | ||
| 16 | - | ||
| 17 | -pkgver() { | ||
| 18 | - cd $_pkgname | ||
| 19 | - echo "$(grep '^version =' Cargo.toml | head -n1 | cut -d\" -f2).$(git rev-list --count HEAD).g$(git rev-parse --short HEAD)" | ||
| 20 | -} | ||
| 21 | - | ||
| 22 | -build() { | ||
| 23 | - cd $_pkgname | ||
| 24 | - cargo build --release --locked | ||
| 25 | -} | ||
| 26 | - | ||
| 27 | -check() { | ||
| 28 | - cd $_pkgname | ||
| 29 | - cargo test --release | ||
| 30 | -} | ||
| 31 | - | ||
| 32 | -package() { | ||
| 33 | - cd $_pkgname | ||
| 34 | - install -Dm755 "target/release/$_pkgname" "$pkgdir/usr/bin/$_pkgname" | ||
| 35 | - install -Dm644 LICENSE "$pkgdir/usr/share/licenses/$pkgname/LICENSE" | ||
| 36 | - install -Dm644 oxwm.desktop "$pkgdir/usr/share/xsessions/oxwm.desktop" | ||
| 37 | - install -Dm644 oxwm.1 "$pkgdir/usr/share/man/man1/oxwm.1" | ||
| 38 | -} | ||
+2 −2 default.nix
| @@ -29,8 +29,8 @@ rustPlatform.buildRustPackage (finalAttrs: { | |||
| 29 | ]; | 29 | ]; |
| 30 | 30 | ||
| 31 | postInstall = '' | 31 | postInstall = '' |
| 32 | - install oxwm.desktop -Dt $out/share/xsessions | 32 | + install resources/oxwm.desktop -Dt $out/share/xsessions |
| 33 | - install -Dm644 oxwm.1 -t $out/share/man/man1 | 33 | + install -Dm644 resources/oxwm.1 -t $out/share/man/man1 |
| 34 | ''; | 34 | ''; |
| 35 | 35 | ||
| 36 | passthru.providedSessions = ["oxwm"]; | 36 | passthru.providedSessions = ["oxwm"]; |
+3 −3 justfile
| @@ -19,17 +19,17 @@ test-clean: | |||
| 19 | pkill Xephyr || true | 19 | pkill Xephyr || true |
| 20 | rm -rf ~/.config/oxwm | 20 | rm -rf ~/.config/oxwm |
| 21 | Xephyr -screen 1280x800 :1 & sleep 1 | 21 | Xephyr -screen 1280x800 :1 & sleep 1 |
| 22 | - DISPLAY=:1 cargo run --release -- --config test-config.ron | 22 | + DISPLAY=:1 cargo run --release -- --config resources/test-config.ron |
| 23 | 23 | ||
| 24 | test: | 24 | test: |
| 25 | pkill Xephyr || true | 25 | pkill Xephyr || true |
| 26 | Xephyr -screen 1280x800 :1 & sleep 1 | 26 | Xephyr -screen 1280x800 :1 & sleep 1 |
| 27 | - DISPLAY=:1 cargo run --release -- --config test-config.ron | 27 | + DISPLAY=:1 cargo run --release -- --config resources/test-config.ron |
| 28 | 28 | ||
| 29 | test-multimon: | 29 | test-multimon: |
| 30 | pkill Xephyr || true | 30 | pkill Xephyr || true |
| 31 | Xephyr +xinerama -screen 640x480 -screen 640x480 :1 & sleep 1 | 31 | Xephyr +xinerama -screen 640x480 -screen 640x480 :1 & sleep 1 |
| 32 | - DISPLAY=:1 cargo run --release -- --config test-config.ron | 32 | + DISPLAY=:1 cargo run --release -- --config resources/test-config.ron |
| 33 | 33 | ||
| 34 | init: | 34 | init: |
| 35 | cargo run --release -- --init | 35 | cargo run --release -- --init |
+0 −193 oxwm.1 deleted file mode 100644
| @@ -1,193 +0,0 @@ | |||
| 1 | -.TH OXWM 1 "2025-10-30" "oxwm 0.4.0" "User Commands" | ||
| 2 | -.SH NAME | ||
| 3 | -oxwm \- a dynamic tiling window manager for X11 written in Rust | ||
| 4 | -.SH SYNOPSIS | ||
| 5 | -.B oxwm | ||
| 6 | -[\fIOPTIONS\fR] | ||
| 7 | -.SH DESCRIPTION | ||
| 8 | -.B oxwm | ||
| 9 | -is a lightweight, dynamic tiling window manager for X11 inspired by dwm but ditching the suckless philosophy. Configuration is done via a runtime-loadable config file in RON format, allowing instant hot-reload without recompilation. | ||
| 10 | -.PP | ||
| 11 | -Features include tag-based workspaces, configurable gaps, a modular status bar, keychord support, and persistent window state across restarts. | ||
| 12 | -.SH OPTIONS | ||
| 13 | -.TP | ||
| 14 | -.B \-\-init | ||
| 15 | -Create default config file at | ||
| 16 | -.IR ~/.config/oxwm/config.ron | ||
| 17 | -.TP | ||
| 18 | -.B \-\-config \fIPATH\fR | ||
| 19 | -Use a custom config file at the specified path | ||
| 20 | -.TP | ||
| 21 | -.B \-\-version | ||
| 22 | -Print version information and exit | ||
| 23 | -.TP | ||
| 24 | -.B \-\-help | ||
| 25 | -Print help message and exit | ||
| 26 | -.SH CONFIGURATION | ||
| 27 | -.B oxwm | ||
| 28 | -reads its configuration from | ||
| 29 | -.IR ~/.config/oxwm/config.ron . | ||
| 30 | -If no config exists on first launch, a default template will be created automatically. | ||
| 31 | -.PP | ||
| 32 | -The config file uses RON (Rusty Object Notation) format and supports: | ||
| 33 | -.IP \(bu 2 | ||
| 34 | -Keybindings (including multi-key keychords) | ||
| 35 | -.IP \(bu 2 | ||
| 36 | -Colors and appearance | ||
| 37 | -.IP \(bu 2 | ||
| 38 | -Status bar blocks (battery, RAM, datetime, shell commands) | ||
| 39 | -.IP \(bu 2 | ||
| 40 | -Gaps and borders | ||
| 41 | -.IP \(bu 2 | ||
| 42 | -Terminal and application settings | ||
| 43 | -.IP \(bu 2 | ||
| 44 | -Variable definitions with #DEFINE | ||
| 45 | -.PP | ||
| 46 | -After editing the config, reload with | ||
| 47 | -.B Mod+Shift+R | ||
| 48 | -\(en no compilation required. | ||
| 49 | -.SH DEFAULT KEYBINDINGS | ||
| 50 | -The default modifier key is | ||
| 51 | -.B Super | ||
| 52 | -(Mod4). All bindings are customizable in config.ron. | ||
| 53 | -.SS Window Management | ||
| 54 | -.TP | ||
| 55 | -.B Super+Return | ||
| 56 | -Spawn terminal (default: st) | ||
| 57 | -.TP | ||
| 58 | -.B Super+Q | ||
| 59 | -Kill focused window | ||
| 60 | -.TP | ||
| 61 | -.B Super+J, Super+K | ||
| 62 | -Cycle focus down/up through windows | ||
| 63 | -.TP | ||
| 64 | -.B Super+Shift+Space | ||
| 65 | -Toggle floating mode for focused window | ||
| 66 | -.TP | ||
| 67 | -.B Super+Shift+F | ||
| 68 | -Toggle fullscreen for focused window | ||
| 69 | -.TP | ||
| 70 | -.B Super+Control+H/J/K/L | ||
| 71 | -Move floating window left/down/up/right | ||
| 72 | -.TP | ||
| 73 | -.B Super+Shift+H/J/K/L | ||
| 74 | -Exchange focused window with neighbor in direction | ||
| 75 | -.SS Layouts | ||
| 76 | -.TP | ||
| 77 | -.B Super+F | ||
| 78 | -Switch to floating layout | ||
| 79 | -.TP | ||
| 80 | -.B Super+C | ||
| 81 | -Switch to tiling layout | ||
| 82 | -.TP | ||
| 83 | -.B Super+A | ||
| 84 | -Toggle gaps on/off | ||
| 85 | -.TP | ||
| 86 | -.B Alt+N | ||
| 87 | -Cycle through available layouts | ||
| 88 | -.SS Tags (Workspaces) | ||
| 89 | -.TP | ||
| 90 | -.B Super+1..9 | ||
| 91 | -View tag 1-9 | ||
| 92 | -.TP | ||
| 93 | -.B Super+Shift+1..9 | ||
| 94 | -Move focused window to tag 1-9 | ||
| 95 | -.SS Monitors | ||
| 96 | -.TP | ||
| 97 | -.B Super+Comma | ||
| 98 | -Focus previous monitor | ||
| 99 | -.TP | ||
| 100 | -.B Super+Period | ||
| 101 | -Focus next monitor | ||
| 102 | -.SS Launchers | ||
| 103 | -.TP | ||
| 104 | -.B Super+D | ||
| 105 | -Launch dmenu | ||
| 106 | -.TP | ||
| 107 | -.B Super+S | ||
| 108 | -Take screenshot with maim (selection to clipboard) | ||
| 109 | -.SS Window Manager | ||
| 110 | -.TP | ||
| 111 | -.B Super+Shift+Q | ||
| 112 | -Quit oxwm | ||
| 113 | -.TP | ||
| 114 | -.B Super+Shift+R | ||
| 115 | -Hot reload oxwm (reload config without restarting X) | ||
| 116 | -.SS Keychord Example | ||
| 117 | -.TP | ||
| 118 | -.B Super+Space, T | ||
| 119 | -Spawn terminal (example keychord: two-key sequence) | ||
| 120 | -.PP | ||
| 121 | -Press | ||
| 122 | -.B Escape | ||
| 123 | -to cancel any in-progress keychord sequence. | ||
| 124 | -.SH KEYCHORDS | ||
| 125 | -.B oxwm | ||
| 126 | -supports multi-key sequences called keychords. These allow binding complex commands to sequences like "Super+a then f". | ||
| 127 | -.PP | ||
| 128 | -Example keychord in config.ron: | ||
| 129 | -.PP | ||
| 130 | -.EX | ||
| 131 | - (keys: [ | ||
| 132 | - (modifiers: [Mod4], key: A), | ||
| 133 | - (modifiers: [], key: F), | ||
| 134 | - ], action: ToggleFloating), | ||
| 135 | -.EE | ||
| 136 | -.PP | ||
| 137 | -This binds "Super+a followed by f" to toggle floating mode. | ||
| 138 | -.SH FILES | ||
| 139 | -.TP | ||
| 140 | -.I ~/.config/oxwm/config.ron | ||
| 141 | -Main configuration file | ||
| 142 | -.TP | ||
| 143 | -.I /usr/share/xsessions/oxwm.desktop | ||
| 144 | -X session desktop entry (if installed via package manager) | ||
| 145 | -.SH ENVIRONMENT | ||
| 146 | -.TP | ||
| 147 | -.B DISPLAY | ||
| 148 | -X11 display to connect to (standard X11 variable) | ||
| 149 | -.SH EXAMPLES | ||
| 150 | -.TP | ||
| 151 | -Start oxwm normally: | ||
| 152 | -.EX | ||
| 153 | - oxwm | ||
| 154 | -.EE | ||
| 155 | -.TP | ||
| 156 | -Initialize config file: | ||
| 157 | -.EX | ||
| 158 | - oxwm --init | ||
| 159 | -.EE | ||
| 160 | -.TP | ||
| 161 | -Use custom config: | ||
| 162 | -.EX | ||
| 163 | - oxwm --config ~/my-oxwm-config.ron | ||
| 164 | -.EE | ||
| 165 | -.TP | ||
| 166 | -Test in Xephyr (nested X server): | ||
| 167 | -.EX | ||
| 168 | - Xephyr -screen 1280x800 :1 & | ||
| 169 | - DISPLAY=:1 oxwm | ||
| 170 | -.EE | ||
| 171 | -.SH TESTING | ||
| 172 | -Test oxwm without affecting your current session using Xephyr: | ||
| 173 | -.PP | ||
| 174 | -.EX | ||
| 175 | - # Start nested X server | ||
| 176 | - Xephyr -screen 1280x800 :1 & | ||
| 177 | - | ||
| 178 | - # Run oxwm in it | ||
| 179 | - DISPLAY=:1 oxwm | ||
| 180 | -.EE | ||
| 181 | -.SH BUGS | ||
| 182 | -Report bugs at: https://github.com/tonybanters/oxwm/issues | ||
| 183 | -.SH SEE ALSO | ||
| 184 | -.BR X (7), | ||
| 185 | -.BR dwm (1), | ||
| 186 | -.BR dmenu (1), | ||
| 187 | -.BR xrandr (1) | ||
| 188 | -.SH AUTHORS | ||
| 189 | -Written by Tony (tonybtw). | ||
| 190 | -.PP | ||
| 191 | -Inspired by dwm but designed to be user-friendly and eliminate arbitrary elitism. | ||
| 192 | -.SH LICENSE | ||
| 193 | -GPL v3 - see https://www.gnu.org/licenses/gpl-3.0.en.html | ||
+0 −7 oxwm.desktop deleted file mode 100644
| @@ -1,7 +0,0 @@ | |||
| 1 | -[Desktop Entry] | ||
| 2 | -Name=oxwm | ||
| 3 | -Comment=DWM but better with sane defaults | ||
| 4 | -Exec=oxwm | ||
| 5 | -Type=Application | ||
| 6 | -Keywords=wm;windowmanager;window;manager; | ||
| 7 | -Version=1.5 | ||
+38 −0 resources/PKGBUILD new file mode 100644
| @@ -0,0 +1,38 @@ | |||
| 1 | +# Maintainer: Tony, btw <tony@tonybtw.com> | ||
| 2 | +pkgname='oxwm-git' | ||
| 3 | +_pkgname='oxwm' | ||
| 4 | +pkgver=0.4.0.177.g6dc200c | ||
| 5 | +pkgrel=1 | ||
| 6 | +arch=('x86_64') | ||
| 7 | +url="https://github.com/tonybanters/oxwm" | ||
| 8 | +pkgdesc="DWM but better with sane defaults, and not suckless." | ||
| 9 | +license=('GPL-3.0-or-later') | ||
| 10 | +depends=('libx11' 'libxft' 'libxcb' 'fontconfig' 'freetype2' 'libxrender') | ||
| 11 | +makedepends=('cargo' 'git') | ||
| 12 | +provides=('oxwm') | ||
| 13 | +conflicts=('oxwm') | ||
| 14 | +source=("$_pkgname::git+https://github.com/tonybanters/oxwm.git") | ||
| 15 | +sha256sums=('SKIP') | ||
| 16 | + | ||
| 17 | +pkgver() { | ||
| 18 | + cd $_pkgname | ||
| 19 | + echo "$(grep '^version =' Cargo.toml | head -n1 | cut -d\" -f2).$(git rev-list --count HEAD).g$(git rev-parse --short HEAD)" | ||
| 20 | +} | ||
| 21 | + | ||
| 22 | +build() { | ||
| 23 | + cd $_pkgname | ||
| 24 | + cargo build --release --locked | ||
| 25 | +} | ||
| 26 | + | ||
| 27 | +check() { | ||
| 28 | + cd $_pkgname | ||
| 29 | + cargo test --release | ||
| 30 | +} | ||
| 31 | + | ||
| 32 | +package() { | ||
| 33 | + cd $_pkgname | ||
| 34 | + install -Dm755 "target/release/$_pkgname" "$pkgdir/usr/bin/$_pkgname" | ||
| 35 | + install -Dm644 LICENSE "$pkgdir/usr/share/licenses/$pkgname/LICENSE" | ||
| 36 | + install -Dm644 resources/oxwm.desktop "$pkgdir/usr/share/xsessions/oxwm.desktop" | ||
| 37 | + install -Dm644 resources/oxwm.1 "$pkgdir/usr/share/man/man1/oxwm.1" | ||
| 38 | +} | ||
+193 −0 resources/oxwm.1 new file mode 100644
| @@ -0,0 +1,193 @@ | |||
| 1 | +.TH OXWM 1 "2025-10-30" "oxwm 0.4.0" "User Commands" | ||
| 2 | +.SH NAME | ||
| 3 | +oxwm \- a dynamic tiling window manager for X11 written in Rust | ||
| 4 | +.SH SYNOPSIS | ||
| 5 | +.B oxwm | ||
| 6 | +[\fIOPTIONS\fR] | ||
| 7 | +.SH DESCRIPTION | ||
| 8 | +.B oxwm | ||
| 9 | +is a lightweight, dynamic tiling window manager for X11 inspired by dwm but ditching the suckless philosophy. Configuration is done via a runtime-loadable config file in RON format, allowing instant hot-reload without recompilation. | ||
| 10 | +.PP | ||
| 11 | +Features include tag-based workspaces, configurable gaps, a modular status bar, keychord support, and persistent window state across restarts. | ||
| 12 | +.SH OPTIONS | ||
| 13 | +.TP | ||
| 14 | +.B \-\-init | ||
| 15 | +Create default config file at | ||
| 16 | +.IR ~/.config/oxwm/config.ron | ||
| 17 | +.TP | ||
| 18 | +.B \-\-config \fIPATH\fR | ||
| 19 | +Use a custom config file at the specified path | ||
| 20 | +.TP | ||
| 21 | +.B \-\-version | ||
| 22 | +Print version information and exit | ||
| 23 | +.TP | ||
| 24 | +.B \-\-help | ||
| 25 | +Print help message and exit | ||
| 26 | +.SH CONFIGURATION | ||
| 27 | +.B oxwm | ||
| 28 | +reads its configuration from | ||
| 29 | +.IR ~/.config/oxwm/config.ron . | ||
| 30 | +If no config exists on first launch, a default template will be created automatically. | ||
| 31 | +.PP | ||
| 32 | +The config file uses RON (Rusty Object Notation) format and supports: | ||
| 33 | +.IP \(bu 2 | ||
| 34 | +Keybindings (including multi-key keychords) | ||
| 35 | +.IP \(bu 2 | ||
| 36 | +Colors and appearance | ||
| 37 | +.IP \(bu 2 | ||
| 38 | +Status bar blocks (battery, RAM, datetime, shell commands) | ||
| 39 | +.IP \(bu 2 | ||
| 40 | +Gaps and borders | ||
| 41 | +.IP \(bu 2 | ||
| 42 | +Terminal and application settings | ||
| 43 | +.IP \(bu 2 | ||
| 44 | +Variable definitions with #DEFINE | ||
| 45 | +.PP | ||
| 46 | +After editing the config, reload with | ||
| 47 | +.B Mod+Shift+R | ||
| 48 | +\(en no compilation required. | ||
| 49 | +.SH DEFAULT KEYBINDINGS | ||
| 50 | +The default modifier key is | ||
| 51 | +.B Super | ||
| 52 | +(Mod4). All bindings are customizable in config.ron. | ||
| 53 | +.SS Window Management | ||
| 54 | +.TP | ||
| 55 | +.B Super+Return | ||
| 56 | +Spawn terminal (default: st) | ||
| 57 | +.TP | ||
| 58 | +.B Super+Q | ||
| 59 | +Kill focused window | ||
| 60 | +.TP | ||
| 61 | +.B Super+J, Super+K | ||
| 62 | +Cycle focus down/up through windows | ||
| 63 | +.TP | ||
| 64 | +.B Super+Shift+Space | ||
| 65 | +Toggle floating mode for focused window | ||
| 66 | +.TP | ||
| 67 | +.B Super+Shift+F | ||
| 68 | +Toggle fullscreen for focused window | ||
| 69 | +.TP | ||
| 70 | +.B Super+Control+H/J/K/L | ||
| 71 | +Move floating window left/down/up/right | ||
| 72 | +.TP | ||
| 73 | +.B Super+Shift+H/J/K/L | ||
| 74 | +Exchange focused window with neighbor in direction | ||
| 75 | +.SS Layouts | ||
| 76 | +.TP | ||
| 77 | +.B Super+F | ||
| 78 | +Switch to floating layout | ||
| 79 | +.TP | ||
| 80 | +.B Super+C | ||
| 81 | +Switch to tiling layout | ||
| 82 | +.TP | ||
| 83 | +.B Super+A | ||
| 84 | +Toggle gaps on/off | ||
| 85 | +.TP | ||
| 86 | +.B Alt+N | ||
| 87 | +Cycle through available layouts | ||
| 88 | +.SS Tags (Workspaces) | ||
| 89 | +.TP | ||
| 90 | +.B Super+1..9 | ||
| 91 | +View tag 1-9 | ||
| 92 | +.TP | ||
| 93 | +.B Super+Shift+1..9 | ||
| 94 | +Move focused window to tag 1-9 | ||
| 95 | +.SS Monitors | ||
| 96 | +.TP | ||
| 97 | +.B Super+Comma | ||
| 98 | +Focus previous monitor | ||
| 99 | +.TP | ||
| 100 | +.B Super+Period | ||
| 101 | +Focus next monitor | ||
| 102 | +.SS Launchers | ||
| 103 | +.TP | ||
| 104 | +.B Super+D | ||
| 105 | +Launch dmenu | ||
| 106 | +.TP | ||
| 107 | +.B Super+S | ||
| 108 | +Take screenshot with maim (selection to clipboard) | ||
| 109 | +.SS Window Manager | ||
| 110 | +.TP | ||
| 111 | +.B Super+Shift+Q | ||
| 112 | +Quit oxwm | ||
| 113 | +.TP | ||
| 114 | +.B Super+Shift+R | ||
| 115 | +Hot reload oxwm (reload config without restarting X) | ||
| 116 | +.SS Keychord Example | ||
| 117 | +.TP | ||
| 118 | +.B Super+Space, T | ||
| 119 | +Spawn terminal (example keychord: two-key sequence) | ||
| 120 | +.PP | ||
| 121 | +Press | ||
| 122 | +.B Escape | ||
| 123 | +to cancel any in-progress keychord sequence. | ||
| 124 | +.SH KEYCHORDS | ||
| 125 | +.B oxwm | ||
| 126 | +supports multi-key sequences called keychords. These allow binding complex commands to sequences like "Super+a then f". | ||
| 127 | +.PP | ||
| 128 | +Example keychord in config.ron: | ||
| 129 | +.PP | ||
| 130 | +.EX | ||
| 131 | + (keys: [ | ||
| 132 | + (modifiers: [Mod4], key: A), | ||
| 133 | + (modifiers: [], key: F), | ||
| 134 | + ], action: ToggleFloating), | ||
| 135 | +.EE | ||
| 136 | +.PP | ||
| 137 | +This binds "Super+a followed by f" to toggle floating mode. | ||
| 138 | +.SH FILES | ||
| 139 | +.TP | ||
| 140 | +.I ~/.config/oxwm/config.ron | ||
| 141 | +Main configuration file | ||
| 142 | +.TP | ||
| 143 | +.I /usr/share/xsessions/oxwm.desktop | ||
| 144 | +X session desktop entry (if installed via package manager) | ||
| 145 | +.SH ENVIRONMENT | ||
| 146 | +.TP | ||
| 147 | +.B DISPLAY | ||
| 148 | +X11 display to connect to (standard X11 variable) | ||
| 149 | +.SH EXAMPLES | ||
| 150 | +.TP | ||
| 151 | +Start oxwm normally: | ||
| 152 | +.EX | ||
| 153 | + oxwm | ||
| 154 | +.EE | ||
| 155 | +.TP | ||
| 156 | +Initialize config file: | ||
| 157 | +.EX | ||
| 158 | + oxwm --init | ||
| 159 | +.EE | ||
| 160 | +.TP | ||
| 161 | +Use custom config: | ||
| 162 | +.EX | ||
| 163 | + oxwm --config ~/my-oxwm-config.ron | ||
| 164 | +.EE | ||
| 165 | +.TP | ||
| 166 | +Test in Xephyr (nested X server): | ||
| 167 | +.EX | ||
| 168 | + Xephyr -screen 1280x800 :1 & | ||
| 169 | + DISPLAY=:1 oxwm | ||
| 170 | +.EE | ||
| 171 | +.SH TESTING | ||
| 172 | +Test oxwm without affecting your current session using Xephyr: | ||
| 173 | +.PP | ||
| 174 | +.EX | ||
| 175 | + # Start nested X server | ||
| 176 | + Xephyr -screen 1280x800 :1 & | ||
| 177 | + | ||
| 178 | + # Run oxwm in it | ||
| 179 | + DISPLAY=:1 oxwm | ||
| 180 | +.EE | ||
| 181 | +.SH BUGS | ||
| 182 | +Report bugs at: https://github.com/tonybanters/oxwm/issues | ||
| 183 | +.SH SEE ALSO | ||
| 184 | +.BR X (7), | ||
| 185 | +.BR dwm (1), | ||
| 186 | +.BR dmenu (1), | ||
| 187 | +.BR xrandr (1) | ||
| 188 | +.SH AUTHORS | ||
| 189 | +Written by Tony (tonybtw). | ||
| 190 | +.PP | ||
| 191 | +Inspired by dwm but designed to be user-friendly and eliminate arbitrary elitism. | ||
| 192 | +.SH LICENSE | ||
| 193 | +GPL v3 - see https://www.gnu.org/licenses/gpl-3.0.en.html | ||
+7 −0 resources/oxwm.desktop new file mode 100644
| @@ -0,0 +1,7 @@ | |||
| 1 | +[Desktop Entry] | ||
| 2 | +Name=oxwm | ||
| 3 | +Comment=DWM but better with sane defaults | ||
| 4 | +Exec=oxwm | ||
| 5 | +Type=Application | ||
| 6 | +Keywords=wm;windowmanager;window;manager; | ||
| 7 | +Version=1.5 | ||
+165 −0 resources/test-config.ron new file mode 100644
| @@ -0,0 +1,165 @@ | |||
| 1 | +#![enable(implicit_some)] | ||
| 2 | +// OXWM Configuration File | ||
| 3 | +// Edit this file and reload with Mod+Shift+R (no compilation needed!) | ||
| 4 | + | ||
| 5 | +#DEFINE $terminal = "st" | ||
| 6 | +#DEFINE $color_blue = 0x6dade3 | ||
| 7 | +#DEFINE $color_grey = 0xbbbbbb | ||
| 8 | +#DEFINE $color_green = 0x9ece6a | ||
| 9 | +#DEFINE $color_red = 0xf7768e | ||
| 10 | +#DEFINE $color_cyan = 0x0db9d7 | ||
| 11 | +#DEFINE $color_purple = 0xad8ee6 | ||
| 12 | +#DEFINE $color_lavender = 0xa9b1d6 | ||
| 13 | +#DEFINE $color_bg = 0x1a1b26 | ||
| 14 | +#DEFINE $color_fg = 0xbbbbbb | ||
| 15 | +#DEFINE $color_light_blue = 0x7aa2f7 | ||
| 16 | + | ||
| 17 | +( | ||
| 18 | + border_width: 2, | ||
| 19 | + border_focused: $color_blue, | ||
| 20 | + border_unfocused: $color_grey, | ||
| 21 | + font: "JetBrainsMono Nerd Font:style=Bold:size=12", | ||
| 22 | + | ||
| 23 | + gaps_enabled: true, | ||
| 24 | + gap_inner_horizontal: 5, | ||
| 25 | + gap_inner_vertical: 5, | ||
| 26 | + gap_outer_horizontal: 5, | ||
| 27 | + gap_outer_vertical: 5, | ||
| 28 | + | ||
| 29 | + terminal: $terminal, | ||
| 30 | + modkey: Mod1, | ||
| 31 | + tags: ["1", "2", "3", "4", "5", "6", "7", "8", "9"], | ||
| 32 | + | ||
| 33 | + // Alternative icon tags (uncomment to use): | ||
| 34 | + // tags: ["", "", "", "", "", "", "", "", ""], | ||
| 35 | + | ||
| 36 | + // Alternative text tags (uncomment to use): | ||
| 37 | + // tags: ["DEV", "WWW", "SYS", "DOC", "VBOX", "CHAT", "MUS", "VID", "MISC"], | ||
| 38 | + | ||
| 39 | + layout_symbols: [ | ||
| 40 | + (name: "tiling", symbol: "[T]"), | ||
| 41 | + (name: "normie", symbol: "[F]"), | ||
| 42 | + ], | ||
| 43 | + | ||
| 44 | + keybindings: [ | ||
| 45 | + (keys: [(modifiers: [Mod1], key: Space), (modifiers: [], key: T)], action: Spawn, arg: "st"), | ||
| 46 | + (modifiers: [Mod1], key: Return, action: Spawn, arg: $terminal), | ||
| 47 | + (modifiers: [Mod1], key: D, action: Spawn, arg: ["sh", "-c", "dmenu_run -l 10"]), | ||
| 48 | + (modifiers: [Mod1], key: S, action: Spawn, arg: ["sh", "-c", "maim -s | xclip -selection clipboard -t image/png"]), | ||
| 49 | + (modifiers: [Mod1], key: Q, action: KillClient), | ||
| 50 | + (modifiers: [Mod1, Shift], key: F, action: ToggleFullScreen), | ||
| 51 | + (modifiers: [Mod1, Shift], key: Space, action: ToggleFloating), | ||
| 52 | + (modifiers: [Mod1], key: F, action: ChangeLayout, arg: "normie"), | ||
| 53 | + (modifiers: [Mod1], key: C, action: ChangeLayout, arg: "tiling"), | ||
| 54 | + (modifiers: [Mod1], key: N, action: CycleLayout), | ||
| 55 | + (modifiers: [Mod1], key: A, action: ToggleGaps), | ||
| 56 | + (modifiers: [Mod1, Shift], key: Q, action: Quit), | ||
| 57 | + (modifiers: [Mod1, Shift], key: R, action: Restart), | ||
| 58 | + (modifiers: [Mod1], key: J, action: FocusStack, arg: -1), | ||
| 59 | + (modifiers: [Mod1], key: K, action: FocusStack, arg: 1), | ||
| 60 | + // Exchange client (vim-style with Mod+Shift) | ||
| 61 | + (modifiers: [Mod1, Control], key: K, action: SmartMoveWin, arg: 0), // UP | ||
| 62 | + (modifiers: [Mod1, Control], key: J, action: SmartMoveWin, arg: 1), // DOWN | ||
| 63 | + (modifiers: [Mod1, Control], key: H, action: SmartMoveWin, arg: 2), // LEFT | ||
| 64 | + (modifiers: [Mod1, Control], key: L, action: SmartMoveWin, arg: 3), // RIGHT | ||
| 65 | + (modifiers: [Mod1, Shift], key: K, action: ExchangeClient, arg: 0), // UP | ||
| 66 | + (modifiers: [Mod1, Shift], key: J, action: ExchangeClient, arg: 1), // DOWN | ||
| 67 | + (modifiers: [Mod1, Shift], key: H, action: ExchangeClient, arg: 2), // LEFT | ||
| 68 | + (modifiers: [Mod1, Shift], key: L, action: ExchangeClient, arg: 3), // RIGHT | ||
| 69 | + (modifiers: [Mod1], key: Key1, action: ViewTag, arg: 0), | ||
| 70 | + (modifiers: [Mod1], key: Key2, action: ViewTag, arg: 1), | ||
| 71 | + (modifiers: [Mod1], key: Key3, action: ViewTag, arg: 2), | ||
| 72 | + (modifiers: [Mod1], key: Key4, action: ViewTag, arg: 3), | ||
| 73 | + (modifiers: [Mod1], key: Key5, action: ViewTag, arg: 4), | ||
| 74 | + (modifiers: [Mod1], key: Key6, action: ViewTag, arg: 5), | ||
| 75 | + (modifiers: [Mod1], key: Key7, action: ViewTag, arg: 6), | ||
| 76 | + (modifiers: [Mod1], key: Key8, action: ViewTag, arg: 7), | ||
| 77 | + (modifiers: [Mod1], key: Key9, action: ViewTag, arg: 8), | ||
| 78 | + (modifiers: [Mod1, Shift], key: Key1, action: MoveToTag, arg: 0), | ||
| 79 | + (modifiers: [Mod1, Shift], key: Key2, action: MoveToTag, arg: 1), | ||
| 80 | + (modifiers: [Mod1, Shift], key: Key3, action: MoveToTag, arg: 2), | ||
| 81 | + (modifiers: [Mod1, Shift], key: Key4, action: MoveToTag, arg: 3), | ||
| 82 | + (modifiers: [Mod1, Shift], key: Key5, action: MoveToTag, arg: 4), | ||
| 83 | + (modifiers: [Mod1, Shift], key: Key6, action: MoveToTag, arg: 5), | ||
| 84 | + (modifiers: [Mod1, Shift], key: Key7, action: MoveToTag, arg: 6), | ||
| 85 | + (modifiers: [Mod1, Shift], key: Key8, action: MoveToTag, arg: 7), | ||
| 86 | + (modifiers: [Mod1, Shift], key: Key9, action: MoveToTag, arg: 8), | ||
| 87 | + ], | ||
| 88 | + | ||
| 89 | + status_blocks: [ | ||
| 90 | + // Battery block (shows charging/discharging status) | ||
| 91 | + ( | ||
| 92 | + format: "", | ||
| 93 | + command: "Battery", | ||
| 94 | + battery_formats: ( | ||
| 95 | + charging: " Bat: {}%", | ||
| 96 | + discharging: " Bat:{}%", | ||
| 97 | + full: " Bat: {}%", | ||
| 98 | + ), | ||
| 99 | + interval_secs: 30, | ||
| 100 | + color: $color_green, | ||
| 101 | + underline: true, | ||
| 102 | + ), | ||
| 103 | + | ||
| 104 | + // Separator | ||
| 105 | + ( | ||
| 106 | + format: " │ ", | ||
| 107 | + command: "Static", | ||
| 108 | + interval_secs: 18446744073709551615, | ||
| 109 | + color: $color_lavender, | ||
| 110 | + underline: false, | ||
| 111 | + ), | ||
| 112 | + | ||
| 113 | + // RAM usage | ||
| 114 | + ( | ||
| 115 | + format: " {used}/{total} GB", | ||
| 116 | + command: "Ram", | ||
| 117 | + interval_secs: 5, | ||
| 118 | + color: $color_light_blue, | ||
| 119 | + underline: true, | ||
| 120 | + ), | ||
| 121 | + | ||
| 122 | + // Separator | ||
| 123 | + ( | ||
| 124 | + format: " │ ", | ||
| 125 | + command: "Static", | ||
| 126 | + interval_secs: 18446744073709551615, | ||
| 127 | + color: $color_lavender, | ||
| 128 | + underline: false, | ||
| 129 | + ), | ||
| 130 | + | ||
| 131 | + // Kernel version | ||
| 132 | + ( | ||
| 133 | + format: " {}", | ||
| 134 | + command: "Shell", | ||
| 135 | + command_arg: "uname -r", | ||
| 136 | + interval_secs: 18446744073709551615, | ||
| 137 | + color: $color_red, | ||
| 138 | + underline: true, | ||
| 139 | + ), | ||
| 140 | + | ||
| 141 | + // Separator | ||
| 142 | + ( | ||
| 143 | + format: " │ ", | ||
| 144 | + command: "Static", | ||
| 145 | + interval_secs: 18446744073709551615, | ||
| 146 | + color: $color_lavender, | ||
| 147 | + underline: false, | ||
| 148 | + ), | ||
| 149 | + | ||
| 150 | + // Date and time | ||
| 151 | + ( | ||
| 152 | + format: " {}", | ||
| 153 | + command: "DateTime", | ||
| 154 | + command_arg: "%a, %b %d - %-I:%M %P", | ||
| 155 | + interval_secs: 1, | ||
| 156 | + color: $color_cyan, | ||
| 157 | + underline: true, | ||
| 158 | + ), | ||
| 159 | + ], | ||
| 160 | + | ||
| 161 | + scheme_normal: (foreground: $color_fg, background: $color_bg, underline: 0x444444), | ||
| 162 | + scheme_occupied: (foreground: $color_cyan, background: $color_bg, underline: $color_cyan), | ||
| 163 | + scheme_selected: (foreground: $color_cyan, background: $color_bg, underline: $color_purple), | ||
| 164 | +) | ||
| 165 | + | ||
+90 −163 src/config/mod.rs
| @@ -1,11 +1,12 @@ | |||
| 1 | use crate::bar::{BlockCommand, BlockConfig}; | 1 | use crate::bar::{BlockCommand, BlockConfig}; |
| 2 | use crate::errors::ConfigError; | 2 | use crate::errors::ConfigError; |
| 3 | use crate::keyboard::handlers::{KeyBinding, KeyPress}; | 3 | use crate::keyboard::handlers::{KeyBinding, KeyPress}; |
| 4 | -use crate::keyboard::keycodes; | 4 | +use crate::keyboard::keysyms; |
| 5 | use crate::keyboard::{Arg, KeyAction}; | 5 | use crate::keyboard::{Arg, KeyAction}; |
| 6 | +use crate::keyboard::keysyms::Keysym; | ||
| 6 | use serde::Deserialize; | 7 | use serde::Deserialize; |
| 7 | use std::collections::HashMap; | 8 | use std::collections::HashMap; |
| 8 | -use x11rb::protocol::xproto::{KeyButMask, Keycode}; | 9 | +use x11rb::protocol::xproto::KeyButMask; |
| 9 | 10 | ||
| 10 | #[derive(Debug, Deserialize)] | 11 | #[derive(Debug, Deserialize)] |
| 11 | pub enum ModKey { | 12 | pub enum ModKey { |
| @@ -76,172 +77,98 @@ pub enum KeyData { | |||
| 76 | Comma, | 77 | Comma, |
| 77 | Period, | 78 | Period, |
| 78 | Slash, | 79 | Slash, |
| 80 | + AudioRaiseVolume, | ||
| 81 | + AudioLowerVolume, | ||
| 82 | + AudioMute, | ||
| 83 | + MonBrightnessUp, | ||
| 84 | + MonBrightnessDown, | ||
| 79 | } | 85 | } |
| 80 | 86 | ||
| 81 | impl KeyData { | 87 | impl KeyData { |
| 82 | - fn to_keycode(&self) -> Keycode { | 88 | + fn to_keysym(&self) -> Keysym { |
| 83 | match self { | 89 | match self { |
| 84 | - KeyData::Return => keycodes::RETURN, | 90 | + KeyData::Return => keysyms::XK_RETURN, |
| 85 | - KeyData::Q => keycodes::Q, | 91 | + KeyData::Q => keysyms::XK_Q, |
| 86 | - KeyData::Escape => keycodes::ESCAPE, | 92 | + KeyData::Escape => keysyms::XK_ESCAPE, |
| 87 | - KeyData::Space => keycodes::SPACE, | 93 | + KeyData::Space => keysyms::XK_SPACE, |
| 88 | - KeyData::Tab => keycodes::TAB, | 94 | + KeyData::Tab => keysyms::XK_TAB, |
| 89 | - KeyData::Backspace => keycodes::BACKSPACE, | 95 | + KeyData::Backspace => keysyms::XK_BACKSPACE, |
| 90 | - KeyData::Delete => keycodes::DELETE, | 96 | + KeyData::Delete => keysyms::XK_DELETE, |
| 91 | - KeyData::F1 => keycodes::F1, | 97 | + KeyData::F1 => keysyms::XK_F1, |
| 92 | - KeyData::F2 => keycodes::F2, | 98 | + KeyData::F2 => keysyms::XK_F2, |
| 93 | - KeyData::F3 => keycodes::F3, | 99 | + KeyData::F3 => keysyms::XK_F3, |
| 94 | - KeyData::F4 => keycodes::F4, | 100 | + KeyData::F4 => keysyms::XK_F4, |
| 95 | - KeyData::F5 => keycodes::F5, | 101 | + KeyData::F5 => keysyms::XK_F5, |
| 96 | - KeyData::F6 => keycodes::F6, | 102 | + KeyData::F6 => keysyms::XK_F6, |
| 97 | - KeyData::F7 => keycodes::F7, | 103 | + KeyData::F7 => keysyms::XK_F7, |
| 98 | - KeyData::F8 => keycodes::F8, | 104 | + KeyData::F8 => keysyms::XK_F8, |
| 99 | - KeyData::F9 => keycodes::F9, | 105 | + KeyData::F9 => keysyms::XK_F9, |
| 100 | - KeyData::F10 => keycodes::F10, | 106 | + KeyData::F10 => keysyms::XK_F10, |
| 101 | - KeyData::F11 => keycodes::F11, | 107 | + KeyData::F11 => keysyms::XK_F11, |
| 102 | - KeyData::F12 => keycodes::F12, | 108 | + KeyData::F12 => keysyms::XK_F12, |
| 103 | - KeyData::A => keycodes::A, | 109 | + KeyData::A => keysyms::XK_A, |
| 104 | - KeyData::B => keycodes::B, | 110 | + KeyData::B => keysyms::XK_B, |
| 105 | - KeyData::C => keycodes::C, | 111 | + KeyData::C => keysyms::XK_C, |
| 106 | - KeyData::D => keycodes::D, | 112 | + KeyData::D => keysyms::XK_D, |
| 107 | - KeyData::E => keycodes::E, | 113 | + KeyData::E => keysyms::XK_E, |
| 108 | - KeyData::F => keycodes::F, | 114 | + KeyData::F => keysyms::XK_F, |
| 109 | - KeyData::G => keycodes::G, | 115 | + KeyData::G => keysyms::XK_G, |
| 110 | - KeyData::H => keycodes::H, | 116 | + KeyData::H => keysyms::XK_H, |
| 111 | - KeyData::I => keycodes::I, | 117 | + KeyData::I => keysyms::XK_I, |
| 112 | - KeyData::J => keycodes::J, | 118 | + KeyData::J => keysyms::XK_J, |
| 113 | - KeyData::K => keycodes::K, | 119 | + KeyData::K => keysyms::XK_K, |
| 114 | - KeyData::L => keycodes::L, | 120 | + KeyData::L => keysyms::XK_L, |
| 115 | - KeyData::M => keycodes::M, | 121 | + KeyData::M => keysyms::XK_M, |
| 116 | - KeyData::N => keycodes::N, | 122 | + KeyData::N => keysyms::XK_N, |
| 117 | - KeyData::O => keycodes::O, | 123 | + KeyData::O => keysyms::XK_O, |
| 118 | - KeyData::P => keycodes::P, | 124 | + KeyData::P => keysyms::XK_P, |
| 119 | - KeyData::R => keycodes::R, | 125 | + KeyData::R => keysyms::XK_R, |
| 120 | - KeyData::S => keycodes::S, | 126 | + KeyData::S => keysyms::XK_S, |
| 121 | - KeyData::T => keycodes::T, | 127 | + KeyData::T => keysyms::XK_T, |
| 122 | - KeyData::U => keycodes::U, | 128 | + KeyData::U => keysyms::XK_U, |
| 123 | - KeyData::V => keycodes::V, | 129 | + KeyData::V => keysyms::XK_V, |
| 124 | - KeyData::W => keycodes::W, | 130 | + KeyData::W => keysyms::XK_W, |
| 125 | - KeyData::X => keycodes::X, | 131 | + KeyData::X => keysyms::XK_X, |
| 126 | - KeyData::Y => keycodes::Y, | 132 | + KeyData::Y => keysyms::XK_Y, |
| 127 | - KeyData::Z => keycodes::Z, | 133 | + KeyData::Z => keysyms::XK_Z, |
| 128 | - KeyData::Key0 => keycodes::KEY_0, | 134 | + KeyData::Key0 => keysyms::XK_0, |
| 129 | - KeyData::Key1 => keycodes::KEY_1, | 135 | + KeyData::Key1 => keysyms::XK_1, |
| 130 | - KeyData::Key2 => keycodes::KEY_2, | 136 | + KeyData::Key2 => keysyms::XK_2, |
| 131 | - KeyData::Key3 => keycodes::KEY_3, | 137 | + KeyData::Key3 => keysyms::XK_3, |
| 132 | - KeyData::Key4 => keycodes::KEY_4, | 138 | + KeyData::Key4 => keysyms::XK_4, |
| 133 | - KeyData::Key5 => keycodes::KEY_5, | 139 | + KeyData::Key5 => keysyms::XK_5, |
| 134 | - KeyData::Key6 => keycodes::KEY_6, | 140 | + KeyData::Key6 => keysyms::XK_6, |
| 135 | - KeyData::Key7 => keycodes::KEY_7, | 141 | + KeyData::Key7 => keysyms::XK_7, |
| 136 | - KeyData::Key8 => keycodes::KEY_8, | 142 | + KeyData::Key8 => keysyms::XK_8, |
| 137 | - KeyData::Key9 => keycodes::KEY_9, | 143 | + KeyData::Key9 => keysyms::XK_9, |
| 138 | - KeyData::Left => keycodes::LEFT, | 144 | + KeyData::Left => keysyms::XK_LEFT, |
| 139 | - KeyData::Right => keycodes::RIGHT, | 145 | + KeyData::Right => keysyms::XK_RIGHT, |
| 140 | - KeyData::Up => keycodes::UP, | 146 | + KeyData::Up => keysyms::XK_UP, |
| 141 | - KeyData::Down => keycodes::DOWN, | 147 | + KeyData::Down => keysyms::XK_DOWN, |
| 142 | - KeyData::Home => keycodes::HOME, | 148 | + KeyData::Home => keysyms::XK_HOME, |
| 143 | - KeyData::End => keycodes::END, | 149 | + KeyData::End => keysyms::XK_END, |
| 144 | - KeyData::PageUp => keycodes::PAGE_UP, | 150 | + KeyData::PageUp => keysyms::XK_PAGE_UP, |
| 145 | - KeyData::PageDown => keycodes::PAGE_DOWN, | 151 | + KeyData::PageDown => keysyms::XK_PAGE_DOWN, |
| 146 | - KeyData::Insert => keycodes::INSERT, | 152 | + KeyData::Insert => keysyms::XK_INSERT, |
| 147 | - KeyData::Minus => keycodes::MINUS, | 153 | + KeyData::Minus => keysyms::XK_MINUS, |
| 148 | - KeyData::Equal => keycodes::EQUAL, | 154 | + KeyData::Equal => keysyms::XK_EQUAL, |
| 149 | - KeyData::BracketLeft => keycodes::LEFT_BRACKET, | 155 | + KeyData::BracketLeft => keysyms::XK_LEFT_BRACKET, |
| 150 | - KeyData::BracketRight => keycodes::RIGHT_BRACKET, | 156 | + KeyData::BracketRight => keysyms::XK_RIGHT_BRACKET, |
| 151 | - KeyData::Semicolon => keycodes::SEMICOLON, | 157 | + KeyData::Semicolon => keysyms::XK_SEMICOLON, |
| 152 | - KeyData::Apostrophe => keycodes::APOSTROPHE, | 158 | + KeyData::Apostrophe => keysyms::XK_APOSTROPHE, |
| 153 | - KeyData::Grave => keycodes::GRAVE, | 159 | + KeyData::Grave => keysyms::XK_GRAVE, |
| 154 | - KeyData::Backslash => keycodes::BACKSLASH, | 160 | + KeyData::Backslash => keysyms::XK_BACKSLASH, |
| 155 | - KeyData::Comma => keycodes::COMMA, | 161 | + KeyData::Comma => keysyms::XK_COMMA, |
| 156 | - KeyData::Period => keycodes::PERIOD, | 162 | + KeyData::Period => keysyms::XK_PERIOD, |
| 157 | - KeyData::Slash => keycodes::SLASH, | 163 | + KeyData::Slash => keysyms::XK_SLASH, |
| 164 | + KeyData::AudioRaiseVolume => keysyms::XF86_AUDIO_RAISE_VOLUME, | ||
| 165 | + KeyData::AudioLowerVolume => keysyms::XF86_AUDIO_LOWER_VOLUME, | ||
| 166 | + KeyData::AudioMute => keysyms::XF86_AUDIO_MUTE, | ||
| 167 | + KeyData::MonBrightnessUp => keysyms::XF86_MON_BRIGHTNESS_UP, | ||
| 168 | + KeyData::MonBrightnessDown => keysyms::XF86_MON_BRIGHTNESS_DOWN, | ||
| 158 | } | 169 | } |
| 159 | } | 170 | } |
| 160 | 171 | ||
| 161 | - // Adding this reverse lookup for now so converting to KeySyms is no longer | ||
| 162 | - // an 'unsafe' call to a C FFI (Sorry Bugsy...) | ||
| 163 | - // This will set us up in the future to move away from hardcoded keycodes, | ||
| 164 | - // and directly convert keysyms to keydata at runtime for international | ||
| 165 | - // keyboard support. | ||
| 166 | - pub fn from_keycode(keycode: Keycode) -> Option<&'static str> { | ||
| 167 | - match keycode { | ||
| 168 | - keycodes::RETURN => Some("Return"), | ||
| 169 | - keycodes::Q => Some("q"), | ||
| 170 | - keycodes::ESCAPE => Some("Esc"), | ||
| 171 | - keycodes::SPACE => Some("Space"), | ||
| 172 | - keycodes::TAB => Some("Tab"), | ||
| 173 | - keycodes::BACKSPACE => Some("Backspace"), | ||
| 174 | - keycodes::DELETE => Some("Del"), | ||
| 175 | - keycodes::F1 => Some("F1"), | ||
| 176 | - keycodes::F2 => Some("F2"), | ||
| 177 | - keycodes::F3 => Some("F3"), | ||
| 178 | - keycodes::F4 => Some("F4"), | ||
| 179 | - keycodes::F5 => Some("F5"), | ||
| 180 | - keycodes::F6 => Some("F6"), | ||
| 181 | - keycodes::F7 => Some("F7"), | ||
| 182 | - keycodes::F8 => Some("F8"), | ||
| 183 | - keycodes::F9 => Some("F9"), | ||
| 184 | - keycodes::F10 => Some("F10"), | ||
| 185 | - keycodes::F11 => Some("F11"), | ||
| 186 | - keycodes::F12 => Some("F12"), | ||
| 187 | - keycodes::A => Some("a"), | ||
| 188 | - keycodes::B => Some("b"), | ||
| 189 | - keycodes::C => Some("c"), | ||
| 190 | - keycodes::D => Some("d"), | ||
| 191 | - keycodes::E => Some("e"), | ||
| 192 | - keycodes::F => Some("f"), | ||
| 193 | - keycodes::G => Some("g"), | ||
| 194 | - keycodes::H => Some("h"), | ||
| 195 | - keycodes::I => Some("i"), | ||
| 196 | - keycodes::J => Some("j"), | ||
| 197 | - keycodes::K => Some("k"), | ||
| 198 | - keycodes::L => Some("l"), | ||
| 199 | - keycodes::M => Some("m"), | ||
| 200 | - keycodes::N => Some("n"), | ||
| 201 | - keycodes::O => Some("o"), | ||
| 202 | - keycodes::P => Some("p"), | ||
| 203 | - keycodes::R => Some("r"), | ||
| 204 | - keycodes::S => Some("s"), | ||
| 205 | - keycodes::T => Some("t"), | ||
| 206 | - keycodes::U => Some("u"), | ||
| 207 | - keycodes::V => Some("v"), | ||
| 208 | - keycodes::W => Some("w"), | ||
| 209 | - keycodes::X => Some("x"), | ||
| 210 | - keycodes::Y => Some("y"), | ||
| 211 | - keycodes::Z => Some("z"), | ||
| 212 | - keycodes::KEY_0 => Some("0"), | ||
| 213 | - keycodes::KEY_1 => Some("1"), | ||
| 214 | - keycodes::KEY_2 => Some("2"), | ||
| 215 | - keycodes::KEY_3 => Some("3"), | ||
| 216 | - keycodes::KEY_4 => Some("4"), | ||
| 217 | - keycodes::KEY_5 => Some("5"), | ||
| 218 | - keycodes::KEY_6 => Some("6"), | ||
| 219 | - keycodes::KEY_7 => Some("7"), | ||
| 220 | - keycodes::KEY_8 => Some("8"), | ||
| 221 | - keycodes::KEY_9 => Some("9"), | ||
| 222 | - keycodes::LEFT => Some("Left"), | ||
| 223 | - keycodes::RIGHT => Some("Right"), | ||
| 224 | - keycodes::UP => Some("Up"), | ||
| 225 | - keycodes::DOWN => Some("Down"), | ||
| 226 | - keycodes::HOME => Some("Home"), | ||
| 227 | - keycodes::END => Some("End"), | ||
| 228 | - keycodes::PAGE_UP => Some("PgUp"), | ||
| 229 | - keycodes::PAGE_DOWN => Some("PgDn"), | ||
| 230 | - keycodes::INSERT => Some("Ins"), | ||
| 231 | - keycodes::MINUS => Some("-"), | ||
| 232 | - keycodes::EQUAL => Some("="), | ||
| 233 | - keycodes::LEFT_BRACKET => Some("["), | ||
| 234 | - keycodes::RIGHT_BRACKET => Some("]"), | ||
| 235 | - keycodes::SEMICOLON => Some(";"), | ||
| 236 | - keycodes::APOSTROPHE => Some("'"), | ||
| 237 | - keycodes::GRAVE => Some("`"), | ||
| 238 | - keycodes::BACKSLASH => Some("\\"), | ||
| 239 | - keycodes::COMMA => Some(","), | ||
| 240 | - keycodes::PERIOD => Some("."), | ||
| 241 | - keycodes::SLASH => Some("/"), | ||
| 242 | - _ => None, | ||
| 243 | - } | ||
| 244 | - } | ||
| 245 | } | 172 | } |
| 246 | 173 | ||
| 247 | fn preprocess_variables(input: &str) -> Result<String, ConfigError> { | 174 | fn preprocess_variables(input: &str) -> Result<String, ConfigError> { |
| @@ -412,7 +339,7 @@ fn config_data_to_config(data: ConfigData) -> Result<crate::Config, ConfigError> | |||
| 412 | 339 | ||
| 413 | KeyPress { | 340 | KeyPress { |
| 414 | modifiers, | 341 | modifiers, |
| 415 | - key: kp.key.to_keycode(), | 342 | + keysym: kp.key.to_keysym(), |
| 416 | } | 343 | } |
| 417 | }) | 344 | }) |
| 418 | .collect() | 345 | .collect() |
| @@ -425,7 +352,7 @@ fn config_data_to_config(data: ConfigData) -> Result<crate::Config, ConfigError> | |||
| 425 | _ => m.to_keybut_mask(), | 352 | _ => m.to_keybut_mask(), |
| 426 | }) | 353 | }) |
| 427 | .collect(), | 354 | .collect(), |
| 428 | - key: key.to_keycode(), | 355 | + keysym: key.to_keysym(), |
| 429 | }] | 356 | }] |
| 430 | } else { | 357 | } else { |
| 431 | return Err(ConfigError::ValidationError( | 358 | return Err(ConfigError::ValidationError( |
+86 −40 src/keyboard/handlers.rs
| @@ -1,6 +1,5 @@ | |||
| 1 | -use std::collections::HashSet; | 1 | +use std::collections::HashMap; |
| 2 | -use std::io; | 2 | +use std::io::{ErrorKind, Result}; |
| 3 | -use std::io::ErrorKind; | ||
| 4 | use std::process::Command; | 3 | use std::process::Command; |
| 5 | 4 | ||
| 6 | use serde::Deserialize; | 5 | use serde::Deserialize; |
| @@ -8,7 +7,7 @@ use x11rb::connection::Connection; | |||
| 8 | use x11rb::protocol::xproto::*; | 7 | use x11rb::protocol::xproto::*; |
| 9 | 8 | ||
| 10 | use crate::errors::X11Error; | 9 | use crate::errors::X11Error; |
| 11 | -use crate::keyboard::keycodes; | 10 | +use crate::keyboard::keysyms::{self, Keysym}; |
| 12 | 11 | ||
| 13 | #[derive(Debug, Copy, Clone, Deserialize)] | 12 | #[derive(Debug, Copy, Clone, Deserialize)] |
| 14 | pub enum KeyAction { | 13 | pub enum KeyAction { |
| @@ -48,7 +47,7 @@ impl Arg { | |||
| 48 | #[derive(Clone, Debug)] | 47 | #[derive(Clone, Debug)] |
| 49 | pub struct KeyPress { | 48 | pub struct KeyPress { |
| 50 | pub(crate) modifiers: Vec<KeyButMask>, | 49 | pub(crate) modifiers: Vec<KeyButMask>, |
| 51 | - pub(crate) key: Keycode, | 50 | + pub(crate) keysym: Keysym, |
| 52 | } | 51 | } |
| 53 | 52 | ||
| 54 | #[derive(Clone)] | 53 | #[derive(Clone)] |
| @@ -63,9 +62,14 @@ impl KeyBinding { | |||
| 63 | Self { keys, func, arg } | 62 | Self { keys, func, arg } |
| 64 | } | 63 | } |
| 65 | 64 | ||
| 66 | - pub fn single_key(modifiers: Vec<KeyButMask>, key: Keycode, func: KeyAction, arg: Arg) -> Self { | 65 | + pub fn single_key( |
| 66 | + modifiers: Vec<KeyButMask>, | ||
| 67 | + keysym: Keysym, | ||
| 68 | + func: KeyAction, | ||
| 69 | + arg: Arg, | ||
| 70 | + ) -> Self { | ||
| 67 | Self { | 71 | Self { |
| 68 | - keys: vec![KeyPress { modifiers, key }], | 72 | + keys: vec![KeyPress { modifiers, keysym }], |
| 69 | func, | 73 | func, |
| 70 | arg, | 74 | arg, |
| 71 | } | 75 | } |
| @@ -96,11 +100,48 @@ pub fn modifiers_to_mask(modifiers: &[KeyButMask]) -> u16 { | |||
| 96 | .fold(0u16, |acc, &modifier| acc | u16::from(modifier)) | 100 | .fold(0u16, |acc, &modifier| acc | u16::from(modifier)) |
| 97 | } | 101 | } |
| 98 | 102 | ||
| 103 | +fn build_keysym_maps( | ||
| 104 | + connection: &impl Connection, | ||
| 105 | +) -> std::result::Result<(HashMap<Keysym, Vec<Keycode>>, HashMap<Keycode, Keysym>), X11Error> { | ||
| 106 | + let setup = connection.setup(); | ||
| 107 | + let min_keycode = setup.min_keycode; | ||
| 108 | + let max_keycode = setup.max_keycode; | ||
| 109 | + | ||
| 110 | + let keyboard_mapping = connection | ||
| 111 | + .get_keyboard_mapping(min_keycode, max_keycode - min_keycode + 1)? | ||
| 112 | + .reply()?; | ||
| 113 | + | ||
| 114 | + let mut keysym_to_keycode: HashMap<Keysym, Vec<Keycode>> = HashMap::new(); | ||
| 115 | + let mut keycode_to_keysym: HashMap<Keycode, Keysym> = HashMap::new(); | ||
| 116 | + let keysyms_per_keycode = keyboard_mapping.keysyms_per_keycode; | ||
| 117 | + | ||
| 118 | + for keycode in min_keycode..=max_keycode { | ||
| 119 | + let index = (keycode - min_keycode) as usize * keysyms_per_keycode as usize; | ||
| 120 | + | ||
| 121 | + for i in 0..keysyms_per_keycode as usize { | ||
| 122 | + if let Some(&keysym) = keyboard_mapping.keysyms.get(index + i) { | ||
| 123 | + if keysym != 0 { | ||
| 124 | + keysym_to_keycode | ||
| 125 | + .entry(keysym) | ||
| 126 | + .or_insert_with(Vec::new) | ||
| 127 | + .push(keycode); | ||
| 128 | + keycode_to_keysym.entry(keycode).or_insert(keysym); | ||
| 129 | + } | ||
| 130 | + } | ||
| 131 | + } | ||
| 132 | + } | ||
| 133 | + | ||
| 134 | + Ok((keysym_to_keycode, keycode_to_keysym)) | ||
| 135 | +} | ||
| 136 | + | ||
| 99 | pub fn setup_keybinds( | 137 | pub fn setup_keybinds( |
| 100 | connection: &impl Connection, | 138 | connection: &impl Connection, |
| 101 | root: Window, | 139 | root: Window, |
| 102 | keybindings: &[KeyBinding], | 140 | keybindings: &[KeyBinding], |
| 103 | -) -> Result<(), X11Error> { | 141 | +) -> std::result::Result<(), X11Error> { |
| 142 | + use std::collections::HashSet; | ||
| 143 | + | ||
| 144 | + let (keysym_to_keycode, _) = build_keysym_maps(connection)?; | ||
| 104 | let mut grabbed_keys: HashSet<(u16, Keycode)> = HashSet::new(); | 145 | let mut grabbed_keys: HashSet<(u16, Keycode)> = HashSet::new(); |
| 105 | 146 | ||
| 106 | for keybinding in keybindings { | 147 | for keybinding in keybindings { |
| @@ -110,29 +151,25 @@ pub fn setup_keybinds( | |||
| 110 | 151 | ||
| 111 | let first_key = &keybinding.keys[0]; | 152 | let first_key = &keybinding.keys[0]; |
| 112 | let modifier_mask = modifiers_to_mask(&first_key.modifiers); | 153 | let modifier_mask = modifiers_to_mask(&first_key.modifiers); |
| 113 | - let key_tuple = (modifier_mask, first_key.key); | 154 | + |
| 114 | - | 155 | + if let Some(keycodes) = keysym_to_keycode.get(&first_key.keysym) { |
| 115 | - if grabbed_keys.insert(key_tuple) { | 156 | + if let Some(&keycode) = keycodes.first() { |
| 116 | - connection.grab_key( | 157 | + let key_tuple = (modifier_mask, keycode); |
| 117 | - false, | 158 | + |
| 118 | - root, | 159 | + if grabbed_keys.insert(key_tuple) { |
| 119 | - modifier_mask.into(), | 160 | + connection.grab_key( |
| 120 | - first_key.key, | 161 | + false, |
| 121 | - GrabMode::ASYNC, | 162 | + root, |
| 122 | - GrabMode::ASYNC, | 163 | + modifier_mask.into(), |
| 123 | - )?; | 164 | + keycode, |
| 165 | + GrabMode::ASYNC, | ||
| 166 | + GrabMode::ASYNC, | ||
| 167 | + )?; | ||
| 168 | + } | ||
| 169 | + } | ||
| 124 | } | 170 | } |
| 125 | } | 171 | } |
| 126 | 172 | ||
| 127 | - connection.grab_key( | ||
| 128 | - false, | ||
| 129 | - root, | ||
| 130 | - ModMask::from(0u16), | ||
| 131 | - keycodes::ESCAPE, | ||
| 132 | - GrabMode::ASYNC, | ||
| 133 | - GrabMode::ASYNC, | ||
| 134 | - )?; | ||
| 135 | - | ||
| 136 | Ok(()) | 173 | Ok(()) |
| 137 | } | 174 | } |
| 138 | 175 | ||
| @@ -140,24 +177,32 @@ pub fn handle_key_press( | |||
| 140 | event: KeyPressEvent, | 177 | event: KeyPressEvent, |
| 141 | keybindings: &[KeyBinding], | 178 | keybindings: &[KeyBinding], |
| 142 | keychord_state: &KeychordState, | 179 | keychord_state: &KeychordState, |
| 143 | -) -> KeychordResult { | 180 | + connection: &impl Connection, |
| 144 | - if event.detail == keycodes::ESCAPE { | 181 | +) -> std::result::Result<KeychordResult, X11Error> { |
| 145 | - return match keychord_state { | 182 | + let (_, keycode_to_keysym) = build_keysym_maps(connection)?; |
| 183 | + let event_keysym = keycode_to_keysym.get(&event.detail).copied().unwrap_or(0); | ||
| 184 | + | ||
| 185 | + if event_keysym == keysyms::XK_ESCAPE { | ||
| 186 | + return Ok(match keychord_state { | ||
| 146 | KeychordState::InProgress { .. } => KeychordResult::Cancelled, | 187 | KeychordState::InProgress { .. } => KeychordResult::Cancelled, |
| 147 | KeychordState::Idle => KeychordResult::None, | 188 | KeychordState::Idle => KeychordResult::None, |
| 148 | - }; | 189 | + }); |
| 149 | } | 190 | } |
| 150 | 191 | ||
| 151 | - match keychord_state { | 192 | + Ok(match keychord_state { |
| 152 | - KeychordState::Idle => handle_first_key(event, keybindings), | 193 | + KeychordState::Idle => handle_first_key(event, event_keysym, keybindings), |
| 153 | KeychordState::InProgress { | 194 | KeychordState::InProgress { |
| 154 | candidates, | 195 | candidates, |
| 155 | keys_pressed, | 196 | keys_pressed, |
| 156 | - } => handle_next_key(event, keybindings, candidates, *keys_pressed), | 197 | + } => handle_next_key(event, event_keysym, keybindings, candidates, *keys_pressed), |
| 157 | - } | 198 | + }) |
| 158 | } | 199 | } |
| 159 | 200 | ||
| 160 | -fn handle_first_key(event: KeyPressEvent, keybindings: &[KeyBinding]) -> KeychordResult { | 201 | +fn handle_first_key( |
| 202 | + event: KeyPressEvent, | ||
| 203 | + event_keysym: Keysym, | ||
| 204 | + keybindings: &[KeyBinding], | ||
| 205 | +) -> KeychordResult { | ||
| 161 | let mut candidates = Vec::new(); | 206 | let mut candidates = Vec::new(); |
| 162 | 207 | ||
| 163 | for (keybinding_index, keybinding) in keybindings.iter().enumerate() { | 208 | for (keybinding_index, keybinding) in keybindings.iter().enumerate() { |
| @@ -168,7 +213,7 @@ fn handle_first_key(event: KeyPressEvent, keybindings: &[KeyBinding]) -> Keychor | |||
| 168 | let first_key = &keybinding.keys[0]; | 213 | let first_key = &keybinding.keys[0]; |
| 169 | let modifier_mask = modifiers_to_mask(&first_key.modifiers); | 214 | let modifier_mask = modifiers_to_mask(&first_key.modifiers); |
| 170 | 215 | ||
| 171 | - if event.detail == first_key.key && event.state == modifier_mask.into() { | 216 | + if event_keysym == first_key.keysym && event.state == modifier_mask.into() { |
| 172 | if keybinding.keys.len() == 1 { | 217 | if keybinding.keys.len() == 1 { |
| 173 | return KeychordResult::Completed(keybinding.func, keybinding.arg.clone()); | 218 | return KeychordResult::Completed(keybinding.func, keybinding.arg.clone()); |
| 174 | } else { | 219 | } else { |
| @@ -186,6 +231,7 @@ fn handle_first_key(event: KeyPressEvent, keybindings: &[KeyBinding]) -> Keychor | |||
| 186 | 231 | ||
| 187 | fn handle_next_key( | 232 | fn handle_next_key( |
| 188 | event: KeyPressEvent, | 233 | event: KeyPressEvent, |
| 234 | + event_keysym: Keysym, | ||
| 189 | keybindings: &[KeyBinding], | 235 | keybindings: &[KeyBinding], |
| 190 | candidates: &[usize], | 236 | candidates: &[usize], |
| 191 | keys_pressed: usize, | 237 | keys_pressed: usize, |
| @@ -209,7 +255,7 @@ fn handle_next_key( | |||
| 209 | (event_state & required_mask) == required_mask | 255 | (event_state & required_mask) == required_mask |
| 210 | }; | 256 | }; |
| 211 | 257 | ||
| 212 | - if event.detail == next_key.key && modifiers_match { | 258 | + if event_keysym == next_key.keysym && modifiers_match { |
| 213 | if keys_pressed + 1 == keybinding.keys.len() { | 259 | if keys_pressed + 1 == keybinding.keys.len() { |
| 214 | return KeychordResult::Completed(keybinding.func, keybinding.arg.clone()); | 260 | return KeychordResult::Completed(keybinding.func, keybinding.arg.clone()); |
| 215 | } else { | 261 | } else { |
| @@ -225,7 +271,7 @@ fn handle_next_key( | |||
| 225 | } | 271 | } |
| 226 | } | 272 | } |
| 227 | 273 | ||
| 228 | -pub fn handle_spawn_action(action: KeyAction, arg: &Arg) -> io::Result<()> { | 274 | +pub fn handle_spawn_action(action: KeyAction, arg: &Arg) -> Result<()> { |
| 229 | if let KeyAction::Spawn = action { | 275 | if let KeyAction::Spawn = action { |
| 230 | match arg { | 276 | match arg { |
| 231 | Arg::Str(command) => match Command::new(command.as_str()).spawn() { | 277 | Arg::Str(command) => match Command::new(command.as_str()).spawn() { |
+0 −86 src/keyboard/keycodes.rs deleted file mode 100644
| @@ -1,86 +0,0 @@ | |||
| 1 | -#![allow(dead_code)] | ||
| 2 | -// Allowing dead code here because its just a file for potential keybinds | ||
| 3 | -pub const RETURN: u8 = 36; | ||
| 4 | -pub const Q: u8 = 24; | ||
| 5 | -pub const ESCAPE: u8 = 9; | ||
| 6 | -pub const SPACE: u8 = 65; | ||
| 7 | -pub const TAB: u8 = 23; | ||
| 8 | -pub const BACKSPACE: u8 = 22; | ||
| 9 | -pub const DELETE: u8 = 119; | ||
| 10 | - | ||
| 11 | -// Function Keys | ||
| 12 | -pub const F1: u8 = 67; | ||
| 13 | -pub const F2: u8 = 68; | ||
| 14 | -pub const F3: u8 = 69; | ||
| 15 | -pub const F4: u8 = 70; | ||
| 16 | -pub const F5: u8 = 71; | ||
| 17 | -pub const F6: u8 = 72; | ||
| 18 | -pub const F7: u8 = 73; | ||
| 19 | -pub const F8: u8 = 74; | ||
| 20 | -pub const F9: u8 = 75; | ||
| 21 | -pub const F10: u8 = 76; | ||
| 22 | -pub const F11: u8 = 95; | ||
| 23 | -pub const F12: u8 = 96; | ||
| 24 | - | ||
| 25 | -// Letters | ||
| 26 | -pub const A: u8 = 38; | ||
| 27 | -pub const B: u8 = 56; | ||
| 28 | -pub const C: u8 = 54; | ||
| 29 | -pub const D: u8 = 40; | ||
| 30 | -pub const E: u8 = 26; | ||
| 31 | -pub const F: u8 = 41; | ||
| 32 | -pub const G: u8 = 42; | ||
| 33 | -pub const H: u8 = 43; | ||
| 34 | -pub const I: u8 = 31; | ||
| 35 | -pub const J: u8 = 44; | ||
| 36 | -pub const K: u8 = 45; | ||
| 37 | -pub const L: u8 = 46; | ||
| 38 | -pub const M: u8 = 58; | ||
| 39 | -pub const N: u8 = 57; | ||
| 40 | -pub const O: u8 = 32; | ||
| 41 | -pub const P: u8 = 33; | ||
| 42 | -pub const R: u8 = 27; | ||
| 43 | -pub const S: u8 = 39; | ||
| 44 | -pub const T: u8 = 28; | ||
| 45 | -pub const U: u8 = 30; | ||
| 46 | -pub const V: u8 = 55; | ||
| 47 | -pub const W: u8 = 25; | ||
| 48 | -pub const X: u8 = 53; | ||
| 49 | -pub const Y: u8 = 29; | ||
| 50 | -pub const Z: u8 = 52; | ||
| 51 | - | ||
| 52 | -// Numbers | ||
| 53 | -pub const KEY_0: u8 = 19; | ||
| 54 | -pub const KEY_1: u8 = 10; | ||
| 55 | -pub const KEY_2: u8 = 11; | ||
| 56 | -pub const KEY_3: u8 = 12; | ||
| 57 | -pub const KEY_4: u8 = 13; | ||
| 58 | -pub const KEY_5: u8 = 14; | ||
| 59 | -pub const KEY_6: u8 = 15; | ||
| 60 | -pub const KEY_7: u8 = 16; | ||
| 61 | -pub const KEY_8: u8 = 17; | ||
| 62 | -pub const KEY_9: u8 = 18; | ||
| 63 | - | ||
| 64 | -// Arrows | ||
| 65 | -pub const LEFT: u8 = 113; | ||
| 66 | -pub const RIGHT: u8 = 114; | ||
| 67 | -pub const UP: u8 = 111; | ||
| 68 | -pub const DOWN: u8 = 116; | ||
| 69 | -pub const HOME: u8 = 110; | ||
| 70 | -pub const END: u8 = 115; | ||
| 71 | -pub const PAGE_UP: u8 = 112; | ||
| 72 | -pub const PAGE_DOWN: u8 = 117; | ||
| 73 | -pub const INSERT: u8 = 118; | ||
| 74 | - | ||
| 75 | -// Symbols | ||
| 76 | -pub const MINUS: u8 = 20; | ||
| 77 | -pub const EQUAL: u8 = 21; | ||
| 78 | -pub const LEFT_BRACKET: u8 = 34; | ||
| 79 | -pub const RIGHT_BRACKET: u8 = 35; | ||
| 80 | -pub const SEMICOLON: u8 = 47; | ||
| 81 | -pub const APOSTROPHE: u8 = 48; | ||
| 82 | -pub const GRAVE: u8 = 49; | ||
| 83 | -pub const BACKSLASH: u8 = 51; | ||
| 84 | -pub const COMMA: u8 = 59; | ||
| 85 | -pub const PERIOD: u8 = 60; | ||
| 86 | -pub const SLASH: u8 = 61; | ||
+84 −0 src/keyboard/keysyms.rs new file mode 100644
| @@ -0,0 +1,84 @@ | |||
| 1 | +#![allow(dead_code)] | ||
| 2 | + | ||
| 3 | +pub type Keysym = u32; | ||
| 4 | +pub const XK_ESCAPE: Keysym = 0xff1b; | ||
| 5 | +pub const XK_RETURN: Keysym = 0xff0d; | ||
| 6 | +pub const XK_SPACE: Keysym = 0x0020; | ||
| 7 | +pub const XK_TAB: Keysym = 0xff09; | ||
| 8 | +pub const XK_BACKSPACE: Keysym = 0xff08; | ||
| 9 | +pub const XK_DELETE: Keysym = 0xffff; | ||
| 10 | +pub const XK_F1: Keysym = 0xffbe; | ||
| 11 | +pub const XK_F2: Keysym = 0xffbf; | ||
| 12 | +pub const XK_F3: Keysym = 0xffc0; | ||
| 13 | +pub const XK_F4: Keysym = 0xffc1; | ||
| 14 | +pub const XK_F5: Keysym = 0xffc2; | ||
| 15 | +pub const XK_F6: Keysym = 0xffc3; | ||
| 16 | +pub const XK_F7: Keysym = 0xffc4; | ||
| 17 | +pub const XK_F8: Keysym = 0xffc5; | ||
| 18 | +pub const XK_F9: Keysym = 0xffc6; | ||
| 19 | +pub const XK_F10: Keysym = 0xffc7; | ||
| 20 | +pub const XK_F11: Keysym = 0xffc8; | ||
| 21 | +pub const XK_F12: Keysym = 0xffc9; | ||
| 22 | +pub const XK_A: Keysym = 0x0061; | ||
| 23 | +pub const XK_B: Keysym = 0x0062; | ||
| 24 | +pub const XK_C: Keysym = 0x0063; | ||
| 25 | +pub const XK_D: Keysym = 0x0064; | ||
| 26 | +pub const XK_E: Keysym = 0x0065; | ||
| 27 | +pub const XK_F: Keysym = 0x0066; | ||
| 28 | +pub const XK_G: Keysym = 0x0067; | ||
| 29 | +pub const XK_H: Keysym = 0x0068; | ||
| 30 | +pub const XK_I: Keysym = 0x0069; | ||
| 31 | +pub const XK_J: Keysym = 0x006a; | ||
| 32 | +pub const XK_K: Keysym = 0x006b; | ||
| 33 | +pub const XK_L: Keysym = 0x006c; | ||
| 34 | +pub const XK_M: Keysym = 0x006d; | ||
| 35 | +pub const XK_N: Keysym = 0x006e; | ||
| 36 | +pub const XK_O: Keysym = 0x006f; | ||
| 37 | +pub const XK_P: Keysym = 0x0070; | ||
| 38 | +pub const XK_Q: Keysym = 0x0071; | ||
| 39 | +pub const XK_R: Keysym = 0x0072; | ||
| 40 | +pub const XK_S: Keysym = 0x0073; | ||
| 41 | +pub const XK_T: Keysym = 0x0074; | ||
| 42 | +pub const XK_U: Keysym = 0x0075; | ||
| 43 | +pub const XK_V: Keysym = 0x0076; | ||
| 44 | +pub const XK_W: Keysym = 0x0077; | ||
| 45 | +pub const XK_X: Keysym = 0x0078; | ||
| 46 | +pub const XK_Y: Keysym = 0x0079; | ||
| 47 | +pub const XK_Z: Keysym = 0x007a; | ||
| 48 | +pub const XK_0: Keysym = 0x0030; | ||
| 49 | +pub const XK_1: Keysym = 0x0031; | ||
| 50 | +pub const XK_2: Keysym = 0x0032; | ||
| 51 | +pub const XK_3: Keysym = 0x0033; | ||
| 52 | +pub const XK_4: Keysym = 0x0034; | ||
| 53 | +pub const XK_5: Keysym = 0x0035; | ||
| 54 | +pub const XK_6: Keysym = 0x0036; | ||
| 55 | +pub const XK_7: Keysym = 0x0037; | ||
| 56 | +pub const XK_8: Keysym = 0x0038; | ||
| 57 | +pub const XK_9: Keysym = 0x0039; | ||
| 58 | +pub const XK_LEFT: Keysym = 0xff51; | ||
| 59 | +pub const XK_UP: Keysym = 0xff52; | ||
| 60 | +pub const XK_RIGHT: Keysym = 0xff53; | ||
| 61 | +pub const XK_DOWN: Keysym = 0xff54; | ||
| 62 | +pub const XK_HOME: Keysym = 0xff50; | ||
| 63 | +pub const XK_END: Keysym = 0xff57; | ||
| 64 | +pub const XK_PAGE_UP: Keysym = 0xff55; | ||
| 65 | +pub const XK_PAGE_DOWN: Keysym = 0xff56; | ||
| 66 | +pub const XK_INSERT: Keysym = 0xff63; | ||
| 67 | +pub const XK_MINUS: Keysym = 0x002d; | ||
| 68 | +pub const XK_EQUAL: Keysym = 0x003d; | ||
| 69 | +pub const XK_LEFT_BRACKET: Keysym = 0x005b; | ||
| 70 | +pub const XK_RIGHT_BRACKET: Keysym = 0x005d; | ||
| 71 | +pub const XK_SEMICOLON: Keysym = 0x003b; | ||
| 72 | +pub const XK_APOSTROPHE: Keysym = 0x0027; | ||
| 73 | +pub const XK_GRAVE: Keysym = 0x0060; | ||
| 74 | +pub const XK_BACKSLASH: Keysym = 0x005c; | ||
| 75 | +pub const XK_COMMA: Keysym = 0x002c; | ||
| 76 | +pub const XK_PERIOD: Keysym = 0x002e; | ||
| 77 | +pub const XK_SLASH: Keysym = 0x002f; | ||
| 78 | +pub const XK_PRINT: Keysym = 0xff61; | ||
| 79 | + | ||
| 80 | +pub const XF86_AUDIO_RAISE_VOLUME: Keysym = 0x1008ff13; | ||
| 81 | +pub const XF86_AUDIO_LOWER_VOLUME: Keysym = 0x1008ff11; | ||
| 82 | +pub const XF86_AUDIO_MUTE: Keysym = 0x1008ff12; | ||
| 83 | +pub const XF86_MON_BRIGHTNESS_UP: Keysym = 0x1008ff02; | ||
| 84 | +pub const XF86_MON_BRIGHTNESS_DOWN: Keysym = 0x1008ff03; | ||
+2 −2 src/keyboard/mod.rs
| @@ -1,5 +1,5 @@ | |||
| 1 | pub mod handlers; | 1 | pub mod handlers; |
| 2 | -pub mod keycodes; | 2 | +pub mod keysyms; |
| 3 | 3 | ||
| 4 | pub use handlers::{Arg, KeyAction, handle_key_press, setup_keybinds}; | 4 | pub use handlers::{Arg, KeyAction, handle_key_press, setup_keybinds}; |
| 5 | -pub use keycodes::*; | 5 | +pub use keysyms::*; |
+35 −35 src/lib.rs
| @@ -10,7 +10,7 @@ pub mod prelude { | |||
| 10 | pub use crate::ColorScheme; | 10 | pub use crate::ColorScheme; |
| 11 | pub use crate::LayoutSymbolOverride; | 11 | pub use crate::LayoutSymbolOverride; |
| 12 | pub use crate::bar::{BlockCommand, BlockConfig}; | 12 | pub use crate::bar::{BlockCommand, BlockConfig}; |
| 13 | - pub use crate::keyboard::{Arg, KeyAction, handlers::KeyBinding, keycodes}; | 13 | + pub use crate::keyboard::{Arg, KeyAction, handlers::KeyBinding, keysyms}; |
| 14 | pub use x11rb::protocol::xproto::KeyButMask; | 14 | pub use x11rb::protocol::xproto::KeyButMask; |
| 15 | } | 15 | } |
| 16 | 16 | ||
| @@ -67,7 +67,7 @@ pub struct ColorScheme { | |||
| 67 | impl Default for Config { | 67 | impl Default for Config { |
| 68 | fn default() -> Self { | 68 | fn default() -> Self { |
| 69 | use crate::keyboard::handlers::KeyBinding; | 69 | use crate::keyboard::handlers::KeyBinding; |
| 70 | - use crate::keyboard::{Arg, KeyAction, keycodes}; | 70 | + use crate::keyboard::{Arg, KeyAction, keysyms}; |
| 71 | use x11rb::protocol::xproto::KeyButMask; | 71 | use x11rb::protocol::xproto::KeyButMask; |
| 72 | 72 | ||
| 73 | const MODKEY: KeyButMask = KeyButMask::MOD4; | 73 | const MODKEY: KeyButMask = KeyButMask::MOD4; |
| @@ -95,13 +95,13 @@ impl Default for Config { | |||
| 95 | keybindings: vec![ | 95 | keybindings: vec![ |
| 96 | KeyBinding::single_key( | 96 | KeyBinding::single_key( |
| 97 | vec![MODKEY], | 97 | vec![MODKEY], |
| 98 | - keycodes::RETURN, | 98 | + keysyms::XK_RETURN, |
| 99 | KeyAction::Spawn, | 99 | KeyAction::Spawn, |
| 100 | Arg::Str(TERMINAL.to_string()), | 100 | Arg::Str(TERMINAL.to_string()), |
| 101 | ), | 101 | ), |
| 102 | KeyBinding::single_key( | 102 | KeyBinding::single_key( |
| 103 | vec![MODKEY], | 103 | vec![MODKEY], |
| 104 | - keycodes::D, | 104 | + keysyms::XK_D, |
| 105 | KeyAction::Spawn, | 105 | KeyAction::Spawn, |
| 106 | Arg::Array(vec![ | 106 | Arg::Array(vec![ |
| 107 | "sh".to_string(), | 107 | "sh".to_string(), |
| @@ -109,169 +109,169 @@ impl Default for Config { | |||
| 109 | "dmenu_run -l 10".to_string(), | 109 | "dmenu_run -l 10".to_string(), |
| 110 | ]), | 110 | ]), |
| 111 | ), | 111 | ), |
| 112 | - KeyBinding::single_key(vec![MODKEY], keycodes::Q, KeyAction::KillClient, Arg::None), | 112 | + KeyBinding::single_key(vec![MODKEY], keysyms::XK_Q, KeyAction::KillClient, Arg::None), |
| 113 | - KeyBinding::single_key(vec![MODKEY], keycodes::N, KeyAction::CycleLayout, Arg::None), | 113 | + KeyBinding::single_key(vec![MODKEY], keysyms::XK_N, KeyAction::CycleLayout, Arg::None), |
| 114 | KeyBinding::single_key( | 114 | KeyBinding::single_key( |
| 115 | vec![MODKEY, SHIFT], | 115 | vec![MODKEY, SHIFT], |
| 116 | - keycodes::F, | 116 | + keysyms::XK_F, |
| 117 | KeyAction::ToggleFullScreen, | 117 | KeyAction::ToggleFullScreen, |
| 118 | Arg::None, | 118 | Arg::None, |
| 119 | ), | 119 | ), |
| 120 | - KeyBinding::single_key(vec![MODKEY], keycodes::A, KeyAction::ToggleGaps, Arg::None), | 120 | + KeyBinding::single_key(vec![MODKEY], keysyms::XK_A, KeyAction::ToggleGaps, Arg::None), |
| 121 | - KeyBinding::single_key(vec![MODKEY, SHIFT], keycodes::Q, KeyAction::Quit, Arg::None), | 121 | + KeyBinding::single_key(vec![MODKEY, SHIFT], keysyms::XK_Q, KeyAction::Quit, Arg::None), |
| 122 | KeyBinding::single_key( | 122 | KeyBinding::single_key( |
| 123 | vec![MODKEY, SHIFT], | 123 | vec![MODKEY, SHIFT], |
| 124 | - keycodes::R, | 124 | + keysyms::XK_R, |
| 125 | KeyAction::Restart, | 125 | KeyAction::Restart, |
| 126 | Arg::None, | 126 | Arg::None, |
| 127 | ), | 127 | ), |
| 128 | KeyBinding::single_key( | 128 | KeyBinding::single_key( |
| 129 | vec![MODKEY], | 129 | vec![MODKEY], |
| 130 | - keycodes::F, | 130 | + keysyms::XK_F, |
| 131 | KeyAction::ToggleFloating, | 131 | KeyAction::ToggleFloating, |
| 132 | Arg::None, | 132 | Arg::None, |
| 133 | ), | 133 | ), |
| 134 | KeyBinding::single_key( | 134 | KeyBinding::single_key( |
| 135 | vec![MODKEY], | 135 | vec![MODKEY], |
| 136 | - keycodes::J, | 136 | + keysyms::XK_J, |
| 137 | KeyAction::FocusStack, | 137 | KeyAction::FocusStack, |
| 138 | Arg::Int(-1), | 138 | Arg::Int(-1), |
| 139 | ), | 139 | ), |
| 140 | KeyBinding::single_key( | 140 | KeyBinding::single_key( |
| 141 | vec![MODKEY], | 141 | vec![MODKEY], |
| 142 | - keycodes::K, | 142 | + keysyms::XK_K, |
| 143 | KeyAction::FocusStack, | 143 | KeyAction::FocusStack, |
| 144 | Arg::Int(1), | 144 | Arg::Int(1), |
| 145 | ), | 145 | ), |
| 146 | KeyBinding::single_key( | 146 | KeyBinding::single_key( |
| 147 | vec![MODKEY, SHIFT], | 147 | vec![MODKEY, SHIFT], |
| 148 | - keycodes::K, | 148 | + keysyms::XK_K, |
| 149 | KeyAction::ExchangeClient, | 149 | KeyAction::ExchangeClient, |
| 150 | Arg::Int(0), // UP | 150 | Arg::Int(0), // UP |
| 151 | ), | 151 | ), |
| 152 | KeyBinding::single_key( | 152 | KeyBinding::single_key( |
| 153 | vec![MODKEY, SHIFT], | 153 | vec![MODKEY, SHIFT], |
| 154 | - keycodes::J, | 154 | + keysyms::XK_J, |
| 155 | KeyAction::ExchangeClient, | 155 | KeyAction::ExchangeClient, |
| 156 | Arg::Int(1), // DOWN | 156 | Arg::Int(1), // DOWN |
| 157 | ), | 157 | ), |
| 158 | KeyBinding::single_key( | 158 | KeyBinding::single_key( |
| 159 | vec![MODKEY, SHIFT], | 159 | vec![MODKEY, SHIFT], |
| 160 | - keycodes::H, | 160 | + keysyms::XK_H, |
| 161 | KeyAction::ExchangeClient, | 161 | KeyAction::ExchangeClient, |
| 162 | Arg::Int(2), // LEFT | 162 | Arg::Int(2), // LEFT |
| 163 | ), | 163 | ), |
| 164 | KeyBinding::single_key( | 164 | KeyBinding::single_key( |
| 165 | vec![MODKEY, SHIFT], | 165 | vec![MODKEY, SHIFT], |
| 166 | - keycodes::L, | 166 | + keysyms::XK_L, |
| 167 | KeyAction::ExchangeClient, | 167 | KeyAction::ExchangeClient, |
| 168 | Arg::Int(3), // RIGHT | 168 | Arg::Int(3), // RIGHT |
| 169 | ), | 169 | ), |
| 170 | KeyBinding::single_key( | 170 | KeyBinding::single_key( |
| 171 | vec![MODKEY], | 171 | vec![MODKEY], |
| 172 | - keycodes::KEY_1, | 172 | + keysyms::XK_1, |
| 173 | KeyAction::ViewTag, | 173 | KeyAction::ViewTag, |
| 174 | Arg::Int(0), | 174 | Arg::Int(0), |
| 175 | ), | 175 | ), |
| 176 | KeyBinding::single_key( | 176 | KeyBinding::single_key( |
| 177 | vec![MODKEY], | 177 | vec![MODKEY], |
| 178 | - keycodes::KEY_2, | 178 | + keysyms::XK_2, |
| 179 | KeyAction::ViewTag, | 179 | KeyAction::ViewTag, |
| 180 | Arg::Int(1), | 180 | Arg::Int(1), |
| 181 | ), | 181 | ), |
| 182 | KeyBinding::single_key( | 182 | KeyBinding::single_key( |
| 183 | vec![MODKEY], | 183 | vec![MODKEY], |
| 184 | - keycodes::KEY_3, | 184 | + keysyms::XK_3, |
| 185 | KeyAction::ViewTag, | 185 | KeyAction::ViewTag, |
| 186 | Arg::Int(2), | 186 | Arg::Int(2), |
| 187 | ), | 187 | ), |
| 188 | KeyBinding::single_key( | 188 | KeyBinding::single_key( |
| 189 | vec![MODKEY], | 189 | vec![MODKEY], |
| 190 | - keycodes::KEY_4, | 190 | + keysyms::XK_4, |
| 191 | KeyAction::ViewTag, | 191 | KeyAction::ViewTag, |
| 192 | Arg::Int(3), | 192 | Arg::Int(3), |
| 193 | ), | 193 | ), |
| 194 | KeyBinding::single_key( | 194 | KeyBinding::single_key( |
| 195 | vec![MODKEY], | 195 | vec![MODKEY], |
| 196 | - keycodes::KEY_5, | 196 | + keysyms::XK_5, |
| 197 | KeyAction::ViewTag, | 197 | KeyAction::ViewTag, |
| 198 | Arg::Int(4), | 198 | Arg::Int(4), |
| 199 | ), | 199 | ), |
| 200 | KeyBinding::single_key( | 200 | KeyBinding::single_key( |
| 201 | vec![MODKEY], | 201 | vec![MODKEY], |
| 202 | - keycodes::KEY_6, | 202 | + keysyms::XK_6, |
| 203 | KeyAction::ViewTag, | 203 | KeyAction::ViewTag, |
| 204 | Arg::Int(5), | 204 | Arg::Int(5), |
| 205 | ), | 205 | ), |
| 206 | KeyBinding::single_key( | 206 | KeyBinding::single_key( |
| 207 | vec![MODKEY], | 207 | vec![MODKEY], |
| 208 | - keycodes::KEY_7, | 208 | + keysyms::XK_7, |
| 209 | KeyAction::ViewTag, | 209 | KeyAction::ViewTag, |
| 210 | Arg::Int(6), | 210 | Arg::Int(6), |
| 211 | ), | 211 | ), |
| 212 | KeyBinding::single_key( | 212 | KeyBinding::single_key( |
| 213 | vec![MODKEY], | 213 | vec![MODKEY], |
| 214 | - keycodes::KEY_8, | 214 | + keysyms::XK_8, |
| 215 | KeyAction::ViewTag, | 215 | KeyAction::ViewTag, |
| 216 | Arg::Int(7), | 216 | Arg::Int(7), |
| 217 | ), | 217 | ), |
| 218 | KeyBinding::single_key( | 218 | KeyBinding::single_key( |
| 219 | vec![MODKEY], | 219 | vec![MODKEY], |
| 220 | - keycodes::KEY_9, | 220 | + keysyms::XK_9, |
| 221 | KeyAction::ViewTag, | 221 | KeyAction::ViewTag, |
| 222 | Arg::Int(8), | 222 | Arg::Int(8), |
| 223 | ), | 223 | ), |
| 224 | KeyBinding::single_key( | 224 | KeyBinding::single_key( |
| 225 | vec![MODKEY, SHIFT], | 225 | vec![MODKEY, SHIFT], |
| 226 | - keycodes::KEY_1, | 226 | + keysyms::XK_1, |
| 227 | KeyAction::MoveToTag, | 227 | KeyAction::MoveToTag, |
| 228 | Arg::Int(0), | 228 | Arg::Int(0), |
| 229 | ), | 229 | ), |
| 230 | KeyBinding::single_key( | 230 | KeyBinding::single_key( |
| 231 | vec![MODKEY, SHIFT], | 231 | vec![MODKEY, SHIFT], |
| 232 | - keycodes::KEY_2, | 232 | + keysyms::XK_2, |
| 233 | KeyAction::MoveToTag, | 233 | KeyAction::MoveToTag, |
| 234 | Arg::Int(1), | 234 | Arg::Int(1), |
| 235 | ), | 235 | ), |
| 236 | KeyBinding::single_key( | 236 | KeyBinding::single_key( |
| 237 | vec![MODKEY, SHIFT], | 237 | vec![MODKEY, SHIFT], |
| 238 | - keycodes::KEY_3, | 238 | + keysyms::XK_3, |
| 239 | KeyAction::MoveToTag, | 239 | KeyAction::MoveToTag, |
| 240 | Arg::Int(2), | 240 | Arg::Int(2), |
| 241 | ), | 241 | ), |
| 242 | KeyBinding::single_key( | 242 | KeyBinding::single_key( |
| 243 | vec![MODKEY, SHIFT], | 243 | vec![MODKEY, SHIFT], |
| 244 | - keycodes::KEY_4, | 244 | + keysyms::XK_4, |
| 245 | KeyAction::MoveToTag, | 245 | KeyAction::MoveToTag, |
| 246 | Arg::Int(3), | 246 | Arg::Int(3), |
| 247 | ), | 247 | ), |
| 248 | KeyBinding::single_key( | 248 | KeyBinding::single_key( |
| 249 | vec![MODKEY, SHIFT], | 249 | vec![MODKEY, SHIFT], |
| 250 | - keycodes::KEY_5, | 250 | + keysyms::XK_5, |
| 251 | KeyAction::MoveToTag, | 251 | KeyAction::MoveToTag, |
| 252 | Arg::Int(4), | 252 | Arg::Int(4), |
| 253 | ), | 253 | ), |
| 254 | KeyBinding::single_key( | 254 | KeyBinding::single_key( |
| 255 | vec![MODKEY, SHIFT], | 255 | vec![MODKEY, SHIFT], |
| 256 | - keycodes::KEY_6, | 256 | + keysyms::XK_6, |
| 257 | KeyAction::MoveToTag, | 257 | KeyAction::MoveToTag, |
| 258 | Arg::Int(5), | 258 | Arg::Int(5), |
| 259 | ), | 259 | ), |
| 260 | KeyBinding::single_key( | 260 | KeyBinding::single_key( |
| 261 | vec![MODKEY, SHIFT], | 261 | vec![MODKEY, SHIFT], |
| 262 | - keycodes::KEY_7, | 262 | + keysyms::XK_7, |
| 263 | KeyAction::MoveToTag, | 263 | KeyAction::MoveToTag, |
| 264 | Arg::Int(6), | 264 | Arg::Int(6), |
| 265 | ), | 265 | ), |
| 266 | KeyBinding::single_key( | 266 | KeyBinding::single_key( |
| 267 | vec![MODKEY, SHIFT], | 267 | vec![MODKEY, SHIFT], |
| 268 | - keycodes::KEY_8, | 268 | + keysyms::XK_8, |
| 269 | KeyAction::MoveToTag, | 269 | KeyAction::MoveToTag, |
| 270 | Arg::Int(7), | 270 | Arg::Int(7), |
| 271 | ), | 271 | ), |
| 272 | KeyBinding::single_key( | 272 | KeyBinding::single_key( |
| 273 | vec![MODKEY, SHIFT], | 273 | vec![MODKEY, SHIFT], |
| 274 | - keycodes::KEY_9, | 274 | + keysyms::XK_9, |
| 275 | KeyAction::MoveToTag, | 275 | KeyAction::MoveToTag, |
| 276 | Arg::Int(8), | 276 | Arg::Int(8), |
| 277 | ), | 277 | ), |
+2 −0 src/monitor.rs
| @@ -13,6 +13,7 @@ pub struct Monitor { | |||
| 13 | pub height: u32, | 13 | pub height: u32, |
| 14 | pub selected_tags: u32, | 14 | pub selected_tags: u32, |
| 15 | pub focused_window: Option<Window>, | 15 | pub focused_window: Option<Window>, |
| 16 | + pub fullscreen_enabled: bool, | ||
| 16 | } | 17 | } |
| 17 | 18 | ||
| 18 | impl Monitor { | 19 | impl Monitor { |
| @@ -24,6 +25,7 @@ impl Monitor { | |||
| 24 | height, | 25 | height, |
| 25 | selected_tags: 1, | 26 | selected_tags: 1, |
| 26 | focused_window: None, | 27 | focused_window: None, |
| 28 | + fullscreen_enabled: false, | ||
| 27 | } | 29 | } |
| 28 | } | 30 | } |
| 29 | 31 | ||
+157 −98 src/window_manager.rs
| @@ -59,7 +59,6 @@ pub struct WindowManager { | |||
| 59 | window_monitor: std::collections::HashMap<Window, usize>, | 59 | window_monitor: std::collections::HashMap<Window, usize>, |
| 60 | window_geometries: std::collections::HashMap<Window, (i16, i16, u16, u16)>, | 60 | window_geometries: std::collections::HashMap<Window, (i16, i16, u16, u16)>, |
| 61 | gaps_enabled: bool, | 61 | gaps_enabled: bool, |
| 62 | - fullscreen_window: Option<Window>, | ||
| 63 | floating_windows: HashSet<Window>, | 62 | floating_windows: HashSet<Window>, |
| 64 | bars: Vec<Bar>, | 63 | bars: Vec<Bar>, |
| 65 | monitors: Vec<Monitor>, | 64 | monitors: Vec<Monitor>, |
| @@ -168,7 +167,6 @@ impl WindowManager { | |||
| 168 | window_monitor: std::collections::HashMap::new(), | 167 | window_monitor: std::collections::HashMap::new(), |
| 169 | window_geometries: std::collections::HashMap::new(), | 168 | window_geometries: std::collections::HashMap::new(), |
| 170 | gaps_enabled, | 169 | gaps_enabled, |
| 171 | - fullscreen_window: None, | ||
| 172 | floating_windows: HashSet::new(), | 170 | floating_windows: HashSet::new(), |
| 173 | bars, | 171 | bars, |
| 174 | monitors, | 172 | monitors, |
| @@ -388,6 +386,17 @@ impl WindowManager { | |||
| 388 | { | 386 | { |
| 389 | if self.floating_windows.contains(&focused) { | 387 | if self.floating_windows.contains(&focused) { |
| 390 | self.floating_windows.remove(&focused); | 388 | self.floating_windows.remove(&focused); |
| 389 | + | ||
| 390 | + let selected_tags = self | ||
| 391 | + .monitors | ||
| 392 | + .get(self.selected_monitor) | ||
| 393 | + .map(|m| m.selected_tags) | ||
| 394 | + .unwrap_or(tag_mask(0)); | ||
| 395 | + | ||
| 396 | + self.window_tags.insert(focused, selected_tags); | ||
| 397 | + self.window_monitor.insert(focused, self.selected_monitor); | ||
| 398 | + let _ = self.save_client_tag(focused, selected_tags); | ||
| 399 | + | ||
| 391 | self.apply_layout()?; | 400 | self.apply_layout()?; |
| 392 | } else { | 401 | } else { |
| 393 | let float_width = (self.screen.width_in_pixels / 2) as u32; | 402 | let float_width = (self.screen.width_in_pixels / 2) as u32; |
| @@ -428,10 +437,6 @@ impl WindowManager { | |||
| 428 | None => return Ok(()), | 437 | None => return Ok(()), |
| 429 | }; | 438 | }; |
| 430 | 439 | ||
| 431 | - if self.fullscreen_window == Some(focused) { | ||
| 432 | - return Ok(()); | ||
| 433 | - } | ||
| 434 | - | ||
| 435 | if !self.floating_windows.contains(&focused) { | 440 | if !self.floating_windows.contains(&focused) { |
| 436 | let float_width = (self.screen.width_in_pixels / 2) as u32; | 441 | let float_width = (self.screen.width_in_pixels / 2) as u32; |
| 437 | let float_height = (self.screen.height_in_pixels / 2) as u32; | 442 | let float_height = (self.screen.height_in_pixels / 2) as u32; |
| @@ -690,7 +695,7 @@ impl WindowManager { | |||
| 690 | None => return Ok(()), | 695 | None => return Ok(()), |
| 691 | }; | 696 | }; |
| 692 | 697 | ||
| 693 | - if self.fullscreen_window == Some(focused) || self.floating_windows.contains(&focused) { | 698 | + if self.floating_windows.contains(&focused) { |
| 694 | return Ok(()); | 699 | return Ok(()); |
| 695 | } | 700 | } |
| 696 | 701 | ||
| @@ -750,43 +755,18 @@ impl WindowManager { | |||
| 750 | } | 755 | } |
| 751 | 756 | ||
| 752 | fn toggle_fullscreen(&mut self) -> WmResult<()> { | 757 | fn toggle_fullscreen(&mut self) -> WmResult<()> { |
| 753 | - if let Some(focused) = self | 758 | + if let Some(monitor) = self.monitors.get_mut(self.selected_monitor) { |
| 754 | - .monitors | 759 | + monitor.fullscreen_enabled = !monitor.fullscreen_enabled; |
| 755 | - .get(self.selected_monitor) | ||
| 756 | - .and_then(|m| m.focused_window) | ||
| 757 | - { | ||
| 758 | - if self.fullscreen_window == Some(focused) { | ||
| 759 | - self.fullscreen_window = None; | ||
| 760 | - | ||
| 761 | - for bar in &self.bars { | ||
| 762 | - self.connection.map_window(bar.window())?; | ||
| 763 | - } | ||
| 764 | - | ||
| 765 | - self.apply_layout()?; | ||
| 766 | - } else { | ||
| 767 | - self.fullscreen_window = Some(focused); | ||
| 768 | 760 | ||
| 769 | - if let Some(bar) = self.bars.get(self.selected_monitor) { | 761 | + if let Some(bar) = self.bars.get(self.selected_monitor) { |
| 762 | + if monitor.fullscreen_enabled { | ||
| 770 | self.connection.unmap_window(bar.window())?; | 763 | self.connection.unmap_window(bar.window())?; |
| 764 | + } else { | ||
| 765 | + self.connection.map_window(bar.window())?; | ||
| 771 | } | 766 | } |
| 772 | - | ||
| 773 | - let monitor = &self.monitors[self.selected_monitor]; | ||
| 774 | - let screen_width = monitor.width; | ||
| 775 | - let screen_height = monitor.height; | ||
| 776 | - | ||
| 777 | - self.connection.configure_window( | ||
| 778 | - focused, | ||
| 779 | - &ConfigureWindowAux::new() | ||
| 780 | - .x(monitor.x) | ||
| 781 | - .y(monitor.y) | ||
| 782 | - .width(screen_width) | ||
| 783 | - .height(screen_height) | ||
| 784 | - .border_width(0) | ||
| 785 | - .stack_mode(StackMode::ABOVE), | ||
| 786 | - )?; | ||
| 787 | - | ||
| 788 | - self.connection.flush()?; | ||
| 789 | } | 767 | } |
| 768 | + | ||
| 769 | + self.apply_layout()?; | ||
| 790 | } | 770 | } |
| 791 | Ok(()) | 771 | Ok(()) |
| 792 | } | 772 | } |
| @@ -822,7 +802,7 @@ impl WindowManager { | |||
| 822 | indicator.push('+'); | 802 | indicator.push('+'); |
| 823 | } | 803 | } |
| 824 | 804 | ||
| 825 | - indicator.push_str(&self.format_keycode(key_press.key)); | 805 | + indicator.push_str(&self.format_keysym(key_press.keysym)); |
| 826 | } | 806 | } |
| 827 | 807 | ||
| 828 | indicator.push('-'); | 808 | indicator.push('-'); |
| @@ -841,10 +821,58 @@ impl WindowManager { | |||
| 841 | } | 821 | } |
| 842 | } | 822 | } |
| 843 | 823 | ||
| 844 | - fn format_keycode(&self, keycode: Keycode) -> String { | 824 | + fn format_keysym(&self, keysym: keyboard::keysyms::Keysym) -> String { |
| 845 | - crate::config::KeyData::from_keycode(keycode) | 825 | + use keyboard::keysyms::*; |
| 846 | - .unwrap_or("?") | 826 | + |
| 847 | - .to_string() | 827 | + match keysym { |
| 828 | + XK_RETURN => "Return", | ||
| 829 | + XK_ESCAPE => "Esc", | ||
| 830 | + XK_SPACE => "Space", | ||
| 831 | + XK_TAB => "Tab", | ||
| 832 | + XK_BACKSPACE => "Backspace", | ||
| 833 | + XK_DELETE => "Del", | ||
| 834 | + XK_F1 => "F1", | ||
| 835 | + XK_F2 => "F2", | ||
| 836 | + XK_F3 => "F3", | ||
| 837 | + XK_F4 => "F4", | ||
| 838 | + XK_F5 => "F5", | ||
| 839 | + XK_F6 => "F6", | ||
| 840 | + XK_F7 => "F7", | ||
| 841 | + XK_F8 => "F8", | ||
| 842 | + XK_F9 => "F9", | ||
| 843 | + XK_F10 => "F10", | ||
| 844 | + XK_F11 => "F11", | ||
| 845 | + XK_F12 => "F12", | ||
| 846 | + XK_A..=XK_Z | XK_0..=XK_9 => { | ||
| 847 | + return char::from_u32(keysym).unwrap_or('?').to_string(); | ||
| 848 | + } | ||
| 849 | + XK_LEFT => "Left", | ||
| 850 | + XK_RIGHT => "Right", | ||
| 851 | + XK_UP => "Up", | ||
| 852 | + XK_DOWN => "Down", | ||
| 853 | + XK_HOME => "Home", | ||
| 854 | + XK_END => "End", | ||
| 855 | + XK_PAGE_UP => "PgUp", | ||
| 856 | + XK_PAGE_DOWN => "PgDn", | ||
| 857 | + XK_INSERT => "Ins", | ||
| 858 | + XK_MINUS => "-", | ||
| 859 | + XK_EQUAL => "=", | ||
| 860 | + XK_LEFT_BRACKET => "[", | ||
| 861 | + XK_RIGHT_BRACKET => "]", | ||
| 862 | + XK_SEMICOLON => ";", | ||
| 863 | + XK_APOSTROPHE => "'", | ||
| 864 | + XK_GRAVE => "`", | ||
| 865 | + XK_BACKSLASH => "\\", | ||
| 866 | + XK_COMMA => ",", | ||
| 867 | + XK_PERIOD => ".", | ||
| 868 | + XK_SLASH => "/", | ||
| 869 | + XF86_AUDIO_RAISE_VOLUME => "Vol+", | ||
| 870 | + XF86_AUDIO_LOWER_VOLUME => "Vol-", | ||
| 871 | + XF86_AUDIO_MUTE => "Mute", | ||
| 872 | + XF86_MON_BRIGHTNESS_UP => "Bri+", | ||
| 873 | + XF86_MON_BRIGHTNESS_DOWN => "Bri-", | ||
| 874 | + _ => "?", | ||
| 875 | + }.to_string() | ||
| 848 | } | 876 | } |
| 849 | 877 | ||
| 850 | fn update_bar(&mut self) -> WmResult<()> { | 878 | fn update_bar(&mut self) -> WmResult<()> { |
| @@ -1070,13 +1098,6 @@ impl WindowManager { | |||
| 1070 | return Ok(()); | 1098 | return Ok(()); |
| 1071 | } | 1099 | } |
| 1072 | 1100 | ||
| 1073 | - if self.fullscreen_window.is_some() { | ||
| 1074 | - self.fullscreen_window = None; | ||
| 1075 | - for bar in &self.bars { | ||
| 1076 | - self.connection.map_window(bar.window())?; | ||
| 1077 | - } | ||
| 1078 | - } | ||
| 1079 | - | ||
| 1080 | if let Some(monitor) = self.monitors.get_mut(self.selected_monitor) { | 1101 | if let Some(monitor) = self.monitors.get_mut(self.selected_monitor) { |
| 1081 | monitor.selected_tags = tag_mask(tag_index); | 1102 | monitor.selected_tags = tag_mask(tag_index); |
| 1082 | } | 1103 | } |
| @@ -1175,6 +1196,32 @@ impl WindowManager { | |||
| 1175 | } | 1196 | } |
| 1176 | 1197 | ||
| 1177 | fn grab_next_keys(&self, candidates: &[usize], keys_pressed: usize) -> WmResult<()> { | 1198 | fn grab_next_keys(&self, candidates: &[usize], keys_pressed: usize) -> WmResult<()> { |
| 1199 | + use std::collections::HashMap; | ||
| 1200 | + use x11rb::protocol::xproto::Keycode; | ||
| 1201 | + | ||
| 1202 | + let setup = self.connection.setup(); | ||
| 1203 | + let min_keycode = setup.min_keycode; | ||
| 1204 | + let max_keycode = setup.max_keycode; | ||
| 1205 | + | ||
| 1206 | + let keyboard_mapping = self.connection.get_keyboard_mapping( | ||
| 1207 | + min_keycode, | ||
| 1208 | + max_keycode - min_keycode + 1, | ||
| 1209 | + )?.reply()?; | ||
| 1210 | + | ||
| 1211 | + let mut keysym_to_keycode: HashMap<keyboard::keysyms::Keysym, Vec<Keycode>> = HashMap::new(); | ||
| 1212 | + let keysyms_per_keycode = keyboard_mapping.keysyms_per_keycode; | ||
| 1213 | + | ||
| 1214 | + for keycode in min_keycode..=max_keycode { | ||
| 1215 | + let index = (keycode - min_keycode) as usize * keysyms_per_keycode as usize; | ||
| 1216 | + for i in 0..keysyms_per_keycode as usize { | ||
| 1217 | + if let Some(&keysym) = keyboard_mapping.keysyms.get(index + i) { | ||
| 1218 | + if keysym != 0 { | ||
| 1219 | + keysym_to_keycode.entry(keysym).or_insert_with(Vec::new).push(keycode); | ||
| 1220 | + } | ||
| 1221 | + } | ||
| 1222 | + } | ||
| 1223 | + } | ||
| 1224 | + | ||
| 1178 | let mut grabbed_keys: HashSet<(u16, Keycode)> = HashSet::new(); | 1225 | let mut grabbed_keys: HashSet<(u16, Keycode)> = HashSet::new(); |
| 1179 | 1226 | ||
| 1180 | for &candidate_index in candidates { | 1227 | for &candidate_index in candidates { |
| @@ -1182,20 +1229,39 @@ impl WindowManager { | |||
| 1182 | if keys_pressed < binding.keys.len() { | 1229 | if keys_pressed < binding.keys.len() { |
| 1183 | let next_key = &binding.keys[keys_pressed]; | 1230 | let next_key = &binding.keys[keys_pressed]; |
| 1184 | let modifier_mask = keyboard::handlers::modifiers_to_mask(&next_key.modifiers); | 1231 | let modifier_mask = keyboard::handlers::modifiers_to_mask(&next_key.modifiers); |
| 1185 | - let key_tuple = (modifier_mask, next_key.key); | 1232 | + |
| 1186 | - | 1233 | + if let Some(keycodes) = keysym_to_keycode.get(&next_key.keysym) { |
| 1187 | - if grabbed_keys.insert(key_tuple) { | 1234 | + if let Some(&keycode) = keycodes.first() { |
| 1188 | - self.connection.grab_key( | 1235 | + let key_tuple = (modifier_mask, keycode); |
| 1189 | - false, | 1236 | + |
| 1190 | - self.root, | 1237 | + if grabbed_keys.insert(key_tuple) { |
| 1191 | - modifier_mask.into(), | 1238 | + self.connection.grab_key( |
| 1192 | - next_key.key, | 1239 | + false, |
| 1193 | - GrabMode::ASYNC, | 1240 | + self.root, |
| 1194 | - GrabMode::ASYNC, | 1241 | + modifier_mask.into(), |
| 1195 | - )?; | 1242 | + keycode, |
| 1243 | + GrabMode::ASYNC, | ||
| 1244 | + GrabMode::ASYNC, | ||
| 1245 | + )?; | ||
| 1246 | + } | ||
| 1247 | + } | ||
| 1196 | } | 1248 | } |
| 1197 | } | 1249 | } |
| 1198 | } | 1250 | } |
| 1251 | + | ||
| 1252 | + if let Some(keycodes) = keysym_to_keycode.get(&keyboard::keysyms::XK_ESCAPE) { | ||
| 1253 | + if let Some(&keycode) = keycodes.first() { | ||
| 1254 | + self.connection.grab_key( | ||
| 1255 | + false, | ||
| 1256 | + self.root, | ||
| 1257 | + ModMask::from(0u16), | ||
| 1258 | + keycode, | ||
| 1259 | + GrabMode::ASYNC, | ||
| 1260 | + GrabMode::ASYNC, | ||
| 1261 | + )?; | ||
| 1262 | + } | ||
| 1263 | + } | ||
| 1264 | + | ||
| 1199 | self.connection.flush()?; | 1265 | self.connection.flush()?; |
| 1200 | Ok(()) | 1266 | Ok(()) |
| 1201 | } | 1267 | } |
| @@ -1459,7 +1525,8 @@ impl WindowManager { | |||
| 1459 | event, | 1525 | event, |
| 1460 | &self.config.keybindings, | 1526 | &self.config.keybindings, |
| 1461 | &self.keychord_state, | 1527 | &self.keychord_state, |
| 1462 | - ); | 1528 | + &self.connection, |
| 1529 | + )?; | ||
| 1463 | 1530 | ||
| 1464 | match result { | 1531 | match result { |
| 1465 | keyboard::handlers::KeychordResult::Completed(action, arg) => { | 1532 | keyboard::handlers::KeychordResult::Completed(action, arg) => { |
| @@ -1533,33 +1600,29 @@ impl WindowManager { | |||
| 1533 | } | 1600 | } |
| 1534 | 1601 | ||
| 1535 | fn apply_layout(&self) -> WmResult<()> { | 1602 | fn apply_layout(&self) -> WmResult<()> { |
| 1536 | - if self.fullscreen_window.is_some() { | ||
| 1537 | - return Ok(()); | ||
| 1538 | - } | ||
| 1539 | - | ||
| 1540 | if self.layout.name() == LayoutType::Normie.as_str() { | 1603 | if self.layout.name() == LayoutType::Normie.as_str() { |
| 1541 | return Ok(()); | 1604 | return Ok(()); |
| 1542 | } | 1605 | } |
| 1543 | 1606 | ||
| 1544 | - let border_width = self.config.border_width; | ||
| 1545 | - | ||
| 1546 | - let gaps = if self.gaps_enabled { | ||
| 1547 | - GapConfig { | ||
| 1548 | - inner_horizontal: self.config.gap_inner_horizontal, | ||
| 1549 | - inner_vertical: self.config.gap_inner_vertical, | ||
| 1550 | - outer_horizontal: self.config.gap_outer_horizontal, | ||
| 1551 | - outer_vertical: self.config.gap_outer_vertical, | ||
| 1552 | - } | ||
| 1553 | - } else { | ||
| 1554 | - GapConfig { | ||
| 1555 | - inner_horizontal: 0, | ||
| 1556 | - inner_vertical: 0, | ||
| 1557 | - outer_horizontal: 0, | ||
| 1558 | - outer_vertical: 0, | ||
| 1559 | - } | ||
| 1560 | - }; | ||
| 1561 | - | ||
| 1562 | for (monitor_index, monitor) in self.monitors.iter().enumerate() { | 1607 | for (monitor_index, monitor) in self.monitors.iter().enumerate() { |
| 1608 | + let border_width = if monitor.fullscreen_enabled { 0 } else { self.config.border_width }; | ||
| 1609 | + | ||
| 1610 | + let gaps = if self.gaps_enabled && !monitor.fullscreen_enabled { | ||
| 1611 | + GapConfig { | ||
| 1612 | + inner_horizontal: self.config.gap_inner_horizontal, | ||
| 1613 | + inner_vertical: self.config.gap_inner_vertical, | ||
| 1614 | + outer_horizontal: self.config.gap_outer_horizontal, | ||
| 1615 | + outer_vertical: self.config.gap_outer_vertical, | ||
| 1616 | + } | ||
| 1617 | + } else { | ||
| 1618 | + GapConfig { | ||
| 1619 | + inner_horizontal: 0, | ||
| 1620 | + inner_vertical: 0, | ||
| 1621 | + outer_horizontal: 0, | ||
| 1622 | + outer_vertical: 0, | ||
| 1623 | + } | ||
| 1624 | + }; | ||
| 1625 | + | ||
| 1563 | let visible: Vec<Window> = self | 1626 | let visible: Vec<Window> = self |
| 1564 | .windows | 1627 | .windows |
| 1565 | .iter() | 1628 | .iter() |
| @@ -1580,11 +1643,14 @@ impl WindowManager { | |||
| 1580 | .copied() | 1643 | .copied() |
| 1581 | .collect(); | 1644 | .collect(); |
| 1582 | 1645 | ||
| 1583 | - let bar_height = self | 1646 | + let bar_height = if monitor.fullscreen_enabled { |
| 1584 | - .bars | 1647 | + 0 |
| 1585 | - .get(monitor_index) | 1648 | + } else { |
| 1586 | - .map(|b| b.height() as u32) | 1649 | + self.bars |
| 1587 | - .unwrap_or(0); | 1650 | + .get(monitor_index) |
| 1651 | + .map(|b| b.height() as u32) | ||
| 1652 | + .unwrap_or(0) | ||
| 1653 | + }; | ||
| 1588 | let usable_height = monitor.height.saturating_sub(bar_height); | 1654 | let usable_height = monitor.height.saturating_sub(bar_height); |
| 1589 | 1655 | ||
| 1590 | let geometries = self | 1656 | let geometries = self |
| @@ -1627,13 +1693,6 @@ impl WindowManager { | |||
| 1627 | self.window_geometries.remove(&window); | 1693 | self.window_geometries.remove(&window); |
| 1628 | self.floating_windows.remove(&window); | 1694 | self.floating_windows.remove(&window); |
| 1629 | 1695 | ||
| 1630 | - if self.fullscreen_window == Some(window) { | ||
| 1631 | - self.fullscreen_window = None; | ||
| 1632 | - for bar in &self.bars { | ||
| 1633 | - self.connection.map_window(bar.window())?; | ||
| 1634 | - } | ||
| 1635 | - } | ||
| 1636 | - | ||
| 1637 | if self.windows.len() < initial_count { | 1696 | if self.windows.len() < initial_count { |
| 1638 | let focused = self | 1697 | let focused = self |
| 1639 | .monitors | 1698 | .monitors |
+0 −165 test-config.ron deleted file mode 100644
| @@ -1,165 +0,0 @@ | |||
| 1 | -#![enable(implicit_some)] | ||
| 2 | -// OXWM Configuration File | ||
| 3 | -// Edit this file and reload with Mod+Shift+R (no compilation needed!) | ||
| 4 | - | ||
| 5 | -#DEFINE $terminal = "alacritty" | ||
| 6 | -#DEFINE $color_blue = 0x6dade3 | ||
| 7 | -#DEFINE $color_grey = 0xbbbbbb | ||
| 8 | -#DEFINE $color_green = 0x9ece6a | ||
| 9 | -#DEFINE $color_red = 0xf7768e | ||
| 10 | -#DEFINE $color_cyan = 0x0db9d7 | ||
| 11 | -#DEFINE $color_purple = 0xad8ee6 | ||
| 12 | -#DEFINE $color_lavender = 0xa9b1d6 | ||
| 13 | -#DEFINE $color_bg = 0x1a1b26 | ||
| 14 | -#DEFINE $color_fg = 0xbbbbbb | ||
| 15 | -#DEFINE $color_light_blue = 0x7aa2f7 | ||
| 16 | - | ||
| 17 | -( | ||
| 18 | - border_width: 2, | ||
| 19 | - border_focused: $color_blue, | ||
| 20 | - border_unfocused: $color_grey, | ||
| 21 | - font: "JetBrainsMono Nerd Font:style=Bold:size=12", | ||
| 22 | - | ||
| 23 | - gaps_enabled: true, | ||
| 24 | - gap_inner_horizontal: 5, | ||
| 25 | - gap_inner_vertical: 5, | ||
| 26 | - gap_outer_horizontal: 5, | ||
| 27 | - gap_outer_vertical: 5, | ||
| 28 | - | ||
| 29 | - terminal: $terminal, | ||
| 30 | - modkey: Mod1, | ||
| 31 | - tags: ["1", "2", "3", "4", "5", "6", "7", "8", "9"], | ||
| 32 | - | ||
| 33 | - // Alternative icon tags (uncomment to use): | ||
| 34 | - // tags: ["", "", "", "", "", "", "", "", ""], | ||
| 35 | - | ||
| 36 | - // Alternative text tags (uncomment to use): | ||
| 37 | - // tags: ["DEV", "WWW", "SYS", "DOC", "VBOX", "CHAT", "MUS", "VID", "MISC"], | ||
| 38 | - | ||
| 39 | - layout_symbols: [ | ||
| 40 | - (name: "tiling", symbol: "[T]"), | ||
| 41 | - (name: "normie", symbol: "[F]"), | ||
| 42 | - ], | ||
| 43 | - | ||
| 44 | - keybindings: [ | ||
| 45 | - (keys: [(modifiers: [Mod1], key: Space), (modifiers: [], key: T)], action: Spawn, arg: "st"), | ||
| 46 | - (modifiers: [Mod1], key: Return, action: Spawn, arg: $terminal), | ||
| 47 | - (modifiers: [Mod1], key: D, action: Spawn, arg: ["sh", "-c", "dmenu_run -l 10"]), | ||
| 48 | - (modifiers: [Mod1], key: S, action: Spawn, arg: ["sh", "-c", "maim -s | xclip -selection clipboard -t image/png"]), | ||
| 49 | - (modifiers: [Mod1], key: Q, action: KillClient), | ||
| 50 | - (modifiers: [Mod1, Shift], key: F, action: ToggleFullScreen), | ||
| 51 | - (modifiers: [Mod1, Shift], key: Space, action: ToggleFloating), | ||
| 52 | - (modifiers: [Mod1], key: F, action: ChangeLayout, arg: "normie"), | ||
| 53 | - (modifiers: [Mod1], key: C, action: ChangeLayout, arg: "tiling"), | ||
| 54 | - (modifiers: [Mod1], key: N, action: CycleLayout), | ||
| 55 | - (modifiers: [Mod1], key: A, action: ToggleGaps), | ||
| 56 | - (modifiers: [Mod1, Shift], key: Q, action: Quit), | ||
| 57 | - (modifiers: [Mod1, Shift], key: R, action: Restart), | ||
| 58 | - (modifiers: [Mod1], key: J, action: FocusStack, arg: -1), | ||
| 59 | - (modifiers: [Mod1], key: K, action: FocusStack, arg: 1), | ||
| 60 | - // Exchange client (vim-style with Mod+Shift) | ||
| 61 | - (modifiers: [Mod1, Control], key: K, action: SmartMoveWin, arg: 0), // UP | ||
| 62 | - (modifiers: [Mod1, Control], key: J, action: SmartMoveWin, arg: 1), // DOWN | ||
| 63 | - (modifiers: [Mod1, Control], key: H, action: SmartMoveWin, arg: 2), // LEFT | ||
| 64 | - (modifiers: [Mod1, Control], key: L, action: SmartMoveWin, arg: 3), // RIGHT | ||
| 65 | - (modifiers: [Mod1, Shift], key: K, action: ExchangeClient, arg: 0), // UP | ||
| 66 | - (modifiers: [Mod1, Shift], key: J, action: ExchangeClient, arg: 1), // DOWN | ||
| 67 | - (modifiers: [Mod1, Shift], key: H, action: ExchangeClient, arg: 2), // LEFT | ||
| 68 | - (modifiers: [Mod1, Shift], key: L, action: ExchangeClient, arg: 3), // RIGHT | ||
| 69 | - (modifiers: [Mod1], key: Key1, action: ViewTag, arg: 0), | ||
| 70 | - (modifiers: [Mod1], key: Key2, action: ViewTag, arg: 1), | ||
| 71 | - (modifiers: [Mod1], key: Key3, action: ViewTag, arg: 2), | ||
| 72 | - (modifiers: [Mod1], key: Key4, action: ViewTag, arg: 3), | ||
| 73 | - (modifiers: [Mod1], key: Key5, action: ViewTag, arg: 4), | ||
| 74 | - (modifiers: [Mod1], key: Key6, action: ViewTag, arg: 5), | ||
| 75 | - (modifiers: [Mod1], key: Key7, action: ViewTag, arg: 6), | ||
| 76 | - (modifiers: [Mod1], key: Key8, action: ViewTag, arg: 7), | ||
| 77 | - (modifiers: [Mod1], key: Key9, action: ViewTag, arg: 8), | ||
| 78 | - (modifiers: [Mod1, Shift], key: Key1, action: MoveToTag, arg: 0), | ||
| 79 | - (modifiers: [Mod1, Shift], key: Key2, action: MoveToTag, arg: 1), | ||
| 80 | - (modifiers: [Mod1, Shift], key: Key3, action: MoveToTag, arg: 2), | ||
| 81 | - (modifiers: [Mod1, Shift], key: Key4, action: MoveToTag, arg: 3), | ||
| 82 | - (modifiers: [Mod1, Shift], key: Key5, action: MoveToTag, arg: 4), | ||
| 83 | - (modifiers: [Mod1, Shift], key: Key6, action: MoveToTag, arg: 5), | ||
| 84 | - (modifiers: [Mod1, Shift], key: Key7, action: MoveToTag, arg: 6), | ||
| 85 | - (modifiers: [Mod1, Shift], key: Key8, action: MoveToTag, arg: 7), | ||
| 86 | - (modifiers: [Mod1, Shift], key: Key9, action: MoveToTag, arg: 8), | ||
| 87 | - ], | ||
| 88 | - | ||
| 89 | - status_blocks: [ | ||
| 90 | - // Battery block (shows charging/discharging status) | ||
| 91 | - ( | ||
| 92 | - format: "", | ||
| 93 | - command: "Battery", | ||
| 94 | - battery_formats: ( | ||
| 95 | - charging: " Bat: {}%", | ||
| 96 | - discharging: " Bat:{}%", | ||
| 97 | - full: " Bat: {}%", | ||
| 98 | - ), | ||
| 99 | - interval_secs: 30, | ||
| 100 | - color: $color_green, | ||
| 101 | - underline: true, | ||
| 102 | - ), | ||
| 103 | - | ||
| 104 | - // Separator | ||
| 105 | - ( | ||
| 106 | - format: " │ ", | ||
| 107 | - command: "Static", | ||
| 108 | - interval_secs: 18446744073709551615, | ||
| 109 | - color: $color_lavender, | ||
| 110 | - underline: false, | ||
| 111 | - ), | ||
| 112 | - | ||
| 113 | - // RAM usage | ||
| 114 | - ( | ||
| 115 | - format: " {used}/{total} GB", | ||
| 116 | - command: "Ram", | ||
| 117 | - interval_secs: 5, | ||
| 118 | - color: $color_light_blue, | ||
| 119 | - underline: true, | ||
| 120 | - ), | ||
| 121 | - | ||
| 122 | - // Separator | ||
| 123 | - ( | ||
| 124 | - format: " │ ", | ||
| 125 | - command: "Static", | ||
| 126 | - interval_secs: 18446744073709551615, | ||
| 127 | - color: $color_lavender, | ||
| 128 | - underline: false, | ||
| 129 | - ), | ||
| 130 | - | ||
| 131 | - // Kernel version | ||
| 132 | - ( | ||
| 133 | - format: " {}", | ||
| 134 | - command: "Shell", | ||
| 135 | - command_arg: "uname -r", | ||
| 136 | - interval_secs: 18446744073709551615, | ||
| 137 | - color: $color_red, | ||
| 138 | - underline: true, | ||
| 139 | - ), | ||
| 140 | - | ||
| 141 | - // Separator | ||
| 142 | - ( | ||
| 143 | - format: " │ ", | ||
| 144 | - command: "Static", | ||
| 145 | - interval_secs: 18446744073709551615, | ||
| 146 | - color: $color_lavender, | ||
| 147 | - underline: false, | ||
| 148 | - ), | ||
| 149 | - | ||
| 150 | - // Date and time | ||
| 151 | - ( | ||
| 152 | - format: " {}", | ||
| 153 | - command: "DateTime", | ||
| 154 | - command_arg: "%a, %b %d - %-I:%M %P", | ||
| 155 | - interval_secs: 1, | ||
| 156 | - color: $color_cyan, | ||
| 157 | - underline: true, | ||
| 158 | - ), | ||
| 159 | - ], | ||
| 160 | - | ||
| 161 | - scheme_normal: (foreground: $color_fg, background: $color_bg, underline: 0x444444), | ||
| 162 | - scheme_occupied: (foreground: $color_cyan, background: $color_bg, underline: $color_cyan), | ||
| 163 | - scheme_selected: (foreground: $color_cyan, background: $color_bg, underline: $color_purple), | ||
| 164 | -) | ||
| 165 | - | ||