Skip to content

Commit

Permalink
stub out daemon state
Browse files Browse the repository at this point in the history
  • Loading branch information
sullyj3 committed Aug 5, 2024
1 parent 4ab0875 commit 2c7ddc6
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 2 deletions.
20 changes: 18 additions & 2 deletions src/daemon.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
pub mod state;

use std::os::fd::FromRawFd;
use std::os::fd::RawFd;
use std::os::unix;
Expand All @@ -8,6 +10,7 @@ use dirs;

use crate::cli;
use crate::sand;
use state::DaemonState;

const SYSTEMD_SOCKFD: RawFd = 3;
const SOUND_FILENAME: &str = "timer_sound.opus";
Expand Down Expand Up @@ -55,7 +58,20 @@ pub fn main(_args: cli::DaemonArgs) {
eprintln!("Warning: failed to locate notification sound. Audio will not work");
}

let _listener = unsafe { unix::net::UnixListener::from_raw_fd(fd) };
let listener = unsafe { unix::net::UnixListener::from_raw_fd(fd) };
let state = DaemonState::default();

loop {
// Accept client
let (stream, addr) = match listener.accept() {
Ok((stream, addr)) => (stream, addr),
Err(e) => {
eprintln!("Error: failed to accept client: {}", e);
continue;
},
};

unimplemented!();
// spawn a thread to handle the client
unimplemented!();
}
}
5 changes: 5 additions & 0 deletions src/daemon/state.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@

#[derive(Debug, Default, Clone)]
pub struct DaemonState {
// TODO
}

0 comments on commit 2c7ddc6

Please sign in to comment.