aboutsummaryrefslogtreecommitdiffhomepage
path: root/hyprpm
diff options
context:
space:
mode:
authorVaxry <[email protected]>2024-06-11 17:17:45 +0200
committerGitHub <[email protected]>2024-06-11 17:17:45 +0200
commit8c64a4bad710fb18e9b84812bd680a89d1e93661 (patch)
tree2439b8408abd8e14f6af35ef9cfbeb7c51429f99 /hyprpm
parent1f46296ea05f9a8e6020ab694b531c91a1abdfa6 (diff)
downloadHyprland-8c64a4bad710fb18e9b84812bd680a89d1e93661.tar.gz
Hyprland-8c64a4bad710fb18e9b84812bd680a89d1e93661.zip
core: move to hyprutils for utils (#6385)
* core: move to hyprutils for utils Nix: add hyprutils dep * Meson: add hyprutils dep * flake.lock: update --------- Co-authored-by: Mihai Fufezan <[email protected]>
Diffstat (limited to 'hyprpm')
-rw-r--r--hyprpm/CMakeLists.txt4
-rw-r--r--hyprpm/src/core/PluginManager.cpp24
-rw-r--r--hyprpm/src/meson.build1
3 files changed, 7 insertions, 22 deletions
diff --git a/hyprpm/CMakeLists.txt b/hyprpm/CMakeLists.txt
index 8b6a8320..692e8da1 100644
--- a/hyprpm/CMakeLists.txt
+++ b/hyprpm/CMakeLists.txt
@@ -9,11 +9,11 @@ file(GLOB_RECURSE SRCFILES CONFIGURE_DEPENDS "src/*.cpp")
set(CMAKE_CXX_STANDARD 23)
-pkg_check_modules(tomlplusplus REQUIRED IMPORTED_TARGET tomlplusplus)
+pkg_check_modules(deps REQUIRED IMPORTED_TARGET tomlplusplus hyprutils>=0.1.1)
add_executable(hyprpm ${SRCFILES})
-target_link_libraries(hyprpm PUBLIC PkgConfig::tomlplusplus)
+target_link_libraries(hyprpm PUBLIC PkgConfig::deps)
# binary
install(TARGETS hyprpm)
diff --git a/hyprpm/src/core/PluginManager.cpp b/hyprpm/src/core/PluginManager.cpp
index fb338d25..446d6af3 100644
--- a/hyprpm/src/core/PluginManager.cpp
+++ b/hyprpm/src/core/PluginManager.cpp
@@ -19,24 +19,8 @@
#include <toml++/toml.hpp>
-static std::string removeBeginEndSpacesTabs(std::string str) {
- if (str.empty())
- return str;
-
- int countBefore = 0;
- while (str[countBefore] == ' ' || str[countBefore] == '\t') {
- countBefore++;
- }
-
- int countAfter = 0;
- while ((int)str.length() - countAfter - 1 >= 0 && (str[str.length() - countAfter - 1] == ' ' || str[str.length() - 1 - countAfter] == '\t')) {
- countAfter++;
- }
-
- str = str.substr(countBefore, str.length() - countBefore - countAfter);
-
- return str;
-}
+#include <hyprutils/string/String.hpp>
+using namespace Hyprutils::String;
static std::string execAndGet(std::string cmd) {
cmd += " 2>&1";
@@ -374,7 +358,7 @@ eHeadersErrors CPluginManager::headersValid() {
if (PATH.ends_with("protocols") || PATH.ends_with("wlroots-hyprland"))
continue;
- verHeader = removeBeginEndSpacesTabs(PATH.substr(2)) + "/hyprland/src/version.h";
+ verHeader = trim(PATH.substr(2)) + "/hyprland/src/version.h";
break;
}
@@ -447,7 +431,7 @@ bool CPluginManager::updateHeaders(bool force) {
// let us give a bit of leg-room for shallowing
// due to timezones, etc.
const std::string SHALLOW_DATE =
- removeBeginEndSpacesTabs(HLVER.date).empty() ? "" : execAndGet("LC_TIME=\"en_US.UTF-8\" date --date='" + HLVER.date + " - 1 weeks' '+\%a \%b \%d \%H:\%M:\%S \%Y'");
+ trim(HLVER.date).empty() ? "" : execAndGet("LC_TIME=\"en_US.UTF-8\" date --date='" + HLVER.date + " - 1 weeks' '+\%a \%b \%d \%H:\%M:\%S \%Y'");
if (m_bVerbose && bShallow)
progress.printMessageAbove(std::string{Colors::BLUE} + "[v] " + Colors::RESET + "will shallow since: " + SHALLOW_DATE);
diff --git a/hyprpm/src/meson.build b/hyprpm/src/meson.build
index a8644169..e2c512a5 100644
--- a/hyprpm/src/meson.build
+++ b/hyprpm/src/meson.build
@@ -3,6 +3,7 @@ src = globber.stdout().strip().split('\n')
executable('hyprpm', src,
dependencies: [
+ dependency('hyprutils', version: '>= 0.1.1'),
dependency('threads'),
dependency('tomlplusplus')
],