Improve clipboard guidance for KDE users
Some checks failed
Release App / release-app (push) Has been cancelled
Some checks failed
Release App / release-app (push) Has been cancelled
This commit is contained in:
@@ -65,6 +65,36 @@ bool command_exists(const char *command) {
|
||||
return !trim_copy(resolved).empty();
|
||||
}
|
||||
|
||||
bool is_wayland_session() {
|
||||
return get_env("XDG_SESSION_TYPE") == "wayland";
|
||||
}
|
||||
|
||||
bool is_kde_session() {
|
||||
const std::string current_desktop = get_env("XDG_CURRENT_DESKTOP");
|
||||
const std::string session_desktop = get_env("XDG_SESSION_DESKTOP");
|
||||
return current_desktop.find("KDE") != std::string::npos ||
|
||||
current_desktop.find("PLASMA") != std::string::npos ||
|
||||
session_desktop.find("kde") != std::string::npos ||
|
||||
session_desktop.find("plasma") != std::string::npos;
|
||||
}
|
||||
|
||||
std::string missing_clipboard_tool_hint() {
|
||||
if (command_exists("wl-paste") || command_exists("xclip") || command_exists("pngpaste")) {
|
||||
return {};
|
||||
}
|
||||
|
||||
if (is_wayland_session()) {
|
||||
if (is_kde_session()) {
|
||||
return " Install wl-clipboard. Klipper alone is not enough.";
|
||||
}
|
||||
return " Install wl-clipboard.";
|
||||
}
|
||||
if (is_kde_session()) {
|
||||
return " Install xclip or wl-clipboard. Klipper alone is not enough.";
|
||||
}
|
||||
return " Install wl-clipboard or xclip.";
|
||||
}
|
||||
|
||||
std::string clipboard_capture_command(const std::string &mime_type,
|
||||
const std::string &destination_path) {
|
||||
if (command_exists("wl-paste")) {
|
||||
@@ -580,8 +610,8 @@ bool App::preview_clipboard_photo_message(std::int64_t chat_id, const std::strin
|
||||
std::optional<std::int64_t> reply_to_message_id) {
|
||||
const auto clipboard_type = detect_clipboard_image_type();
|
||||
if (!clipboard_type.has_value()) {
|
||||
status_line_ =
|
||||
"Clipboard doesn't contain an image, or no clipboard tool is available.";
|
||||
status_line_ = "Clipboard doesn't contain an image, or no clipboard tool is available." +
|
||||
missing_clipboard_tool_hint();
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user