Skip to content

Commit

Permalink
blank-screens: exit without fading if signal is not SIGINT, reflect f…
Browse files Browse the repository at this point in the history
…ade status on exit code
  • Loading branch information
XPhyro committed Aug 21, 2024
1 parent 5cf78f9 commit 5edae0e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
12 changes: 7 additions & 5 deletions src/cpp/project/blank-screens/src/daemon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,11 @@ bs::daemon::daemon(const cli& cli) : m_cli(cli), m_blinds({ cli }) {}
std::exit(EXIT_FAILURE);
}

void bs::daemon::handle_signals([[maybe_unused]] int signal)
void bs::daemon::handle_signals(int signal)
{
clean_up();
std::exit(EXIT_SUCCESS);
auto interrupt = signal == SIGINT;
clean_up(interrupt);
std::exit(!interrupt);
}

// // PRIVATE // //
Expand Down Expand Up @@ -91,10 +92,11 @@ void bs::daemon::dispatch(const std::string& command_line)
}
}

void bs::daemon::clean_up()
void bs::daemon::clean_up(bool lerp_to_zero)
{
fs::remove(m_cli.fifo_path());
fs::remove_all(m_cli.lock_path());

m_blinds.lerp_alpha(0.0);
if (lerp_to_zero)
m_blinds.lerp_alpha(0.0);
}
4 changes: 2 additions & 2 deletions src/cpp/project/blank-screens/src/daemon.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ namespace bs {
daemon(void) = delete;
daemon(const cli& cli);
[[noreturn]] void run(void);
void handle_signals(int signal);
[[noreturn]] void handle_signals(int signal);

private:
void dispatch(const std::string& command_line);
void clean_up(void);
void clean_up(bool lerp_to_zero = true);
};
} // namespace bs

Expand Down

0 comments on commit 5edae0e

Please sign in to comment.