add config options for waking dpms on mouse and keyboard interaction
This commit is contained in:
parent
2167484861
commit
eece44a59c
12 changed files with 116 additions and 9 deletions
|
|
@ -367,11 +367,15 @@ impl Parser for ConfigParser<'_> {
|
|||
}
|
||||
let mut idle = None;
|
||||
let mut grace_period = None;
|
||||
let mut key_press_enables_dpms = None;
|
||||
let mut mouse_move_enables_dpms = None;
|
||||
if let Some(value) = idle_val {
|
||||
match value.parse(&mut IdleParser(self.0)) {
|
||||
Ok(v) => {
|
||||
idle = v.timeout;
|
||||
grace_period = v.grace_period;
|
||||
key_press_enables_dpms = v.key_press_enables_dpms;
|
||||
mouse_move_enables_dpms = v.mouse_move_enables_dpms;
|
||||
}
|
||||
Err(e) => {
|
||||
log::warn!("Could not parse the idle timeout: {}", self.0.error(e));
|
||||
|
|
@ -581,6 +585,8 @@ impl Parser for ConfigParser<'_> {
|
|||
inputs,
|
||||
idle,
|
||||
grace_period,
|
||||
key_press_enables_dpms,
|
||||
mouse_move_enables_dpms,
|
||||
focus_follows_mouse: focus_follows_mouse.despan().unwrap_or(true),
|
||||
window_management_key,
|
||||
vrr,
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ use {
|
|||
crate::{
|
||||
config::{
|
||||
context::Context,
|
||||
extractor::{Extractor, ExtractorError, n64, opt, val},
|
||||
extractor::{Extractor, ExtractorError, bol, n64, opt, recover, val},
|
||||
parser::{DataType, ParseResult, Parser, UnexpectedDataType},
|
||||
},
|
||||
toml::{
|
||||
|
|
@ -28,6 +28,8 @@ pub struct IdleParser<'a>(pub &'a Context<'a>);
|
|||
pub struct Idle {
|
||||
pub timeout: Option<Duration>,
|
||||
pub grace_period: Option<Duration>,
|
||||
pub key_press_enables_dpms: Option<bool>,
|
||||
pub mouse_move_enables_dpms: Option<bool>,
|
||||
}
|
||||
|
||||
impl Parser for IdleParser<'_> {
|
||||
|
|
@ -41,10 +43,18 @@ impl Parser for IdleParser<'_> {
|
|||
table: &IndexMap<Spanned<String>, Spanned<Value>>,
|
||||
) -> ParseResult<Self> {
|
||||
let mut ext = Extractor::new(self.0, span, table);
|
||||
let (minutes, seconds, grace_period_val) = ext.extract((
|
||||
let (
|
||||
minutes,
|
||||
seconds,
|
||||
grace_period_val,
|
||||
key_press_enables_dpms,
|
||||
mouse_move_enables_dpms,
|
||||
) = ext.extract((
|
||||
opt(n64("minutes")),
|
||||
opt(n64("seconds")),
|
||||
opt(val("grace-period")),
|
||||
recover(opt(bol("key-press-enables-dpms"))),
|
||||
recover(opt(bol("mouse-move-enables-dpms"))),
|
||||
))?;
|
||||
let mut timeout = None;
|
||||
if minutes.is_some() || seconds.is_some() {
|
||||
|
|
@ -57,6 +67,8 @@ impl Parser for IdleParser<'_> {
|
|||
Ok(Idle {
|
||||
timeout,
|
||||
grace_period,
|
||||
key_press_enables_dpms: key_press_enables_dpms.despan(),
|
||||
mouse_move_enables_dpms: mouse_move_enables_dpms.despan(),
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue