Linger on screen after release, keyviz-style
Previously the chips cleared the instant the keys were released, so the 120ms hide delay was invisible. Keep the last combo rendered for the whole linger window and only clear it when the timer fires, so a quick tap stays readable (keyviz keeps keys for lingerDurationMs, 5s by default). Default 1000ms, tunable via lingerMs.
This commit is contained in:
+13
-7
@@ -10,7 +10,7 @@ import qs.Ui
|
|||||||
// to the compositor's key events and writes the current combination to
|
// to the compositor's key events and writes the current combination to
|
||||||
// $XDG_RUNTIME_DIR/omarchy-key-visualizer.json. This panel watches that file
|
// $XDG_RUNTIME_DIR/omarchy-key-visualizer.json. This panel watches that file
|
||||||
// and renders. No images, no animations: the combo appears while held and
|
// and renders. No images, no animations: the combo appears while held and
|
||||||
// disappears the moment the keys are released.
|
// lingers briefly after release (like keyviz's Duration), then vanishes.
|
||||||
//
|
//
|
||||||
// On first load the panel also appends a small guarded block to
|
// On first load the panel also appends a small guarded block to
|
||||||
// ~/.config/hypr/hyprland.lua that dofiles the capture script, so install
|
// ~/.config/hypr/hyprland.lua that dofiles the capture script, so install
|
||||||
@@ -21,9 +21,10 @@ Item {
|
|||||||
|
|
||||||
property bool opened: false
|
property bool opened: false
|
||||||
property var keys: []
|
property var keys: []
|
||||||
// Grace period after the last key is released. Small enough to feel
|
// How long the last combination stays on screen after the keys are
|
||||||
// immediate, long enough that a quick tap is still readable.
|
// released (keyviz's "Duration"; keyviz defaults to 5000ms). The combo
|
||||||
property int hideDelayMs: 120
|
// lingers intact, then vanishes in one frame — no fade.
|
||||||
|
property int lingerMs: 1000
|
||||||
// Drop state written more than this long ago (e.g. from a previous shell
|
// Drop state written more than this long ago (e.g. from a previous shell
|
||||||
// session after a restart) so a stale combo never sticks on screen.
|
// session after a restart) so a stale combo never sticks on screen.
|
||||||
readonly property int maxStateAgeMs: 1500
|
readonly property int maxStateAgeMs: 1500
|
||||||
@@ -79,19 +80,24 @@ Item {
|
|||||||
if (age <= Math.ceil(root.maxStateAgeMs / 1000)) next = parsed.keys
|
if (age <= Math.ceil(root.maxStateAgeMs / 1000)) next = parsed.keys
|
||||||
}
|
}
|
||||||
} catch (e) {}
|
} catch (e) {}
|
||||||
root.keys = next
|
|
||||||
if (next.length === 0) {
|
if (next.length === 0) {
|
||||||
|
// Keys were released: keep the last combo on screen for the linger
|
||||||
|
// window, then clear it. A fresh press restarts the timer below.
|
||||||
hideTimer.restart()
|
hideTimer.restart()
|
||||||
} else {
|
} else {
|
||||||
hideTimer.stop()
|
hideTimer.stop()
|
||||||
|
root.keys = next
|
||||||
root.opened = true
|
root.opened = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Timer {
|
Timer {
|
||||||
id: hideTimer
|
id: hideTimer
|
||||||
interval: root.hideDelayMs
|
interval: root.lingerMs
|
||||||
onTriggered: root.opened = false
|
onTriggered: {
|
||||||
|
root.keys = []
|
||||||
|
root.opened = false
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
FileView {
|
FileView {
|
||||||
|
|||||||
@@ -71,7 +71,8 @@ The panel starts with the shell, so it works after the next login too.
|
|||||||
- Modifiers that produce the shifted character (`Shift` with a letter) are
|
- Modifiers that produce the shifted character (`Shift` with a letter) are
|
||||||
folded into the character itself: `Shift + 1` shows `!`.
|
folded into the character itself: `Shift + 1` shows `!`.
|
||||||
- Key repeat is ignored; a held key shows once.
|
- Key repeat is ignored; a held key shows once.
|
||||||
- The combo disappears immediately after the last key is released.
|
- After the last key is released the combo lingers briefly (1s by default,
|
||||||
|
keyviz-style "Duration") and then vanishes in one frame — no fade.
|
||||||
|
|
||||||
## Customize
|
## Customize
|
||||||
|
|
||||||
@@ -81,7 +82,7 @@ automatically.
|
|||||||
|
|
||||||
| Want to change... | Edit |
|
| Want to change... | Edit |
|
||||||
|-----------------------------------|-----------------------------------------|
|
|-----------------------------------|-----------------------------------------|
|
||||||
| How long a released combo lingers | `hideDelayMs` in `KeyVisualizer.qml` (default `120`) |
|
| How long a released combo lingers | `lingerMs` in `KeyVisualizer.qml` (default `1000`; keyviz defaults to `5000`) |
|
||||||
| Chip font / padding | `chipFont`, `chipPadX/Y` in `KeyVisualizer.qml` |
|
| Chip font / padding | `chipFont`, `chipPadX/Y` in `KeyVisualizer.qml` |
|
||||||
| Key labels or layout mapping | `KEYS` / `CHARS` / `SHIFTED` tables in `key-visualizer.lua` |
|
| Key labels or layout mapping | `KEYS` / `CHARS` / `SHIFTED` tables in `key-visualizer.lua` |
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -2,7 +2,7 @@
|
|||||||
"schemaVersion": 1,
|
"schemaVersion": 1,
|
||||||
"id": "felixzsh.key-visualizer",
|
"id": "felixzsh.key-visualizer",
|
||||||
"name": "Key Visualizer",
|
"name": "Key Visualizer",
|
||||||
"version": "1.0.0",
|
"version": "1.1.0",
|
||||||
"description": "Shows the keys you press on screen. Great for keybinding tutorials, demos, and screencasts.",
|
"description": "Shows the keys you press on screen. Great for keybinding tutorials, demos, and screencasts.",
|
||||||
"kinds": ["panel"],
|
"kinds": ["panel"],
|
||||||
"keepLoaded": true,
|
"keepLoaded": true,
|
||||||
|
|||||||
Reference in New Issue
Block a user