NAME
    Clipboard::Any - Common interface to clipboard manager functions

VERSION
    This document describes version 0.012 of Clipboard::Any (from Perl
    distribution Clipboard-Any), released on 2024-08-30.

DESCRIPTION
    This module provides a common interface to interact with clipboard.

    Some terminology:

    *   clipboard content

        The current clipboard content. Some clipboard manager supports
        storing multiple items (multiple contents). All the items are called
        "clipboard history".

    *   clipboard history

        Some clipboard manager supports storing multiple items (multiple
        contents). All the items are called clipboard history. It is
        presented as an array. The current item/content is at index 0, the
        secondmost current item is at index 1, and so on.

  Supported clipboard managers
   Klipper
    The default clipboard manager on KDE Plasma.

   clipit
   parcellite
   xclip
    This is not a "real" clipboard manager, but just an interface to the X
    selections. With "xclip", the history is viewed as having two items. The
    first/recent is the primary selection and the second one is the
    secondary.

    This module provides common functions related to clipboard manager.

    Supported clipboard manager: KDE Plasma's Klipper ("klipper"),
    "parcellite", "clipit", "xclip". Support for more clipboard managers,
    e.g. on Windows or other Linux desktop environment is welcome.

NOTES
    2021-07-15 - Tested on my system (KDE Plasma 5.12.9 on Linux).

FUNCTIONS
  add_clipboard_content
    Usage:

     add_clipboard_content(%args) -> [$status_code, $reason, $payload, \%result_meta]

    Add a new content to the clipboard.

    For "xclip": when adding content, the primary selection is set. The
    clipboard content is unchanged.

    This function is not exported by default, but exportable.

    Arguments ('*' denotes required arguments):

    *   clipboard_manager => *str*

        Explicitly set clipboard manager to use.

        The default, when left undef, is to detect what clipboard manager is
        running.

    *   content => *str*

        (No description)

    *   tee => *bool*

        If set to true, will output content back to STDOUT.

    Returns an enveloped result (an array).

    First element ($status_code) is an integer containing HTTP-like status
    code (200 means OK, 4xx caller error, 5xx function error). Second
    element ($reason) is a string containing error message, or something
    like "OK" if status is 200. Third element ($payload) is the actual
    result, but usually not present when enveloped result is an error
    response ($status_code is not 2xx). Fourth element (%result_meta) is
    called result metadata and is optional, a hash that contains extra
    information, much like how HTTP response headers provide additional
    metadata.

    Return value: (any)

  clear_clipboard_content
    Usage:

     clear_clipboard_content(%args) -> [$status_code, $reason, $payload, \%result_meta]

    Delete current clipboard content.

    This function is not exported by default, but exportable.

    Arguments ('*' denotes required arguments):

    *   clipboard_manager => *str*

        Explicitly set clipboard manager to use.

        The default, when left undef, is to detect what clipboard manager is
        running.

    Returns an enveloped result (an array).

    First element ($status_code) is an integer containing HTTP-like status
    code (200 means OK, 4xx caller error, 5xx function error). Second
    element ($reason) is a string containing error message, or something
    like "OK" if status is 200. Third element ($payload) is the actual
    result, but usually not present when enveloped result is an error
    response ($status_code is not 2xx). Fourth element (%result_meta) is
    called result metadata and is optional, a hash that contains extra
    information, much like how HTTP response headers provide additional
    metadata.

    Return value: (any)

  clear_clipboard_history
    Usage:

     clear_clipboard_history(%args) -> [$status_code, $reason, $payload, \%result_meta]

    Delete all clipboard items.

    This function is not exported by default, but exportable.

    Arguments ('*' denotes required arguments):

    *   clipboard_manager => *str*

        Explicitly set clipboard manager to use.

        The default, when left undef, is to detect what clipboard manager is
        running.

    Returns an enveloped result (an array).

    First element ($status_code) is an integer containing HTTP-like status
    code (200 means OK, 4xx caller error, 5xx function error). Second
    element ($reason) is a string containing error message, or something
    like "OK" if status is 200. Third element ($payload) is the actual
    result, but usually not present when enveloped result is an error
    response ($status_code is not 2xx). Fourth element (%result_meta) is
    called result metadata and is optional, a hash that contains extra
    information, much like how HTTP response headers provide additional
    metadata.

    Return value: (any)

  detect_clipboard_manager
    Usage:

     detect_clipboard_manager() -> str

    Detect which clipboard manager program is currently running.

    Will return a string containing name of clipboard manager program, e.g.
    "klipper". Will return undef if no known clipboard manager is detected.

    This function is not exported by default, but exportable.

    No arguments.

    Return value: (str)

  get_clipboard_content
    Usage:

     get_clipboard_content(%args) -> [$status_code, $reason, $payload, \%result_meta]

    Get the clipboard content (most recent, history index [0]).

    Caveats for klipper: Non-text item is not retrievable by
    getClipboardContents(). If the current item is e.g. an image, then the
    next text item from history will be returned instead, or empty string if
    none exists.

    This function is not exported by default, but exportable.

    Arguments ('*' denotes required arguments):

    *   clipboard_manager => *str*

        Explicitly set clipboard manager to use.

        The default, when left undef, is to detect what clipboard manager is
        running.

    Returns an enveloped result (an array).

    First element ($status_code) is an integer containing HTTP-like status
    code (200 means OK, 4xx caller error, 5xx function error). Second
    element ($reason) is a string containing error message, or something
    like "OK" if status is 200. Third element ($payload) is the actual
    result, but usually not present when enveloped result is an error
    response ($status_code is not 2xx). Fourth element (%result_meta) is
    called result metadata and is optional, a hash that contains extra
    information, much like how HTTP response headers provide additional
    metadata.

    Return value: (any)

  get_clipboard_history_item
    Usage:

     get_clipboard_history_item(%args) -> [$status_code, $reason, $payload, \%result_meta]

    Get a clipboard history item.

    This function is not exported by default, but exportable.

    Arguments ('*' denotes required arguments):

    *   clipboard_manager => *str*

        Explicitly set clipboard manager to use.

        The default, when left undef, is to detect what clipboard manager is
        running.

    *   index => *int*

        Index of item in history (0 means the current/latest, 1 the second
        latest, and so on).

        If the index exceeds the number of items in history, empty string or
        undef will be returned instead.

    Returns an enveloped result (an array).

    First element ($status_code) is an integer containing HTTP-like status
    code (200 means OK, 4xx caller error, 5xx function error). Second
    element ($reason) is a string containing error message, or something
    like "OK" if status is 200. Third element ($payload) is the actual
    result, but usually not present when enveloped result is an error
    response ($status_code is not 2xx). Fourth element (%result_meta) is
    called result metadata and is optional, a hash that contains extra
    information, much like how HTTP response headers provide additional
    metadata.

    Return value: (any)

  list_clipboard_history
    Usage:

     list_clipboard_history(%args) -> [$status_code, $reason, $payload, \%result_meta]

    List the clipboard history.

    Caveats for klipper: 1) Klipper does not provide method to get the
    length of history. So we retrieve history item one by one using
    getClipboardHistoryItem(i) from i=0, i=1, and so on. And assume that if
    we get two consecutive empty string, it means we reach the end of the
    clipboard history before the first empty result.

    2) Non-text items are not retrievable by getClipboardHistoryItem().

    This function is not exported by default, but exportable.

    Arguments ('*' denotes required arguments):

    *   clipboard_manager => *str*

        Explicitly set clipboard manager to use.

        The default, when left undef, is to detect what clipboard manager is
        running.

    Returns an enveloped result (an array).

    First element ($status_code) is an integer containing HTTP-like status
    code (200 means OK, 4xx caller error, 5xx function error). Second
    element ($reason) is a string containing error message, or something
    like "OK" if status is 200. Third element ($payload) is the actual
    result, but usually not present when enveloped result is an error
    response ($status_code is not 2xx). Fourth element (%result_meta) is
    called result metadata and is optional, a hash that contains extra
    information, much like how HTTP response headers provide additional
    metadata.

    Return value: (any)

