mirror of
https://github.com/hyprwm/xdg-desktop-portal-hyprland.git
synced 2024-12-22 17:59:47 +01:00
parent
aca51609d4
commit
9dfb9e125b
4 changed files with 31 additions and 5 deletions
|
@ -114,6 +114,7 @@ int main(int argc, char* argv[]) {
|
|||
ID = ID.substr(ID.find_last_of('(') + 1);
|
||||
ID = ID.substr(0, ID.find_last_of(')'));
|
||||
|
||||
std::cout << "[SELECTION]";
|
||||
std::cout << (ALLOWTOKENBUTTON->isChecked() ? "r" : "");
|
||||
std::cout << "/";
|
||||
|
||||
|
@ -141,6 +142,7 @@ int main(int argc, char* argv[]) {
|
|||
mainPickerPtr->windowIDs[button] = window.id;
|
||||
|
||||
QObject::connect(button, &QPushButton::clicked, [=]() {
|
||||
std::cout << "[SELECTION]";
|
||||
std::cout << (ALLOWTOKENBUTTON->isChecked() ? "r" : "");
|
||||
std::cout << "/";
|
||||
|
||||
|
@ -199,6 +201,7 @@ int main(int argc, char* argv[]) {
|
|||
REGION = REGION.substr(REGION.find_first_of(' ') + 1);
|
||||
const auto H = std::stoi(REGION);
|
||||
|
||||
std::cout << "[SELECTION]";
|
||||
std::cout << (ALLOWTOKENBUTTON->isChecked() ? "r" : "");
|
||||
std::cout << "/";
|
||||
|
||||
|
|
|
@ -3,6 +3,8 @@
|
|||
#include "../helpers/Log.hpp"
|
||||
|
||||
std::string execAndGet(const char* cmd) {
|
||||
Debug::log(LOG, "execAndGet: {}", cmd);
|
||||
|
||||
std::array<char, 128> buffer;
|
||||
std::string result;
|
||||
const std::unique_ptr<FILE, decltype(&pclose)> pipe(popen(cmd, "r"), pclose);
|
||||
|
@ -14,4 +16,11 @@ std::string execAndGet(const char* cmd) {
|
|||
result += buffer.data();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
void addHyprlandNotification(const std::string& icon, float timeMs, const std::string& color, const std::string& message) {
|
||||
const std::string CMD = std::format("hyprctl notify {} {} {} \"{}\"", icon, timeMs, color, message);
|
||||
Debug::log(LOG, "addHyprlandNotification: {}", CMD);
|
||||
if (fork() == 0)
|
||||
execl("/bin/sh", "/bin/sh", "-c", CMD.c_str(), nullptr);
|
||||
}
|
|
@ -1,4 +1,5 @@
|
|||
#pragma once
|
||||
#include <string>
|
||||
|
||||
std::string execAndGet(const char* cmd);
|
||||
std::string execAndGet(const char* cmd);
|
||||
void addHyprlandNotification(const std::string& icon, float timeMs, const std::string& color, const std::string& message);
|
|
@ -42,15 +42,28 @@ SSelectionData promptForScreencopySelection() {
|
|||
const char* HYPRLAND_INSTANCE_SIGNATURE = getenv("HYPRLAND_INSTANCE_SIGNATURE");
|
||||
|
||||
std::string cmd =
|
||||
std::format("WAYLAND_DISPLAY={} QT_QPA_PLATFORM=\"wayland\" XCURSOR_SIZE={} HYPRLAND_INSTANCE_SIGNATURE={} XDPH_WINDOW_SHARING_LIST=\"{}\" hyprland-share-picker",
|
||||
std::format("WAYLAND_DISPLAY={} QT_QPA_PLATFORM=\"wayland\" XCURSOR_SIZE={} HYPRLAND_INSTANCE_SIGNATURE={} XDPH_WINDOW_SHARING_LIST=\"{}\" hyprland-share-picker 2>&1",
|
||||
WAYLAND_DISPLAY ? WAYLAND_DISPLAY : "", XCURSOR_SIZE ? XCURSOR_SIZE : "24", HYPRLAND_INSTANCE_SIGNATURE ? HYPRLAND_INSTANCE_SIGNATURE : "0", buildWindowList());
|
||||
|
||||
const auto RETVAL = execAndGet(cmd.c_str());
|
||||
|
||||
Debug::log(LOG, "[sc] Selection: {}", RETVAL);
|
||||
if (!RETVAL.contains("[SELECTION]")) {
|
||||
// failed
|
||||
|
||||
const auto FLAGS = RETVAL.substr(0, RETVAL.find_first_of('/'));
|
||||
const auto SEL = RETVAL.substr(RETVAL.find_first_of('/') + 1);
|
||||
if (RETVAL.contains("qt.qpa.plugin: Could not find the Qt platform plugin")) {
|
||||
// prompt the user to install qt5-wayland and qt6-wayland
|
||||
addHyprlandNotification("3", 7000, "0", "[xdph] Could not open the picker: qt5-wayland or qt6-wayland doesn't seem to be installed.");
|
||||
}
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
const auto SELECTION = RETVAL.substr(RETVAL.find("[SELECTION]") + 11);
|
||||
|
||||
Debug::log(LOG, "[sc] Selection: {}", SELECTION);
|
||||
|
||||
const auto FLAGS = SELECTION.substr(0, SELECTION.find_first_of('/'));
|
||||
const auto SEL = SELECTION.substr(SELECTION.find_first_of('/') + 1);
|
||||
|
||||
for (auto& flag : FLAGS) {
|
||||
if (flag == 'r') {
|
||||
|
|
Loading…
Reference in a new issue