-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from d86leader/develop
Release 1.1.0
- Loading branch information
Showing
14 changed files
with
378 additions
and
99 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
[package] | ||
name = "wzmach" | ||
version = "1.0.0" | ||
version = "1.1.0" | ||
edition = "2021" | ||
|
||
[profile.release] | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
[1.1.0 2022-06-19] | ||
- Add rotation gesture | ||
- Add any-command action | ||
- Can now specify config file to use | ||
- Rework how sequential gestures are counted | ||
This fixes the problem with diagonal swipes triggering a lot of stuff | ||
simultaneously | ||
- Make other gestures reversible, not just cardinals | ||
So now you can rotate in one direction, in other, and then in the first | ||
direction again, without lifting your fingers |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
mod command_action; | ||
mod uinput_action; | ||
|
||
use thiserror::Error; | ||
|
||
#[derive(Error, Debug)] | ||
#[error("Failure executing action: {0}")] | ||
pub struct ActionError(pub String); | ||
|
||
pub trait Action { | ||
fn execute(&mut self) -> Result<(), ActionError>; | ||
} | ||
|
||
pub use uinput_action::UinputAction; | ||
pub use command_action::{CommandAction, ShellCommandAction}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
use std::os::unix::prelude::CommandExt; | ||
|
||
use super::{Action, ActionError}; | ||
|
||
pub struct CommandAction { | ||
pub path: String, | ||
pub args: Vec<String>, | ||
} | ||
|
||
pub struct ShellCommandAction { | ||
pub command: String, | ||
} | ||
|
||
impl Action for CommandAction { | ||
fn execute(&mut self) -> Result<(), ActionError> { | ||
log::debug!("Execute command {} {:?}", self.path, self.args); | ||
|
||
std::process::Command::new(&self.path) | ||
.args(self.args.iter()) | ||
.stdin(std::process::Stdio::null()) | ||
.stdout(std::process::Stdio::inherit()) | ||
.stderr(std::process::Stdio::inherit()) | ||
.detach()?; | ||
log::trace!("Spawned the command"); | ||
|
||
Ok(()) | ||
} | ||
} | ||
|
||
impl Action for ShellCommandAction { | ||
fn execute(&mut self) -> Result<(), ActionError> { | ||
log::debug!("Execute command {:?}", self.command); | ||
|
||
std::process::Command::new("/bin/sh") | ||
.arg("-c") | ||
.arg(&self.command) | ||
.stdout(std::process::Stdio::inherit()) | ||
.stderr(std::process::Stdio::inherit()) | ||
.detach()?; | ||
log::trace!("Spawned the command"); | ||
|
||
Ok(()) | ||
} | ||
} | ||
|
||
/// Extension to be able to detach child processes without creating zombies | ||
trait DetachExt { | ||
fn detach(&mut self) -> std::io::Result<()>; | ||
} | ||
impl DetachExt for std::process::Command { | ||
fn detach(&mut self) -> std::io::Result<()> { | ||
// Safety: usual daemonization stuff. Parent exits immediately before | ||
// exec, child goes on to exec what it wants | ||
use nix::unistd::ForkResult; | ||
unsafe { | ||
self.pre_exec(|| { | ||
match nix::unistd::fork().unwrap() { | ||
ForkResult::Parent { child: _ } => std::process::exit(0), | ||
ForkResult::Child => (), | ||
} | ||
Ok(()) | ||
}) | ||
} | ||
.status() | ||
.map(|_| ()) | ||
} | ||
} | ||
|
||
impl From<std::io::Error> for ActionError { | ||
fn from(err: std::io::Error) -> ActionError { | ||
ActionError(format!("{}", err)) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.