Skip to content

Commit

Permalink
Merge pull request #77 from waycrate/remove_temp_pause
Browse files Browse the repository at this point in the history
[update] Exit on SIGINT ( Control + c ).
  • Loading branch information
Shinyzenith authored Mar 6, 2022
2 parents c36bd28 + 185dbd0 commit 6046f14
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 13 deletions.
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ After opening swhkd, you can control the program through signals:
- `sudo pkill -USR1 swhkd` - Pause key checking
- `sudo pkill -USR2 swhkd` - Resume key checking
- `sudo pkill -HUP swhkd` - Reload config file
- `sudo pkill -INT swhkd` - Pause key checking temporarily (resume by pressing `super+shift+escape`)

## Configuration

Expand Down
14 changes: 2 additions & 12 deletions src/daemon.rs
Original file line number Diff line number Diff line change
Expand Up @@ -157,8 +157,6 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
SIGSYS, SIGTERM, SIGTRAP, SIGTSTP, SIGVTALRM, SIGXCPU, SIGXFSZ,
])?;
let mut paused = false;
let mut temp_paused = false;

let mut last_hotkey: Option<config::Hotkey> = None;
let mut keyboard_states: Vec<KeyboardState> = Vec::new();
let mut keyboard_stream_map = StreamMap::new();
Expand Down Expand Up @@ -200,7 +198,8 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
hotkeys = load_config();
}
SIGINT => {
temp_paused = true;
log::warn!("Received SIGINT signal, exiting...");
exit(1);
}
_ => {
let keyboard_devices = evdev::enumerate().filter(check_keyboard);
Expand Down Expand Up @@ -272,15 +271,6 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
log::debug!("state_modifiers: {:#?}", keyboard_state.state_modifiers);
log::debug!("state_keysyms: {:#?}", keyboard_state.state_keysyms);
log::debug!("hotkey: {:#?}", possible_hotkeys);
if temp_paused {
if keyboard_state.state_modifiers.iter().all(|x| {
vec![config::Modifier::Shift, config::Modifier::Super].contains(x)
}) && keyboard_state.state_keysyms.contains(evdev::Key::KEY_ESC)
{
temp_paused = false;
}
continue;
}

for hotkey in possible_hotkeys {
// this should check if state_modifiers and hotkey.modifiers have the same elements
Expand Down

0 comments on commit 6046f14

Please sign in to comment.