diff --git a/PKGBUILD b/PKGBUILD index b77b4d4..537c563 100644 --- a/PKGBUILD +++ b/PKGBUILD @@ -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') diff --git a/README.md b/README.md index f74763b..e12c810 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/src/app_auth.cpp b/src/app_auth.cpp index 43b4e72..e5cbd42 100644 --- a/src/app_auth.cpp +++ b/src/app_auth.cpp @@ -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 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; }