diff --git a/flake.lock b/flake.lock index ff1c3a0..5222f7a 100644 --- a/flake.lock +++ b/flake.lock @@ -20,11 +20,11 @@ ] }, "locked": { - "lastModified": 1731496216, - "narHash": "sha256-nlQrNN+tmJ+iP6Ck/czwZI0Hxz3oNvUyGkVruxJwgwA=", + "lastModified": 1731959031, + "narHash": "sha256-TGcvIjftziC1CjuiHCzrYDwmOoSFYIhdiKmLetzB5L0=", "owner": "hyprwm", "repo": "aquamarine", - "rev": "3b00e96f90cb0040de6d88ad99bf5f4d443f0c59", + "rev": "4468981c1c50999f315baa1508f0e53c4ee70c52", "type": "github" }, "original": { @@ -100,11 +100,42 @@ "type": "github" } }, + "hyprgraphics": { + "inputs": { + "hyprutils": [ + "hyprland", + "hyprutils" + ], + "nixpkgs": [ + "hyprland", + "nixpkgs" + ], + "systems": [ + "hyprland", + "systems" + ] + }, + "locked": { + "lastModified": 1733248371, + "narHash": "sha256-FFLJzFTyNhS7tBEEECx0B8Ye/bpmxhFVEKlECgMLc6c=", + "owner": "hyprwm", + "repo": "hyprgraphics", + "rev": "cc95e5babc6065bc3ab4cd195429a9900836ef13", + "type": "github" + }, + "original": { + "owner": "hyprwm", + "repo": "hyprgraphics", + "type": "github" + } + }, "hyprland": { "inputs": { "aquamarine": "aquamarine", "hyprcursor": "hyprcursor", + "hyprgraphics": "hyprgraphics", "hyprland-protocols": "hyprland-protocols", + "hyprland-qtutils": "hyprland-qtutils", "hyprlang": "hyprlang", "hyprutils": "hyprutils", "hyprwayland-scanner": "hyprwayland-scanner", @@ -114,11 +145,11 @@ "xdph": "xdph" }, "locked": { - "lastModified": 1731526492, - "narHash": "sha256-tzWLCOcIxvJvxB25kC0Q371pc5wBBzbzwSlSNc4L8gw=", + "lastModified": 1733683959, + "narHash": "sha256-+tHGw4fimhZ9LtGUTpXV8V1EH5AWY6FC/3u5OmZ4I5A=", "owner": "hyprwm", "repo": "Hyprland", - "rev": "3fb47372b79265ebdabeeefdad10359d5b18377a", + "rev": "0a27af8cd190315c1f13363ebd11e83d30455d48", "type": "github" }, "original": { @@ -152,6 +183,35 @@ "type": "github" } }, + "hyprland-qtutils": { + "inputs": { + "hyprutils": [ + "hyprland", + "hyprutils" + ], + "nixpkgs": [ + "hyprland", + "nixpkgs" + ], + "systems": [ + "hyprland", + "systems" + ] + }, + "locked": { + "lastModified": 1733472316, + "narHash": "sha256-PvXiFLIExJEJj+goLbIuXLTN5CSDSAUsAfiYSdbbWg0=", + "owner": "hyprwm", + "repo": "hyprland-qtutils", + "rev": "969427419276c7ee170301ef1ebe0f68eb6eb2e2", + "type": "github" + }, + "original": { + "owner": "hyprwm", + "repo": "hyprland-qtutils", + "type": "github" + } + }, "hyprlang": { "inputs": { "hyprutils": [ @@ -193,11 +253,11 @@ ] }, "locked": { - "lastModified": 1731518387, - "narHash": "sha256-aZZw1ZvTMLkcA6udlvkA3hrCkuipoWLy8s/JNnIclxY=", + "lastModified": 1732288281, + "narHash": "sha256-XTU9B53IjGeJiJ7LstOhuxcRjCOFkQFl01H78sT9Lg4=", "owner": "hyprwm", "repo": "hyprutils", - "rev": "315fba5d21d87ddb756d4bebdb49f99d86b0ffe8", + "rev": "b26f33cc1c8a7fd5076e19e2cce3f062dca6351c", "type": "github" }, "original": { @@ -233,11 +293,11 @@ }, "nixpkgs": { "locked": { - "lastModified": 1731139594, - "narHash": "sha256-IigrKK3vYRpUu+HEjPL/phrfh7Ox881er1UEsZvw9Q4=", + "lastModified": 1733392399, + "narHash": "sha256-kEsTJTUQfQFIJOcLYFt/RvNxIK653ZkTBIs4DG+cBns=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "76612b17c0ce71689921ca12d9ffdc9c23ce40b2", + "rev": "d0797a04b81caeae77bcff10a9dde78bc17f5661", "type": "github" }, "original": { @@ -274,11 +334,11 @@ "nixpkgs-stable": "nixpkgs-stable" }, "locked": { - "lastModified": 1731363552, - "narHash": "sha256-vFta1uHnD29VUY4HJOO/D6p6rxyObnf+InnSMT4jlMU=", + "lastModified": 1733318908, + "narHash": "sha256-SVQVsbafSM1dJ4fpgyBqLZ+Lft+jcQuMtEL3lQWx2Sk=", "owner": "cachix", "repo": "git-hooks.nix", - "rev": "cd1af27aa85026ac759d5d3fccf650abe7e1bbf0", + "rev": "6f4e2a2112050951a314d2733a994fbab94864c6", "type": "github" }, "original": { @@ -343,11 +403,11 @@ ] }, "locked": { - "lastModified": 1730743262, - "narHash": "sha256-iTLqj3lU8kFehPm5tXpctzkD274t/k1nwSSq3qCWXeg=", + "lastModified": 1733157064, + "narHash": "sha256-NetqJHAN4bbZDQADvpep+wXk2AbMZ2bN6tINz8Kpz6M=", "owner": "hyprwm", "repo": "xdg-desktop-portal-hyprland", - "rev": "09b23cef06fe248e61cec8862c04b9bcb62f4b6d", + "rev": "fd85ef39369f95eed67fdf3f025e86916edeea2f", "type": "github" }, "original": { diff --git a/hyprbars/barDeco.cpp b/hyprbars/barDeco.cpp index 4883581..7c7b61e 100644 --- a/hyprbars/barDeco.cpp +++ b/hyprbars/barDeco.cpp @@ -350,7 +350,7 @@ void CHyprBar::renderBarButtons(const Vector2D& bufferSize, const float scale) { const int Y = currentPos.y; const int RADIUS = static_cast(std::ceil(scaledButtonSize / 2.0)); - cairo_set_source_rgba(CAIRO, button.col.r, button.col.g, button.col.b, button.col.a); + cairo_set_source_rgba(CAIRO, button.bgcol.r, button.bgcol.g, button.bgcol.b, button.bgcol.a); cairo_arc(CAIRO, X, Y + RADIUS, RADIUS, 0, 2 * M_PI); cairo_fill(CAIRO); @@ -399,9 +399,14 @@ void CHyprBar::renderBarButtonsText(CBox* barBox, const float scale, const float // render icon const Vector2D BUFSIZE = {scaledButtonSize, scaledButtonSize}; - const bool LIGHT = button.col.r + button.col.g + button.col.b < 1; + auto fgcolor = button.fgcol; - renderText(button.iconTex, button.icon, LIGHT ? CHyprColor(0xFFFFFFFF) : CHyprColor(0xFF000000), BUFSIZE, scale, button.size * 0.62); + if (fgcolor == CHyprColor(0, 0, 0, 0)) { + const bool LIGHT = button.bgcol.r + button.bgcol.g + button.bgcol.b < 1; + fgcolor = LIGHT ? CHyprColor(0xFFFFFFFF) : CHyprColor(0xFF000000); + } + + renderText(button.iconTex, button.icon, fgcolor, BUFSIZE, scale, button.size * 0.62); } if (button.iconTex->m_iTexID == 0) diff --git a/hyprbars/globals.hpp b/hyprbars/globals.hpp index a2b693a..d42621d 100644 --- a/hyprbars/globals.hpp +++ b/hyprbars/globals.hpp @@ -7,7 +7,8 @@ inline HANDLE PHANDLE = nullptr; struct SHyprButton { std::string cmd = ""; - CHyprColor col = CHyprColor(0, 0, 0, 0); + CHyprColor fgcol = CHyprColor(0, 0, 0, 0); + CHyprColor bgcol = CHyprColor(0, 0, 0, 0); float size = 10; std::string icon = ""; SP iconTex = makeShared(); diff --git a/hyprbars/main.cpp b/hyprbars/main.cpp index f7d8c59..42fada2 100644 --- a/hyprbars/main.cpp +++ b/hyprbars/main.cpp @@ -59,10 +59,10 @@ Hyprlang::CParseResult onNewButton(const char* K, const char* V) { Hyprlang::CParseResult result; - // hyprbars-button = color, size, icon, action + // hyprbars-button = bgcolor, size, icon, action, fgcolor if (vars[0].empty() || vars[1].empty()) { - result.setError("var 1 and 2 cannot be empty"); + result.setError("bgcolor and size cannot be empty"); return result; } @@ -70,16 +70,27 @@ Hyprlang::CParseResult onNewButton(const char* K, const char* V) { try { size = std::stof(vars[1]); } catch (std::exception& e) { - result.setError("failed parsing var 2 as int"); + result.setError("failed to parse size"); return result; } - auto X = configStringToInt(vars[0]); - if (!X) { - result.setError("var2 is not a valid number"); + auto bgcolor = configStringToInt(vars[1]); + auto fgcolor = configStringToInt(""); + + if (!bgcolor) { + result.setError("invalid bgcolor"); return result; } - g_pGlobalState->buttons.push_back(SHyprButton{vars[3], *X, size, vars[2]}); + + if (vars.size() == 5) { + fgcolor = configStringToInt(vars[4]); + if (!fgcolor) { + result.setError("invalid fgcolor"); + return result; + } + } + + g_pGlobalState->buttons.push_back(SHyprButton{vars[3], *fgcolor, *bgcolor, size, vars[2]}); for (auto& b : g_pGlobalState->bars) { b->m_bButtonsDirty = true; @@ -108,7 +119,7 @@ APICALL EXPORT PLUGIN_DESCRIPTION_INFO PLUGIN_INIT(HANDLE handle) { HyprlandAPI::addConfigValue(PHANDLE, "plugin:hyprbars:bar_color", Hyprlang::INT{*configStringToInt("rgba(33333388)")}); HyprlandAPI::addConfigValue(PHANDLE, "plugin:hyprbars:bar_height", Hyprlang::INT{15}); - HyprlandAPI::addConfigValue(PHANDLE, "plugin:hyprbars:col.text", Hyprlang::INT{*configStringToInt("rgba(ffffffff)")}); + HyprlandAPI::addConfigValue(PHANDLE, "plugin:hyprbars:bar_text_color", Hyprlang::INT{*configStringToInt("rgba(ffffffff)")}); HyprlandAPI::addConfigValue(PHANDLE, "plugin:hyprbars:bar_text_size", Hyprlang::INT{10}); HyprlandAPI::addConfigValue(PHANDLE, "plugin:hyprbars:bar_title_enabled", Hyprlang::INT{1}); HyprlandAPI::addConfigValue(PHANDLE, "plugin:hyprbars:bar_text_font", Hyprlang::STRING{"Sans"}); @@ -132,7 +143,7 @@ APICALL EXPORT PLUGIN_DESCRIPTION_INFO PLUGIN_INIT(HANDLE handle) { HyprlandAPI::reloadConfig(); - HyprlandAPI::addNotification(PHANDLE, "[hyprbars] Initialized successfully!", CHyprColor{0.2, 1.0, 0.2, 1.0}, 5000); + /* HyprlandAPI::addNotification(PHANDLE, "[hyprbars] Initialized successfully!", CHyprColor{0.2, 1.0, 0.2, 1.0}, 5000); annoying and dumb as fuck.*/ return {"hyprbars", "A plugin to add title bars to windows.", "Vaxry", "1.0"}; }