config: add a config with hyprlang

This commit is contained in:
Vaxry 2024-01-03 12:59:40 +01:00
parent 54a30259be
commit c5b69eb5b5
3 changed files with 29 additions and 2 deletions

View File

@ -36,7 +36,7 @@ add_subdirectory(hyprland-share-picker)
find_package(Threads REQUIRED)
find_package(PkgConfig REQUIRED)
pkg_check_modules(deps REQUIRED IMPORTED_TARGET wayland-client wayland-protocols libpipewire-0.3 libspa-0.2 libdrm gbm)
pkg_check_modules(deps REQUIRED IMPORTED_TARGET wayland-client wayland-protocols libpipewire-0.3 libspa-0.2 libdrm gbm hyprlang>=0.2.0)
file(GLOB_RECURSE SRCFILES CONFIGURE_DEPENDS "src/*.cpp")
add_executable(xdg-desktop-portal-hyprland ${SRCFILES})

View File

@ -198,6 +198,25 @@ inline const zwp_linux_dmabuf_feedback_v1_listener dmabufFeedbackListener = {
//
CPortalManager::CPortalManager() {
const auto XDG_CONFIG_HOME = getenv("XDG_CONFIG_HOME");
const auto HOME = getenv("HOME");
if (!HOME && !XDG_CONFIG_HOME) {
Debug::log(CRIT, "Cannot proceed: neither $HOME nor $XDG_CONFIG_HOME is present in env");
throw "$HOME and $XDG_CONFIG_HOME both missing from env";
}
std::string path = XDG_CONFIG_HOME ? std::string{XDG_CONFIG_HOME} + "/hypr/xdph.conf" : std::string{HOME} + "/.config/hypr/xdph.conf";
m_sConfig.config = std::make_unique<Hyprlang::CConfig>(path, Hyprlang::SConfigOptions{.allowMissingConfig = true});
m_sConfig.config->addConfigValue("general:toplevel_dynamic_bind", {0L});
m_sConfig.config->commence();
m_sConfig.config->parse();
}
void CPortalManager::onGlobal(void* data, struct wl_registry* registry, uint32_t name, const char* interface, uint32_t version) {
const std::string INTERFACE = interface;
@ -238,7 +257,8 @@ void CPortalManager::onGlobal(void* data, struct wl_registry* registry, uint32_t
m_sHelpers.toplevel = std::make_unique<CToplevelManager>(registry, name, version);
// remove when another fix is found for https://github.com/hyprwm/xdg-desktop-portal-hyprland/issues/147
m_sHelpers.toplevel->activate();
if (!std::any_cast<Hyprlang::INT>(m_sConfig.config->getConfigValue("general:toplevel_dynamic_bind")))
m_sHelpers.toplevel->activate();
}
}

View File

@ -3,6 +3,7 @@
#include <memory>
#include <sdbus-c++/sdbus-c++.h>
#include <wayland-client.h>
#include <hyprlang.hpp>
#include "../portals/Screencopy.hpp"
#include "../portals/Screenshot.hpp"
@ -30,6 +31,8 @@ struct SDMABUFModifier {
class CPortalManager {
public:
CPortalManager();
void init();
void onGlobal(void* data, struct wl_registry* registry, uint32_t name, const char* interface, uint32_t version);
@ -67,6 +70,10 @@ class CPortalManager {
} dma;
} m_sWaylandConnection;
struct {
std::unique_ptr<Hyprlang::CConfig> config;
} m_sConfig;
std::vector<SDMABUFModifier> m_vDMABUFMods;
void addTimer(const CTimer& timer);