Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[update] Exit on SIGINT ( Control + c ). #77

Merged
merged 2 commits into from
Mar 6, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -201,7 +199,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 @@ -273,15 +272,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