session: add optional vim-like keybinds (#291)

Co-authored-by: 2 * r + 2 * t <61896496+soramanew@users.noreply.github.com>
This commit is contained in:
Joel R. 2025-07-29 04:48:51 +02:00 committed by GitHub
parent 7dc5b65d22
commit 2539f7b68c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 25 additions and 0 deletions

View file

@ -224,6 +224,7 @@ All configuration options are in `~/.config/caelestia/shell.json`.
},
"session": {
"dragThreshold": 30,
"vimKeybinds": false,
"commands": {
"logout": ["loginctl", "terminate-user", ""],
"shutdown": ["systemctl", "poweroff"],

View file

@ -3,7 +3,9 @@ import Quickshell.Io
JsonObject {
property bool enabled: true
property int dragThreshold: 30
property bool vimKeybinds: false
property Commands commands: Commands{}
property Sizes sizes: Sizes {}
component Commands: JsonObject {

View file

@ -98,6 +98,28 @@ Column {
Keys.onEnterPressed: Quickshell.execDetached(button.command)
Keys.onReturnPressed: Quickshell.execDetached(button.command)
Keys.onEscapePressed: root.visibilities.session = false
Keys.onPressed: event => {
if (!Config.session.vimKeybinds)
return;
if (event.modifiers & Qt.ControlModifier) {
if (event.key === Qt.Key_J && KeyNavigation.down) {
KeyNavigation.down.focus = true;
event.accepted = true;
} else if (event.key === Qt.Key_K && KeyNavigation.up) {
KeyNavigation.up.focus = true;
event.accepted = true;
}
} else if (event.key === Qt.Key_Tab && KeyNavigation.down) {
KeyNavigation.down.focus = true;
event.accepted = true;
} else if (event.key === Qt.Key_Backtab || (event.key === Qt.Key_Tab && (event.modifiers & Qt.ShiftModifier))) {
if (KeyNavigation.up) {
KeyNavigation.up.focus = true;
event.accepted = true;
}
}
}
StateLayer {
radius: parent.radius