Compare commits
2 commits
| Author | SHA1 | Date | |
|---|---|---|---|
| eece44a59c | |||
| 2167484861 |
17 changed files with 191 additions and 21 deletions
|
|
@ -1327,6 +1327,14 @@ impl ConfigClient {
|
||||||
self.send(&ClientMessage::SetIdle { timeout })
|
self.send(&ClientMessage::SetIdle { timeout })
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn set_key_press_enables_dpms(&self, enabled: bool) {
|
||||||
|
self.send(&ClientMessage::SetKeyPressEnablesDpms { enabled })
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn set_mouse_move_enables_dpms(&self, enabled: bool) {
|
||||||
|
self.send(&ClientMessage::SetMouseMoveEnablesDpms { enabled })
|
||||||
|
}
|
||||||
|
|
||||||
pub fn set_idle_grace_period(&self, period: Duration) {
|
pub fn set_idle_grace_period(&self, period: Duration) {
|
||||||
self.send(&ClientMessage::SetIdleGracePeriod { period })
|
self.send(&ClientMessage::SetIdleGracePeriod { period })
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -475,6 +475,12 @@ pub enum ClientMessage<'a> {
|
||||||
SetIdle {
|
SetIdle {
|
||||||
timeout: Duration,
|
timeout: Duration,
|
||||||
},
|
},
|
||||||
|
SetKeyPressEnablesDpms {
|
||||||
|
enabled: bool,
|
||||||
|
},
|
||||||
|
SetMouseMoveEnablesDpms {
|
||||||
|
enabled: bool,
|
||||||
|
},
|
||||||
MoveToOutput {
|
MoveToOutput {
|
||||||
workspace: WorkspaceSource,
|
workspace: WorkspaceSource,
|
||||||
connector: Connector,
|
connector: Connector,
|
||||||
|
|
|
||||||
|
|
@ -252,6 +252,20 @@ pub fn set_idle(timeout: Option<Duration>) {
|
||||||
get!().set_idle(timeout.unwrap_or_default())
|
get!().set_idle(timeout.unwrap_or_default())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Configures whether a key press turns monitors back on after `jay dpms off`.
|
||||||
|
///
|
||||||
|
/// The default is `false`.
|
||||||
|
pub fn set_key_press_enables_dpms(enabled: bool) {
|
||||||
|
get!().set_key_press_enables_dpms(enabled)
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Configures whether mouse movement turns monitors back on after `jay dpms off`.
|
||||||
|
///
|
||||||
|
/// The default is `false`.
|
||||||
|
pub fn set_mouse_move_enables_dpms(enabled: bool) {
|
||||||
|
get!().set_mouse_move_enables_dpms(enabled)
|
||||||
|
}
|
||||||
|
|
||||||
/// Configures the idle grace period.
|
/// Configures the idle grace period.
|
||||||
///
|
///
|
||||||
/// The grace period starts after the idle timeout expires. During the grace period, the
|
/// The grace period starts after the idle timeout expires. During the grace period, the
|
||||||
|
|
|
||||||
17
src/cli.rs
17
src/cli.rs
|
|
@ -3,6 +3,7 @@ mod color;
|
||||||
mod color_management;
|
mod color_management;
|
||||||
mod config;
|
mod config;
|
||||||
mod damage_tracking;
|
mod damage_tracking;
|
||||||
|
mod dpms;
|
||||||
mod duration;
|
mod duration;
|
||||||
mod generate;
|
mod generate;
|
||||||
mod idle;
|
mod idle;
|
||||||
|
|
@ -85,6 +86,8 @@ pub enum Cmd {
|
||||||
Screenshot(ScreenshotArgs),
|
Screenshot(ScreenshotArgs),
|
||||||
/// Inspect/modify the idle (screensaver) settings.
|
/// Inspect/modify the idle (screensaver) settings.
|
||||||
Idle(IdleArgs),
|
Idle(IdleArgs),
|
||||||
|
/// Turn monitors on or off.
|
||||||
|
Dpms(DpmsArgs),
|
||||||
/// Run a privileged program.
|
/// Run a privileged program.
|
||||||
RunPrivileged(RunPrivilegedArgs),
|
RunPrivileged(RunPrivilegedArgs),
|
||||||
/// Run a program with a connection tag.
|
/// Run a program with a connection tag.
|
||||||
|
|
@ -131,6 +134,19 @@ pub struct IdleArgs {
|
||||||
pub command: Option<IdleCmd>,
|
pub command: Option<IdleCmd>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Args, Debug)]
|
||||||
|
pub struct DpmsArgs {
|
||||||
|
/// Whether monitors should be on or off.
|
||||||
|
#[clap(value_enum)]
|
||||||
|
pub state: DpmsState,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(ValueEnum, Debug, Copy, Clone, Eq, PartialEq)]
|
||||||
|
pub enum DpmsState {
|
||||||
|
On,
|
||||||
|
Off,
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Args, Debug)]
|
#[derive(Args, Debug)]
|
||||||
pub struct RunPrivilegedArgs {
|
pub struct RunPrivilegedArgs {
|
||||||
/// The program to run
|
/// The program to run
|
||||||
|
|
@ -250,6 +266,7 @@ pub fn main() {
|
||||||
Cmd::SetLogLevel(a) => set_log_level::main(cli.global, a),
|
Cmd::SetLogLevel(a) => set_log_level::main(cli.global, a),
|
||||||
Cmd::Screenshot(a) => screenshot::main(cli.global, a),
|
Cmd::Screenshot(a) => screenshot::main(cli.global, a),
|
||||||
Cmd::Idle(a) => idle::main(cli.global, a),
|
Cmd::Idle(a) => idle::main(cli.global, a),
|
||||||
|
Cmd::Dpms(a) => dpms::main(cli.global, a),
|
||||||
Cmd::Unlock => unlock::main(cli.global),
|
Cmd::Unlock => unlock::main(cli.global),
|
||||||
Cmd::RunPrivileged(a) => run_privileged::main(cli.global, a),
|
Cmd::RunPrivileged(a) => run_privileged::main(cli.global, a),
|
||||||
Cmd::RunTagged(a) => run_tagged::main(cli.global, a),
|
Cmd::RunTagged(a) => run_tagged::main(cli.global, a),
|
||||||
|
|
|
||||||
23
src/cli/dpms.rs
Normal file
23
src/cli/dpms.rs
Normal file
|
|
@ -0,0 +1,23 @@
|
||||||
|
use {
|
||||||
|
crate::{
|
||||||
|
cli::{DpmsArgs, DpmsState, GlobalArgs},
|
||||||
|
tools::tool_client::{ToolClient, with_tool_client},
|
||||||
|
wire::jay_compositor::SetDpms,
|
||||||
|
},
|
||||||
|
std::rc::Rc,
|
||||||
|
};
|
||||||
|
|
||||||
|
pub fn main(global: GlobalArgs, args: DpmsArgs) {
|
||||||
|
with_tool_client(global.log_level, |tc| async move {
|
||||||
|
run(tc, args).await;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
async fn run(tc: Rc<ToolClient>, args: DpmsArgs) {
|
||||||
|
let comp = tc.jay_compositor().await;
|
||||||
|
tc.send(SetDpms {
|
||||||
|
self_id: comp,
|
||||||
|
active: (args.state == DpmsState::On) as u32,
|
||||||
|
});
|
||||||
|
tc.round_trip().await;
|
||||||
|
}
|
||||||
|
|
@ -279,11 +279,14 @@ fn start_compositor2(
|
||||||
change: Default::default(),
|
change: Default::default(),
|
||||||
timeout: Cell::new(Duration::from_secs(10 * 60)),
|
timeout: Cell::new(Duration::from_secs(10 * 60)),
|
||||||
grace_period: Cell::new(Duration::from_secs(5)),
|
grace_period: Cell::new(Duration::from_secs(5)),
|
||||||
|
key_press_enables_dpms: Cell::new(false),
|
||||||
|
mouse_move_enables_dpms: Cell::new(false),
|
||||||
timeout_changed: Default::default(),
|
timeout_changed: Default::default(),
|
||||||
inhibitors: Default::default(),
|
inhibitors: Default::default(),
|
||||||
inhibitors_changed: Default::default(),
|
inhibitors_changed: Default::default(),
|
||||||
inhibited_idle_notifications: Default::default(),
|
inhibited_idle_notifications: Default::default(),
|
||||||
backend_idle: Cell::new(true),
|
backend_idle: Cell::new(true),
|
||||||
|
dpms_off_by_command: Cell::new(false),
|
||||||
in_grace_period: Cell::new(false),
|
in_grace_period: Cell::new(false),
|
||||||
},
|
},
|
||||||
run_args,
|
run_args,
|
||||||
|
|
|
||||||
|
|
@ -1134,6 +1134,14 @@ impl ConfigProxyHandler {
|
||||||
self.state.idle.set_timeout(&self.state, timeout);
|
self.state.idle.set_timeout(&self.state, timeout);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn handle_set_key_press_enables_dpms(&self, enabled: bool) {
|
||||||
|
self.state.idle.key_press_enables_dpms.set(enabled);
|
||||||
|
}
|
||||||
|
|
||||||
|
fn handle_set_mouse_move_enables_dpms(&self, enabled: bool) {
|
||||||
|
self.state.idle.mouse_move_enables_dpms.set(enabled);
|
||||||
|
}
|
||||||
|
|
||||||
fn handle_set_idle_grace_period(&self, period: Duration) {
|
fn handle_set_idle_grace_period(&self, period: Duration) {
|
||||||
self.state.idle.set_grace_period(&self.state, period);
|
self.state.idle.set_grace_period(&self.state, period);
|
||||||
}
|
}
|
||||||
|
|
@ -3129,6 +3137,12 @@ impl ConfigProxyHandler {
|
||||||
.handle_get_input_device_devnode(device)
|
.handle_get_input_device_devnode(device)
|
||||||
.wrn("get_input_device_devnode")?,
|
.wrn("get_input_device_devnode")?,
|
||||||
ClientMessage::SetIdle { timeout } => self.handle_set_idle(timeout),
|
ClientMessage::SetIdle { timeout } => self.handle_set_idle(timeout),
|
||||||
|
ClientMessage::SetKeyPressEnablesDpms { enabled } => {
|
||||||
|
self.handle_set_key_press_enables_dpms(enabled)
|
||||||
|
}
|
||||||
|
ClientMessage::SetMouseMoveEnablesDpms { enabled } => {
|
||||||
|
self.handle_set_mouse_move_enables_dpms(enabled)
|
||||||
|
}
|
||||||
ClientMessage::MoveToOutput {
|
ClientMessage::MoveToOutput {
|
||||||
workspace,
|
workspace,
|
||||||
connector,
|
connector,
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
use {
|
use {
|
||||||
crate::{
|
crate::{
|
||||||
|
backend::transaction::BackendConnectorTransactionError,
|
||||||
client::{CAP_JAY_COMPOSITOR, Client, ClientCaps, ClientError, ClientId},
|
client::{CAP_JAY_COMPOSITOR, Client, ClientCaps, ClientError, ClientId},
|
||||||
compositor::LogLevel,
|
compositor::LogLevel,
|
||||||
globals::{Global, GlobalName},
|
globals::{Global, GlobalName},
|
||||||
|
|
@ -78,7 +79,7 @@ global_base!(JayCompositorGlobal, JayCompositor, JayCompositorError);
|
||||||
|
|
||||||
impl Global for JayCompositorGlobal {
|
impl Global for JayCompositorGlobal {
|
||||||
fn version(&self) -> u32 {
|
fn version(&self) -> u32 {
|
||||||
30
|
31
|
||||||
}
|
}
|
||||||
|
|
||||||
fn required_caps(&self) -> ClientCaps {
|
fn required_caps(&self) -> ClientCaps {
|
||||||
|
|
@ -542,6 +543,14 @@ impl JayCompositorRequestHandler for JayCompositor {
|
||||||
});
|
});
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn set_dpms(&self, req: SetDpms, _slf: &Rc<Self>) -> Result<(), Self::Error> {
|
||||||
|
self.client
|
||||||
|
.state
|
||||||
|
.set_dpms_active(req.active != 0)
|
||||||
|
.map_err(JayCompositorError::SetDpms)?;
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
object_base! {
|
object_base! {
|
||||||
|
|
@ -559,5 +568,7 @@ pub enum JayCompositorError {
|
||||||
ClientError(Box<ClientError>),
|
ClientError(Box<ClientError>),
|
||||||
#[error("Unknown log level {0}")]
|
#[error("Unknown log level {0}")]
|
||||||
UnknownLogLevel(u32),
|
UnknownLogLevel(u32),
|
||||||
|
#[error("Could not set DPMS state")]
|
||||||
|
SetDpms(#[source] BackendConnectorTransactionError),
|
||||||
}
|
}
|
||||||
efrom!(JayCompositorError, ClientError);
|
efrom!(JayCompositorError, ClientError);
|
||||||
|
|
|
||||||
39
src/state.rs
39
src/state.rs
|
|
@ -7,7 +7,8 @@ use {
|
||||||
Backend, BackendConnectorState, BackendConnectorStateSerials, BackendDrmDevice,
|
Backend, BackendConnectorState, BackendConnectorStateSerials, BackendDrmDevice,
|
||||||
BackendEvent, Connector, ConnectorId, ConnectorIds, DrmDeviceId, DrmDeviceIds,
|
BackendEvent, Connector, ConnectorId, ConnectorIds, DrmDeviceId, DrmDeviceIds,
|
||||||
HardwareCursorUpdate, InputDevice, InputDeviceGroupIds, InputDeviceId, InputDeviceIds,
|
HardwareCursorUpdate, InputDevice, InputDeviceGroupIds, InputDeviceId, InputDeviceIds,
|
||||||
MonitorInfo, transaction::BackendConnectorTransactionError,
|
MonitorInfo,
|
||||||
|
transaction::{BackendConnectorTransactionError, ConnectorTransaction},
|
||||||
},
|
},
|
||||||
backends::dummy::DummyBackend,
|
backends::dummy::DummyBackend,
|
||||||
cli::RunArgs,
|
cli::RunArgs,
|
||||||
|
|
@ -341,10 +342,13 @@ pub struct IdleState {
|
||||||
pub change: AsyncEvent,
|
pub change: AsyncEvent,
|
||||||
pub timeout: Cell<Duration>,
|
pub timeout: Cell<Duration>,
|
||||||
pub grace_period: Cell<Duration>,
|
pub grace_period: Cell<Duration>,
|
||||||
|
pub key_press_enables_dpms: Cell<bool>,
|
||||||
|
pub mouse_move_enables_dpms: Cell<bool>,
|
||||||
pub timeout_changed: Cell<bool>,
|
pub timeout_changed: Cell<bool>,
|
||||||
pub inhibitors: CopyHashMap<IdleInhibitorId, Rc<ZwpIdleInhibitorV1>>,
|
pub inhibitors: CopyHashMap<IdleInhibitorId, Rc<ZwpIdleInhibitorV1>>,
|
||||||
pub inhibitors_changed: Cell<bool>,
|
pub inhibitors_changed: Cell<bool>,
|
||||||
pub backend_idle: Cell<bool>,
|
pub backend_idle: Cell<bool>,
|
||||||
|
pub dpms_off_by_command: Cell<bool>,
|
||||||
pub inhibited_idle_notifications:
|
pub inhibited_idle_notifications:
|
||||||
CopyHashMap<(ClientId, ExtIdleNotificationV1Id), Rc<ExtIdleNotificationV1>>,
|
CopyHashMap<(ClientId, ExtIdleNotificationV1Id), Rc<ExtIdleNotificationV1>>,
|
||||||
pub in_grace_period: Cell<bool>,
|
pub in_grace_period: Cell<bool>,
|
||||||
|
|
@ -974,7 +978,14 @@ impl State {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn input_occurred(&self) {
|
pub fn input_occurred(self: &Rc<Self>, key_press: bool, mouse_move: bool) {
|
||||||
|
if self.idle.dpms_off_by_command.get() {
|
||||||
|
let enable_dpms = key_press && self.idle.key_press_enables_dpms.get()
|
||||||
|
|| mouse_move && self.idle.mouse_move_enables_dpms.get();
|
||||||
|
if enable_dpms && let Err(e) = self.set_dpms_active(true) {
|
||||||
|
log::error!("Could not enable DPMS after input: {}", ErrorFmt(e));
|
||||||
|
}
|
||||||
|
}
|
||||||
if !self.idle.input.replace(true) {
|
if !self.idle.input.replace(true) {
|
||||||
self.idle.change.trigger();
|
self.idle.change.trigger();
|
||||||
}
|
}
|
||||||
|
|
@ -1404,6 +1415,30 @@ impl State {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn set_connectors_active(
|
||||||
|
self: &Rc<Self>,
|
||||||
|
active: bool,
|
||||||
|
) -> Result<(), BackendConnectorTransactionError> {
|
||||||
|
let mut tran = ConnectorTransaction::new(self);
|
||||||
|
for connector in self.connectors.lock().values() {
|
||||||
|
let mut state = connector.state.borrow().clone();
|
||||||
|
state.active = active;
|
||||||
|
tran.add(&connector.connector, state)?;
|
||||||
|
}
|
||||||
|
tran.prepare()?.apply()?.commit();
|
||||||
|
self.set_backend_idle(!active);
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn set_dpms_active(
|
||||||
|
self: &Rc<Self>,
|
||||||
|
active: bool,
|
||||||
|
) -> Result<(), BackendConnectorTransactionError> {
|
||||||
|
self.set_connectors_active(active)?;
|
||||||
|
self.idle.dpms_off_by_command.set(!active);
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
pub fn root_visible(&self) -> bool {
|
pub fn root_visible(&self) -> bool {
|
||||||
!self.idle.backend_idle.get()
|
!self.idle.backend_idle.get()
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
use {
|
use {
|
||||||
crate::{
|
crate::{
|
||||||
backend::transaction::{BackendConnectorTransactionError, ConnectorTransaction},
|
backend::transaction::BackendConnectorTransactionError,
|
||||||
state::State,
|
state::State,
|
||||||
utils::{
|
utils::{
|
||||||
errorfmt::ErrorFmt,
|
errorfmt::ErrorFmt,
|
||||||
|
|
@ -136,15 +136,7 @@ impl Idle {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn try_set_idle(&self, idle: bool) -> Result<(), BackendConnectorTransactionError> {
|
fn try_set_idle(&self, idle: bool) -> Result<(), BackendConnectorTransactionError> {
|
||||||
let mut tran = ConnectorTransaction::new(&self.state);
|
self.state.set_connectors_active(!idle)
|
||||||
for connector in self.state.connectors.lock().values() {
|
|
||||||
let mut state = connector.state.borrow().clone();
|
|
||||||
state.active = !idle;
|
|
||||||
tran.add(&connector.connector, state)?;
|
|
||||||
}
|
|
||||||
tran.prepare()?.apply()?.commit();
|
|
||||||
self.state.set_backend_idle(idle);
|
|
||||||
Ok(())
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
use {
|
use {
|
||||||
crate::{
|
crate::{
|
||||||
backend::{InputDevice, InputDeviceCapability},
|
backend::{InputDevice, InputDeviceCapability, InputEvent, KeyState},
|
||||||
ifs::wl_seat::PX_PER_SCROLL,
|
ifs::wl_seat::PX_PER_SCROLL,
|
||||||
state::{DeviceHandlerData, InputDeviceData, State},
|
state::{DeviceHandlerData, InputDeviceData, State},
|
||||||
tasks::udev_utils::{UdevProps, udev_props},
|
tasks::udev_utils::{UdevProps, udev_props},
|
||||||
|
|
@ -80,13 +80,21 @@ impl DeviceHandler {
|
||||||
}
|
}
|
||||||
if let Some(seat) = self.data.seat.get() {
|
if let Some(seat) = self.data.seat.get() {
|
||||||
let mut any_events = false;
|
let mut any_events = false;
|
||||||
|
let mut key_press = false;
|
||||||
|
let mut mouse_move = false;
|
||||||
while let Some(event) = self.dev.event() {
|
while let Some(event) = self.dev.event() {
|
||||||
|
let (is_key_press, is_mouse_move) = dpms_wake_triggers_for(&event);
|
||||||
|
key_press |= is_key_press;
|
||||||
|
mouse_move |= is_mouse_move;
|
||||||
|
if is_key_press || is_mouse_move {
|
||||||
|
self.state.input_occurred(is_key_press, is_mouse_move);
|
||||||
|
}
|
||||||
seat.event(&self.data, event);
|
seat.event(&self.data, event);
|
||||||
any_events = true;
|
any_events = true;
|
||||||
}
|
}
|
||||||
if any_events {
|
if any_events {
|
||||||
seat.mark_last_active();
|
seat.mark_last_active();
|
||||||
self.state.input_occurred();
|
self.state.input_occurred(key_press, mouse_move);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
while self.dev.event().is_some() {
|
while self.dev.event().is_some() {
|
||||||
|
|
@ -105,3 +113,16 @@ impl DeviceHandler {
|
||||||
self.data.set_seat(&self.state, None);
|
self.data.set_seat(&self.state, None);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn dpms_wake_triggers_for(event: &InputEvent) -> (bool, bool) {
|
||||||
|
match event {
|
||||||
|
InputEvent::Key {
|
||||||
|
state: KeyState::Pressed,
|
||||||
|
..
|
||||||
|
} => (true, false),
|
||||||
|
InputEvent::ConnectorPosition { .. }
|
||||||
|
| InputEvent::Motion { .. }
|
||||||
|
| InputEvent::MotionAbsolute { .. } => (false, true),
|
||||||
|
_ => (false, false),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -330,7 +330,7 @@ impl ToolClient {
|
||||||
self_id: s.registry,
|
self_id: s.registry,
|
||||||
name: s.jay_compositor.0,
|
name: s.jay_compositor.0,
|
||||||
interface: JayCompositor.name(),
|
interface: JayCompositor.name(),
|
||||||
version: s.jay_compositor.1.min(30),
|
version: s.jay_compositor.1.min(31),
|
||||||
id: id.into(),
|
id: id.into(),
|
||||||
});
|
});
|
||||||
self.jay_compositor.set(Some(id));
|
self.jay_compositor.set(Some(id));
|
||||||
|
|
|
||||||
|
|
@ -560,6 +560,8 @@ pub struct Config {
|
||||||
pub inputs: Vec<Input>,
|
pub inputs: Vec<Input>,
|
||||||
pub idle: Option<Duration>,
|
pub idle: Option<Duration>,
|
||||||
pub grace_period: Option<Duration>,
|
pub grace_period: Option<Duration>,
|
||||||
|
pub key_press_enables_dpms: Option<bool>,
|
||||||
|
pub mouse_move_enables_dpms: Option<bool>,
|
||||||
pub explicit_sync_enabled: Option<bool>,
|
pub explicit_sync_enabled: Option<bool>,
|
||||||
pub focus_follows_mouse: bool,
|
pub focus_follows_mouse: bool,
|
||||||
pub window_management_key: Option<ModifiedKeySym>,
|
pub window_management_key: Option<ModifiedKeySym>,
|
||||||
|
|
|
||||||
|
|
@ -367,11 +367,15 @@ impl Parser for ConfigParser<'_> {
|
||||||
}
|
}
|
||||||
let mut idle = None;
|
let mut idle = None;
|
||||||
let mut grace_period = 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 {
|
if let Some(value) = idle_val {
|
||||||
match value.parse(&mut IdleParser(self.0)) {
|
match value.parse(&mut IdleParser(self.0)) {
|
||||||
Ok(v) => {
|
Ok(v) => {
|
||||||
idle = v.timeout;
|
idle = v.timeout;
|
||||||
grace_period = v.grace_period;
|
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) => {
|
Err(e) => {
|
||||||
log::warn!("Could not parse the idle timeout: {}", self.0.error(e));
|
log::warn!("Could not parse the idle timeout: {}", self.0.error(e));
|
||||||
|
|
@ -581,6 +585,8 @@ impl Parser for ConfigParser<'_> {
|
||||||
inputs,
|
inputs,
|
||||||
idle,
|
idle,
|
||||||
grace_period,
|
grace_period,
|
||||||
|
key_press_enables_dpms,
|
||||||
|
mouse_move_enables_dpms,
|
||||||
focus_follows_mouse: focus_follows_mouse.despan().unwrap_or(true),
|
focus_follows_mouse: focus_follows_mouse.despan().unwrap_or(true),
|
||||||
window_management_key,
|
window_management_key,
|
||||||
vrr,
|
vrr,
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@ use {
|
||||||
crate::{
|
crate::{
|
||||||
config::{
|
config::{
|
||||||
context::Context,
|
context::Context,
|
||||||
extractor::{Extractor, ExtractorError, n64, opt, val},
|
extractor::{Extractor, ExtractorError, bol, n64, opt, recover, val},
|
||||||
parser::{DataType, ParseResult, Parser, UnexpectedDataType},
|
parser::{DataType, ParseResult, Parser, UnexpectedDataType},
|
||||||
},
|
},
|
||||||
toml::{
|
toml::{
|
||||||
|
|
@ -28,6 +28,8 @@ pub struct IdleParser<'a>(pub &'a Context<'a>);
|
||||||
pub struct Idle {
|
pub struct Idle {
|
||||||
pub timeout: Option<Duration>,
|
pub timeout: Option<Duration>,
|
||||||
pub grace_period: 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<'_> {
|
impl Parser for IdleParser<'_> {
|
||||||
|
|
@ -41,10 +43,18 @@ impl Parser for IdleParser<'_> {
|
||||||
table: &IndexMap<Spanned<String>, Spanned<Value>>,
|
table: &IndexMap<Spanned<String>, Spanned<Value>>,
|
||||||
) -> ParseResult<Self> {
|
) -> ParseResult<Self> {
|
||||||
let mut ext = Extractor::new(self.0, span, table);
|
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("minutes")),
|
||||||
opt(n64("seconds")),
|
opt(n64("seconds")),
|
||||||
opt(val("grace-period")),
|
opt(val("grace-period")),
|
||||||
|
recover(opt(bol("key-press-enables-dpms"))),
|
||||||
|
recover(opt(bol("mouse-move-enables-dpms"))),
|
||||||
))?;
|
))?;
|
||||||
let mut timeout = None;
|
let mut timeout = None;
|
||||||
if minutes.is_some() || seconds.is_some() {
|
if minutes.is_some() || seconds.is_some() {
|
||||||
|
|
@ -57,6 +67,8 @@ impl Parser for IdleParser<'_> {
|
||||||
Ok(Idle {
|
Ok(Idle {
|
||||||
timeout,
|
timeout,
|
||||||
grace_period,
|
grace_period,
|
||||||
|
key_press_enables_dpms: key_press_enables_dpms.despan(),
|
||||||
|
mouse_move_enables_dpms: mouse_move_enables_dpms.despan(),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -40,9 +40,9 @@ use {
|
||||||
on_devices_enumerated, on_idle, on_unload, quit, reload, set_autotile,
|
on_devices_enumerated, on_idle, on_unload, quit, reload, set_autotile,
|
||||||
set_color_management_enabled, set_corner_radius, set_default_workspace_capture,
|
set_color_management_enabled, set_corner_radius, set_default_workspace_capture,
|
||||||
set_explicit_sync_enabled, set_float_above_fullscreen, set_floating_titles, set_idle,
|
set_explicit_sync_enabled, set_float_above_fullscreen, set_floating_titles, set_idle,
|
||||||
set_idle_grace_period, set_middle_click_paste_enabled, set_show_bar,
|
set_idle_grace_period, set_key_press_enables_dpms, set_middle_click_paste_enabled,
|
||||||
set_show_float_pin_icon, set_show_titles, set_tab_title_align, set_ui_drag_enabled,
|
set_mouse_move_enables_dpms, set_show_bar, set_show_float_pin_icon, set_show_titles,
|
||||||
set_ui_drag_threshold,
|
set_tab_title_align, set_ui_drag_enabled, set_ui_drag_threshold,
|
||||||
status::{set_i3bar_separator, set_status, set_status_command, unset_status_command},
|
status::{set_i3bar_separator, set_status, set_status_command, unset_status_command},
|
||||||
switch_to_vt,
|
switch_to_vt,
|
||||||
tasks::{self, JoinHandle},
|
tasks::{self, JoinHandle},
|
||||||
|
|
@ -1657,6 +1657,8 @@ fn load_config(initial_load: bool, auto_reload: bool, persistent: &Rc<Persistent
|
||||||
set_x_scaling_mode(mode);
|
set_x_scaling_mode(mode);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
set_key_press_enables_dpms(config.key_press_enables_dpms.unwrap_or(false));
|
||||||
|
set_mouse_move_enables_dpms(config.mouse_move_enables_dpms.unwrap_or(false));
|
||||||
if let Some(cm) = config.color_management
|
if let Some(cm) = config.color_management
|
||||||
&& let Some(enabled) = cm.enabled
|
&& let Some(enabled) = cm.enabled
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -135,6 +135,10 @@ request get_pid (since = 27) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
request set_dpms (since = 31) {
|
||||||
|
active: u32,
|
||||||
|
}
|
||||||
|
|
||||||
# events
|
# events
|
||||||
|
|
||||||
event client_id {
|
event client_id {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue