Updated plugin hash checking (#1262)

This is needed for hyprwm/Hyprland#12110
This commit is contained in:
nnra 2025-10-23 21:50:43 +02:00 committed by GitHub
parent 5319c65de2
commit af6c5f39e1
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -79,11 +79,12 @@ Skipping over some example handlers, we have two important functions:
APICALL EXPORT PLUGIN_DESCRIPTION_INFO PLUGIN_INIT(HANDLE handle) {
PHANDLE = handle;
const std::string HASH = __hyprland_api_get_hash();
const std::string COMPOSITOR_HASH = __hyprland_api_get_hash();
const std::string CLIENT_HASH = __hyprland_api_get_client_hash();
// ALWAYS add this to your plugins. It will prevent random crashes coming from
// mismatched header versions.
if (HASH != GIT_COMMIT_HASH) {
if (COMPOSITOR_HASH != CLIENT_HASH) {
HyprlandAPI::addNotification(PHANDLE, "[MyPlugin] Mismatched headers! Can't proceed.",
CHyprColor{1.0, 0.2, 0.2, 1.0}, 5000);
throw std::runtime_error("[MyPlugin] Version mismatch");