Improve clipboard guidance for KDE users
Some checks failed
Release App / release-app (push) Has been cancelled

This commit is contained in:
2026-04-24 15:17:38 +03:00
parent 9aa45d2b09
commit 53094ec472
3 changed files with 40 additions and 2 deletions

View File

@@ -6,6 +6,8 @@ arch=('x86_64')
url='https://git.mshq.dev/AxiFisk/shinoa'
license=('custom:unknown')
depends=('gcc-libs' 'glibc' 'ncurses' 'openssl' 'zlib')
optdepends=('wl-clipboard: clipboard image paste on Wayland/Plasma'
'xclip: clipboard image paste on X11')
options=(!debug)
provides=('shinoa')
conflicts=('shinoa')

View File

@@ -50,6 +50,12 @@ Or start the app without env vars and enter them interactively when prompted.
When entered in the TUI, the app now stores `api_id` and `api_hash` in
`~/.local/share/telegram-tui/config.json` and reuses them on later launches.
Clipboard image sending via `>paste` or `>clip` requires an external clipboard tool:
- `wl-clipboard` on Wayland or KDE Plasma Wayland
- `xclip` on X11
Klipper by itself is not a supported image backend for this feature.
To use Telegram test servers instead of production:
```bash

View File

@@ -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;
}