Skip to content

Commit

Permalink
Lockscreen now gets restarted if it crashes. Fixes #6
Browse files Browse the repository at this point in the history
  • Loading branch information
Kilobyte22 committed May 14, 2018
1 parent cc7b15a commit 69d4ce2
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 11 deletions.
14 changes: 7 additions & 7 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ build = "build.rs"
[dependencies]
dbus = "0.3"
libc = "0.2"
config-parser = "0.1"
config-parser = "0.1.0"

[[bin]]
name = "lockd"
Expand Down
5 changes: 5 additions & 0 deletions src/daemon.rs
Original file line number Diff line number Diff line change
Expand Up @@ -372,6 +372,11 @@ fn actor_main(handles: ActorMainHandles, inbox: Receiver<CoreMessage>) {
}
};
apply_config(&config, &handles, &mut state);
},
CoreMessage::LockCrashed => {
state.locking = true;
state.locked = false;
handles.lockscreen.send(LockMessage::Lock).unwrap();
}

}
Expand Down
7 changes: 5 additions & 2 deletions src/lockscreen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ fn lock_command(command: &(String, Vec<String>)) -> Child {
}

fn actor_lock_instance(core: Sender<CoreMessage>, mut child: Child) {
child.wait().unwrap();
core.send(CoreMessage::Unlocked).unwrap();
if child.wait().unwrap().success() {
core.send(CoreMessage::Unlocked).unwrap();
} else {
core.send(CoreMessage::LockCrashed).unwrap();
}
}
4 changes: 3 additions & 1 deletion src/msg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ pub enum CoreMessage {
Suspended,
QueryFlag(CoreFlag, Sender<bool>),
AutoLock,
SetAutoLock(bool)
SetAutoLock(bool),
LockCrashed
}

impl fmt::Debug for CoreMessage {
Expand All @@ -42,6 +43,7 @@ impl fmt::Debug for CoreMessage {
CoreMessage::Suspending => write!(f, "Suspending"),
CoreMessage::Suspended => write!(f, "Suspended"),
CoreMessage::ReloadConfig => write!(f, "ReloadConfig"),
CoreMessage::LockCrashed => write!(f, "LockCrashed"),

CoreMessage::SuspendOnLid(flag) => {
write!(f, "SuspendOnLid({:?})", flag)
Expand Down

0 comments on commit 69d4ce2

Please sign in to comment.