Skip to content

Commit 2ff4993

Browse files
committed
feat: define hold and intensity behaviours for shake cursor
1 parent e835cbc commit 2ff4993

File tree

3 files changed

+213
-27
lines changed

3 files changed

+213
-27
lines changed

docs/wiki/Configuration:-Miscellaneous.md

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,10 @@ cursor {
207207
shake {
208208
off
209209
max-multiplier 2.5
210+
behavior "hold"
211+
cooldown-ms 400
212+
stopped-threshold-ms 50
213+
shake-relax-ms 150
210214
post-expand-delay-ms 250
211215
expand-duration-ms 200
212216
decay-duration-ms 300
@@ -227,6 +231,48 @@ shake {
227231
}
228232
```
229233

234+
#### `behavior`
235+
236+
Selects the shake behaviour.
237+
- `"hold"` (default): keep the cursor enlarged while the pointer is moving; when the pointer stops the shrink animation is scheduled.
238+
- `"intensity"`: keep the cursor enlarged while shake intensity is high; start shrinking when intensity drops below `sensitivity`.
239+
240+
```kdl
241+
shake {
242+
behavior "hold"
243+
}
244+
```
245+
246+
#### `cooldown-ms`
247+
248+
After a shrink (decay) completes, ignore new shake-triggered expansions until this many milliseconds have passed. Prevents immediate re-expansions when the pointer is noisy.
249+
250+
```kdl
251+
shake {
252+
cooldown-ms 400
253+
}
254+
```
255+
256+
#### `stopped-threshold-ms`
257+
258+
Only for `behavior "hold"`. The pointer is considered "stopped" if no motion has been observed for this many milliseconds; when stopped the shrink is scheduled after `post-expand-delay-ms`.
259+
260+
```kdl
261+
shake {
262+
stopped-threshold-ms 50
263+
}
264+
```
265+
266+
#### `shake-relax-ms`
267+
268+
Only for `behavior "intensity"`. How long the shake factor must remain below `sensitivity` before decay is scheduled. Prevents transient dips from triggering shrink.
269+
270+
```kdl
271+
shake {
272+
shake-relax-ms 150
273+
}
274+
```
275+
230276
#### `post-expand-delay-ms`
231277

232278
When the cursor is enlarged, this is the additional delay (ms) after the expansion animation finishes before the shrink animation (decay) is started. Once decay begins it will not be interrupted by further pointer movement.

niri-config/src/misc.rs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,10 @@ pub struct ShakeConfig {
2424
pub shake_interval_ms: u64,
2525
pub min_diagonal: f64,
2626
pub sensitivity: f64,
27+
pub cooldown_ms: Option<u64>,
28+
pub behavior: Option<String>,
29+
pub stopped_threshold_ms: Option<u64>,
30+
pub shake_relax_ms: Option<u64>,
2731
}
2832

2933
impl Default for ShakeConfig {
@@ -37,6 +41,10 @@ impl Default for ShakeConfig {
3741
shake_interval_ms: 400,
3842
min_diagonal: 100.0,
3943
sensitivity: 2.0,
44+
cooldown_ms: Some(400),
45+
behavior: Some(String::from("hold")),
46+
stopped_threshold_ms: Some(50),
47+
shake_relax_ms: Some(150),
4048
}
4149
}
4250
}
@@ -61,6 +69,14 @@ pub struct ShakeConfigPart {
6169
pub min_diagonal: Option<f64>,
6270
#[knuffel(child, unwrap(argument))]
6371
pub sensitivity: Option<f64>,
72+
#[knuffel(child, unwrap(argument))]
73+
pub cooldown_ms: Option<u64>,
74+
#[knuffel(child, unwrap(argument, str))]
75+
pub behavior: Option<String>,
76+
#[knuffel(child, unwrap(argument))]
77+
pub stopped_threshold_ms: Option<u64>,
78+
#[knuffel(child, unwrap(argument))]
79+
pub shake_relax_ms: Option<u64>,
6480
}
6581

6682
impl MergeWith<ShakeConfigPart> for ShakeConfig {
@@ -76,6 +92,10 @@ impl MergeWith<ShakeConfigPart> for ShakeConfig {
7692
merge_clone!((self, part), decay_duration_ms);
7793
merge_clone!((self, part), shake_interval_ms);
7894
merge_clone!((self, part), min_diagonal);
95+
merge_clone_opt!((self, part), cooldown_ms);
96+
merge_clone_opt!((self, part), behavior);
97+
merge_clone_opt!((self, part), stopped_threshold_ms);
98+
merge_clone_opt!((self, part), shake_relax_ms);
7999
}
80100
}
81101

0 commit comments

Comments
 (0)