core: add --version

This commit is contained in:
Vaxry 2024-07-24 13:58:59 +02:00
parent dba9d8b517
commit 58e1a4a499
5 changed files with 10 additions and 8 deletions

View File

@ -30,6 +30,7 @@ add_compile_options(-Wall -Wextra -Wno-unused-parameter -Wno-unused-value
# position independent build: __FILE__ # position independent build: __FILE__
add_compile_options(-fmacro-prefix-map=${CMAKE_SOURCE_DIR}/=) add_compile_options(-fmacro-prefix-map=${CMAKE_SOURCE_DIR}/=)
add_compile_definitions(HYPRLOCK_VERSION="${VERSION}")
# dependencies # dependencies
message(STATUS "Checking deps...") message(STATUS "Checking deps...")

View File

@ -829,8 +829,7 @@ void CHyprlock::startKeyRepeat(xkb_keysym_t sym) {
if (m_iKeebRepeatDelay <= 0) if (m_iKeebRepeatDelay <= 0)
return; return;
m_pKeyRepeatTimer = addTimer( m_pKeyRepeatTimer = addTimer(std::chrono::milliseconds(m_iKeebRepeatDelay), [sym](std::shared_ptr<CTimer> self, void* data) { g_pHyprlock->repeatKey(sym); }, nullptr);
std::chrono::milliseconds(m_iKeebRepeatDelay), [sym](std::shared_ptr<CTimer> self, void* data) { g_pHyprlock->repeatKey(sym); }, nullptr);
} }
void CHyprlock::repeatKey(xkb_keysym_t sym) { void CHyprlock::repeatKey(xkb_keysym_t sym) {
@ -841,8 +840,7 @@ void CHyprlock::repeatKey(xkb_keysym_t sym) {
// This condition is for backspace and delete keys, but should also be ok for other keysyms since our buffer won't be empty anyways // This condition is for backspace and delete keys, but should also be ok for other keysyms since our buffer won't be empty anyways
if (bool CONTINUE = m_sPasswordState.passBuffer.length() > 0; CONTINUE) if (bool CONTINUE = m_sPasswordState.passBuffer.length() > 0; CONTINUE)
m_pKeyRepeatTimer = addTimer( m_pKeyRepeatTimer = addTimer(std::chrono::milliseconds(m_iKeebRepeatRate), [sym](std::shared_ptr<CTimer> self, void* data) { g_pHyprlock->repeatKey(sym); }, nullptr);
std::chrono::milliseconds(m_iKeebRepeatRate), [sym](std::shared_ptr<CTimer> self, void* data) { g_pHyprlock->repeatKey(sym); }, nullptr);
renderAllOutputs(); renderAllOutputs();
} }
@ -1051,8 +1049,7 @@ std::vector<std::shared_ptr<CTimer>> CHyprlock::getTimers() {
} }
void CHyprlock::enqueueForceUpdateTimers() { void CHyprlock::enqueueForceUpdateTimers() {
addTimer( addTimer(std::chrono::milliseconds(1), [](std::shared_ptr<CTimer> self, void* data) { forceUpdateTimers(); }, nullptr, false);
std::chrono::milliseconds(1), [](std::shared_ptr<CTimer> self, void* data) { forceUpdateTimers(); }, nullptr, false);
} }
void CHyprlock::spawnAsync(const std::string& args) { void CHyprlock::spawnAsync(const std::string& args) {

View File

@ -19,7 +19,7 @@ enum eLogLevel {
std::format(reason, ##__VA_ARGS__), __LINE__, \ std::format(reason, ##__VA_ARGS__), __LINE__, \
([]() constexpr -> std::string { return std::string(__FILE__).substr(std::string(__FILE__).find_last_of('/') + 1); })().c_str()); \ ([]() constexpr -> std::string { return std::string(__FILE__).substr(std::string(__FILE__).find_last_of('/') + 1); })().c_str()); \
printf("Assertion failed! See the log in /tmp/hypr/hyprland.log for more info."); \ printf("Assertion failed! See the log in /tmp/hypr/hyprland.log for more info."); \
std::abort(); \ std::abort(); \
} }
#define ASSERT(expr) RASSERT(expr, "?") #define ASSERT(expr) RASSERT(expr, "?")

View File

@ -2,5 +2,4 @@
#include <string> #include <string>
std::string absolutePath(const std::string&, const std::string&); std::string absolutePath(const std::string&, const std::string&);

View File

@ -41,6 +41,11 @@ int main(int argc, char** argv, char** envp) {
if (arg == "--verbose" || arg == "-v") if (arg == "--verbose" || arg == "-v")
Debug::verbose = true; Debug::verbose = true;
if (arg == "--version" || arg == "-V") {
std::cout << "Hyprlock version " << HYPRLOCK_VERSION << "\n";
return 0;
}
else if (arg == "--quiet" || arg == "-q") else if (arg == "--quiet" || arg == "-q")
Debug::quiet = true; Debug::quiet = true;