HOMEPAGE
    Please visit the project's homepage at
    <https://metacpan.org/release/Clipboard-Any>.

SOURCE
    Source repository is at
    <https://github.com/perlancar/perl-Clipboard-Any>.

AUTHOR
    perlancar <perlancar@cpan.org>

CONTRIBUTING
    To contribute, you can send patches by email/via RT, or send pull
    requests on GitHub.

    Most of the time, you don't need to build the distribution yourself. You
    can simply modify the code, then test via:

     % prove -l

    If you want to build the distribution (e.g. to try to install it locally
    on your system), you can install Dist::Zilla,
    Dist::Zilla::PluginBundle::Author::PERLANCAR,
    Pod::Weaver::PluginBundle::Author::PERLANCAR, and sometimes one or two
    other Dist::Zilla- and/or Pod::Weaver plugins. Any additional steps
    required beyond that are considered a bug and can be reported to me.

COPYRIGHT AND LICENSE
    This software is copyright (c) 2024, 2023, 2022 by perlancar
    <perlancar@cpan.org>.

    This is free software; you can redistribute it and/or modify it under
    the same terms as the Perl 5 programming language system itself.

BUGS
    Please report any bugs or feature requests on the bugtracker website
    <https://rt.cpan.org/Public/Dist/Display.html?Name=Clipboard-Any>

    When submitting a bug or request, please include a test-file or a patch
    to an existing test-file that illustrates the bug or desired feature.