Update all dependencies
This commit is contained in:
@ -5,6 +5,6 @@ edition = "2021"
|
||||
|
||||
[dependencies]
|
||||
bscreensaver-util = { path = "../util" }
|
||||
clap = "3"
|
||||
nix = "0.23"
|
||||
clap = { version = "4", features = ["derive"] }
|
||||
nix = { version = "0.29", features = ["poll"] }
|
||||
xcb = "1"
|
||||
|
@ -1,8 +1,8 @@
|
||||
use nix::poll::{poll, PollFd, PollFlags};
|
||||
use std::{cmp, error::Error as StdError, fmt, time::{Duration, Instant}, os::unix::prelude::AsRawFd};
|
||||
use nix::poll::{poll, PollFd, PollFlags, PollTimeout};
|
||||
use std::{error::Error as StdError, fmt, os::unix::prelude::AsRawFd, time::{Duration, Instant}};
|
||||
use xcb::{x, Xid};
|
||||
|
||||
use bscreensaver_util::{create_atom, BSCREENSAVER_WM_CLASS};
|
||||
use bscreensaver_util::{borrow_raw_fd, create_atom, BSCREENSAVER_WM_CLASS};
|
||||
|
||||
const COMMAND_WINDOW_ID_ATOM_NAME: &[u8] = b"BSCREENSAVER_COMMAND_WINDOW_ID";
|
||||
const COMMAND_WINDOW_WM_NAME: &[u8] = b"bscreensaver command window";
|
||||
@ -268,16 +268,13 @@ pub fn bscreensaver_command(command: BCommand, timeout: Option<Duration>) -> Res
|
||||
let poll_timeout = timeout.map(|to| {
|
||||
let since_start = start.elapsed();
|
||||
if since_start > to {
|
||||
0i32
|
||||
Err(Error::Timeout)
|
||||
} else {
|
||||
cmp::max(i32::MAX as u128, (to - since_start).as_millis()) as i32
|
||||
Ok(u16::try_from((to - since_start).as_millis()).unwrap_or(u16::MAX).into())
|
||||
}
|
||||
}).unwrap_or(-1);
|
||||
if poll_timeout == 0 {
|
||||
break 'outer1 Err(Error::Timeout);
|
||||
}
|
||||
}).unwrap_or(Ok(PollTimeout::NONE))?;
|
||||
|
||||
let mut pfds = vec![PollFd::new(conn.as_raw_fd(), PollFlags::POLLIN)];
|
||||
let mut pfds = vec![PollFd::new(borrow_raw_fd(conn.as_raw_fd()), PollFlags::POLLIN)];
|
||||
poll(pfds.as_mut_slice(), poll_timeout)?;
|
||||
}
|
||||
}
|
||||
|
@ -1,58 +1,48 @@
|
||||
use clap::{Arg, Command};
|
||||
use std::{env, io, process::exit, time::Duration};
|
||||
use clap::{CommandFactory, Parser};
|
||||
use std::{io, process::exit, time::Duration};
|
||||
|
||||
use bscreensaver_command::{BCommand, Error, bscreensaver_command};
|
||||
|
||||
#[derive(Parser, Debug)]
|
||||
#[command(name = "bscreensaver-command", version, author, about = "Send commands to the running bscreensaver instance", long_about = None)]
|
||||
struct Args {
|
||||
/// Blanks the screen right now
|
||||
#[arg(short = 'b', long = "blank")]
|
||||
blank: bool,
|
||||
|
||||
/// Lock the screen right now
|
||||
#[arg(short = 'l', long = "lock")]
|
||||
lock: bool,
|
||||
|
||||
/// Deactivates the screen lock, presenting the unlock dialog if needed. This can be used to 'reset' things so the screensaver thinks there has been user input
|
||||
#[arg(short = 'd', long = "deactivate")]
|
||||
deactivate: bool,
|
||||
|
||||
/// Restarts the bscreensaver daemon
|
||||
#[arg(short = 'r', long = "restart")]
|
||||
restart: bool,
|
||||
|
||||
/// Causes the bscreensaver daemon to exit now, even if the screen is locked
|
||||
#[arg(short = 'x', long = "exit")]
|
||||
exit: bool,
|
||||
}
|
||||
|
||||
fn main() -> io::Result<()> {
|
||||
let mut command = Command::new("bscreensaver-command")
|
||||
.author(env!("CARGO_PKG_AUTHORS"))
|
||||
.version(env!("CARGO_PKG_VERSION"))
|
||||
.about("Send commands to the running bscreensaver instance")
|
||||
.arg(
|
||||
Arg::new("blank")
|
||||
.long("blank")
|
||||
.short('b')
|
||||
.help("Blanks the screen right now")
|
||||
)
|
||||
.arg(
|
||||
Arg::new("lock")
|
||||
.long("lock")
|
||||
.short('l')
|
||||
.help("Lock the screen right now")
|
||||
)
|
||||
.arg(
|
||||
Arg::new("deactivate")
|
||||
.long("deactivate")
|
||||
.short('d')
|
||||
.help("Deactivates the screen lock, presenting the unlock dialog if needed. This can be used to 'reset' things so the screensaver thinks there has been user input")
|
||||
)
|
||||
.arg(
|
||||
Arg::new("restart")
|
||||
.long("restart")
|
||||
.short('r')
|
||||
.help("Restarts the bscreensaver daemon")
|
||||
)
|
||||
.arg(
|
||||
Arg::new("exit")
|
||||
.long("exit")
|
||||
.short('x')
|
||||
.help("Causes the bscreensaver daemon to exit now, even if the screen is locked")
|
||||
);
|
||||
let args = command.get_matches_mut();
|
||||
let args = Args::parse();
|
||||
|
||||
let command =
|
||||
if args.is_present("blank") {
|
||||
if args.blank {
|
||||
BCommand::Blank
|
||||
} else if args.is_present("lock") {
|
||||
} else if args.lock {
|
||||
BCommand::Lock
|
||||
} else if args.is_present("deactivate") {
|
||||
} else if args.deactivate {
|
||||
BCommand::Deactivate
|
||||
} else if args.is_present("restart") {
|
||||
} else if args.restart {
|
||||
BCommand::Restart
|
||||
} else if args.is_present("exit") {
|
||||
} else if args.exit {
|
||||
BCommand::Exit
|
||||
} else {
|
||||
command.print_help()?;
|
||||
Args::command().print_help()?;
|
||||
exit(1);
|
||||
};
|
||||
|
||||
|
Reference in New Issue
Block a user