mirror of
https://github.com/hyprwm/xdg-desktop-portal-hyprland.git
synced 2024-11-22 06:35:57 +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(ID.find_last_of('(') + 1);
|
||||||
ID = ID.substr(0, ID.find_last_of(')'));
|
ID = ID.substr(0, ID.find_last_of(')'));
|
||||||
|
|
||||||
|
std::cout << "[SELECTION]";
|
||||||
std::cout << (ALLOWTOKENBUTTON->isChecked() ? "r" : "");
|
std::cout << (ALLOWTOKENBUTTON->isChecked() ? "r" : "");
|
||||||
std::cout << "/";
|
std::cout << "/";
|
||||||
|
|
||||||
|
@ -141,6 +142,7 @@ int main(int argc, char* argv[]) {
|
||||||
mainPickerPtr->windowIDs[button] = window.id;
|
mainPickerPtr->windowIDs[button] = window.id;
|
||||||
|
|
||||||
QObject::connect(button, &QPushButton::clicked, [=]() {
|
QObject::connect(button, &QPushButton::clicked, [=]() {
|
||||||
|
std::cout << "[SELECTION]";
|
||||||
std::cout << (ALLOWTOKENBUTTON->isChecked() ? "r" : "");
|
std::cout << (ALLOWTOKENBUTTON->isChecked() ? "r" : "");
|
||||||
std::cout << "/";
|
std::cout << "/";
|
||||||
|
|
||||||
|
@ -199,6 +201,7 @@ int main(int argc, char* argv[]) {
|
||||||
REGION = REGION.substr(REGION.find_first_of(' ') + 1);
|
REGION = REGION.substr(REGION.find_first_of(' ') + 1);
|
||||||
const auto H = std::stoi(REGION);
|
const auto H = std::stoi(REGION);
|
||||||
|
|
||||||
|
std::cout << "[SELECTION]";
|
||||||
std::cout << (ALLOWTOKENBUTTON->isChecked() ? "r" : "");
|
std::cout << (ALLOWTOKENBUTTON->isChecked() ? "r" : "");
|
||||||
std::cout << "/";
|
std::cout << "/";
|
||||||
|
|
||||||
|
|
|
@ -3,6 +3,8 @@
|
||||||
#include "../helpers/Log.hpp"
|
#include "../helpers/Log.hpp"
|
||||||
|
|
||||||
std::string execAndGet(const char* cmd) {
|
std::string execAndGet(const char* cmd) {
|
||||||
|
Debug::log(LOG, "execAndGet: {}", cmd);
|
||||||
|
|
||||||
std::array<char, 128> buffer;
|
std::array<char, 128> buffer;
|
||||||
std::string result;
|
std::string result;
|
||||||
const std::unique_ptr<FILE, decltype(&pclose)> pipe(popen(cmd, "r"), pclose);
|
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();
|
result += buffer.data();
|
||||||
}
|
}
|
||||||
return result;
|
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
|
#pragma once
|
||||||
#include <string>
|
#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");
|
const char* HYPRLAND_INSTANCE_SIGNATURE = getenv("HYPRLAND_INSTANCE_SIGNATURE");
|
||||||
|
|
||||||
std::string cmd =
|
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());
|
WAYLAND_DISPLAY ? WAYLAND_DISPLAY : "", XCURSOR_SIZE ? XCURSOR_SIZE : "24", HYPRLAND_INSTANCE_SIGNATURE ? HYPRLAND_INSTANCE_SIGNATURE : "0", buildWindowList());
|
||||||
|
|
||||||
const auto RETVAL = execAndGet(cmd.c_str());
|
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('/'));
|
if (RETVAL.contains("qt.qpa.plugin: Could not find the Qt platform plugin")) {
|
||||||
const auto SEL = RETVAL.substr(RETVAL.find_first_of('/') + 1);
|
// 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) {
|
for (auto& flag : FLAGS) {
|
||||||
if (flag == 'r') {
|
if (flag == 'r') {
|
||||||
|
|
Loading…
Reference in a new issue