Skip to content

Commit

Permalink
Feat hl version check (#52)
Browse files Browse the repository at this point in the history
* chore: update flake.lock

* feat: add version mismatch check
  • Loading branch information
horriblename committed Oct 28, 2023
1 parent c6a62dd commit 71b3a28
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include <hyprland/src/Compositor.hpp>
#include <hyprland/src/config/ConfigManager.hpp>
#include <hyprland/src/managers/input/InputManager.hpp>
#include <hyprland/src/version.h>
#include <vector>

const CColor s_pluginColor = {0x61 / 255.0f, 0xAF / 255.0f, 0xEF / 255.0f,
Expand Down Expand Up @@ -83,6 +84,20 @@ APICALL EXPORT PLUGIN_DESCRIPTION_INFO PLUGIN_INIT(HANDLE handle) {
PHANDLE, (void*)&CInputManager::onTouchMove, (void*)&hkOnTouchMove);
#pragma GCC diagnostic pop

const auto hlTargetVersion = GIT_COMMIT_HASH;
const auto hlVersion = HyprlandAPI::getHyprlandVersion(PHANDLE);

if (hlVersion.hash != hlTargetVersion) {
HyprlandAPI::addNotification(
PHANDLE, "Mismatched Hyprland version! check logs for details",
CColor(0.8, 0.2, 0.2, 1.0), 5000);
Debug::log(ERR, "[hyprgrass] version mismatch!");
Debug::log(ERR, "[hyprgrass] | hyprgrass was built against: {}",
hlTargetVersion);
Debug::log(ERR, "[hyprgrass] | actual hyprland version: {}",
hlVersion.hash);
}

g_pTouchDownHook->hook();
g_pTouchUpHook->hook();
g_pTouchMoveHook->hook();
Expand Down

0 comments on commit 71b3a28

Please sign in to comment.