Skip to content

Commit

Permalink
[update] Exit on SIGINT ( Control + c ).
Browse files Browse the repository at this point in the history
  • Loading branch information
Shinyzenith committed Mar 6, 2022
1 parent 1898566 commit b8daa1b
Show file tree
Hide file tree
Showing 2 changed files with 1 addition 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
13 changes: 1 addition & 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 @@ -201,7 +199,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
hotkeys = load_config();
}
SIGINT => {
temp_paused = true;
exit(1);
}
_ => {
let keyboard_devices = evdev::enumerate().filter(check_keyboard);
Expand Down Expand Up @@ -273,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 b8daa1b

Please sign in to comment.