### CopyQ Directory Structure Example Source: https://github.com/hluk/copyq/wiki/How-to-build-CopyQ-on-Windows This example illustrates the expected file and directory layout for a CopyQ installation on Windows, including core executables, DLLs, and plugin subdirectories. ```text | copyq.com | copyq.exe | icudt51.dll | icuin51.dll | icuuc51.dll | libEGL.dll | libgcc_s_dw2-1.dll | libGLESv2.dll | libstdc++-6.dll | libwinpthread-1.dll | msvcp100.dll | msvcr100.dll | Qt5Core.dll | Qt5Gui.dll | Qt5Network.dll | Qt5Script.dll | Qt5Svg.dll | Qt5Widgets.dll | +---imageformats qgif.dll qico.dll qjpeg.dll qmng.dll qsvg.dll qtga.dll qtiff.dll +---platforms qminimal.dll qoffscreen.dll qwindows.dll +---plugins libitemdata.dll libitemencrypted.dll libitemfakevim.dll libitemimage.dll libitemnotes.dll libitemsync.dll libitemtext.dll libitemweb.dll \---themes dark.ini forest.ini paper.ini simple.ini solarized-dark.ini solarized-light.ini wine.ini ``` -------------------------------- ### Add Ubuntu PPA and Install CopyQ Source: https://github.com/hluk/copyq/blob/master/README.md Add the official CopyQ PPA to your system and install CopyQ and its plugins. This ensures you get the latest updates. ```bash sudo apt install software-properties-common python-software-properties ``` ```bash sudo add-apt-repository ppa:hluk/copyq ``` ```bash sudo apt update ``` ```bash sudo apt install copyq ``` -------------------------------- ### Install CopyQ using Scoop on Windows Source: https://github.com/hluk/copyq/blob/master/README.md Use Scoop to install CopyQ on Windows. Ensure Scoop is already installed. ```bash scoop install copyq ``` -------------------------------- ### Start CopyQ Server Source: https://github.com/hluk/copyq/blob/master/AGENTS.md Start the CopyQ server process. Ensure X11 or Wayland is set up correctly. ```bash build/copyq ``` -------------------------------- ### Install CopyQ Source: https://github.com/hluk/copyq/blob/master/AGENTS.md Install the CopyQ project using CMake. ```bash cmake -B build --target install ``` -------------------------------- ### Install Flatpak Runtimes and SDKs Source: https://github.com/hluk/copyq/blob/master/shared/flatpak/README.md Installs the required Freedesktop.org and KDE runtimes and SDKs for building the Flatpak. The `--user` flag installs them for the current user only. ```bash flatpak install --user flathub org.freedesktop.Platform//1.6 org.freedesktop.Sdk//1.6 flatpak remote-add --user --if-not-exists kdeapps --from https://distribute.kde.org/kdeapps.flatpakrepo flatpak install --user flathub org.kde.Platform//5.9 flatpak install --user flathub org.kde.Sdk//5.9 ``` -------------------------------- ### Build CopyQ with CMake Source: https://github.com/hluk/copyq/wiki/Development Configure and build the CopyQ application using CMake. This example demonstrates setting debug build type, installation prefix, and enabling Qt5 and tests. ```bash mkdir build cd build cmake \ -DCMAKE_BUILD_TYPE=Debug \ -DCMAKE_INSTALL_PREFIX=/usr/local \ -DWITH_QT5=ON \ -DWITH_TESTS=ON \ .. ``` -------------------------------- ### Install and Run CopyQ Flatpak Source: https://github.com/hluk/copyq/blob/master/shared/flatpak/README.md Adds the local repository containing the built CopyQ Flatpak and installs it. The `--no-gpg-verify` flag bypasses GPG signature verification for the local repository. Finally, it runs the installed CopyQ application. ```bash flatpak remote-add --user copyq repo --no-gpg-verify flatpak install --user --reinstall copyq com.github.hluk.copyq flatpak run com.github.hluk.copyq ``` -------------------------------- ### Start Default CopyQ Instance Source: https://github.com/hluk/copyq/blob/master/docs/sessions.md Run this command to start the default CopyQ instance, which uses an empty session name. ```bash copyq ``` -------------------------------- ### Get Path to Configuration File Source: https://github.com/hluk/copyq/blob/master/docs/scripting-api.md Example of using the info() function to retrieve the path to the configuration file. ```javascript info('config') ``` -------------------------------- ### Install CopyQ using Chocolatey on Windows Source: https://github.com/hluk/copyq/blob/master/README.md Use Chocolatey to install CopyQ on Windows. Ensure Chocolatey is already installed. ```bash choco install copyq ``` -------------------------------- ### Install Debian/Ubuntu Build Dependencies Source: https://github.com/hluk/copyq/blob/master/docs/build-source-code.md Installs all required packages for building CopyQ on Debian-based systems. ```bash sudo apt install \ build-essential \ cmake \ extra-cmake-modules \ git \ libminiaudio-dev \ libqt6svg6-dev \ libqt6waylandclient6 \ libwayland-dev \ libxfixes-dev \ libxtst-dev \ qt6-base-dev \ qt6-base-dev-tools \ qt6-base-private-dev \ qt6-declarative-dev \ qt6-l10n-tools \ qt6-tools-dev \ qt6-tools-dev-tools \ qt6-wayland \ qt6-wayland-dev \ qt6-wayland-dev-tools \ qtkeychain-qt6-dev ``` -------------------------------- ### Install CopyQ on Debian/Ubuntu Source: https://github.com/hluk/copyq/blob/master/docs/installation.md Install the stable version of CopyQ from official repositories on Debian and Ubuntu-based systems. ```bash sudo apt install copyq # copyq-plugins and copyq-doc is split out and can be installed independently ``` -------------------------------- ### Install Fedora/RHEL/CentOS Build Dependencies Source: https://github.com/hluk/copyq/blob/master/docs/build-source-code.md Installs all required packages for building CopyQ on Fedora-based systems. ```bash sudo dnf install \ cmake \ extra-cmake-modules \ gcc-c++ \ git \ kf6-kguiaddons-devel \ kf6-knotifications-devel \ kf6-kstatusnotifieritem-devel \ libSM-devel \ libXfixes-devel \ libXtst-devel \ miniaudio-devel \ qca-qt6-devel \ qca-qt6-ossl \ qt6-qtbase-devel \ qt6-qtbase-private-devel \ qt6-qtdeclarative-devel \ qt6-qtsvg-devel \ qt6-qttools-devel \ qt6-qtwayland-devel \ qtkeychain-qt6-devel \ wayland-devel ``` -------------------------------- ### Install CopyQ on Fedora Source: https://github.com/hluk/copyq/blob/master/docs/installation.md Install the CopyQ package on Fedora using the DNF package manager. ```bash sudo dnf install copyq ``` -------------------------------- ### onStart Source: https://github.com/hluk/copyq/blob/master/docs/scripting-api.md Callback function invoked when the application starts. ```APIDOC ## onStart() ### Description Called when application starts. ``` -------------------------------- ### Build and Install CopyQ Source: https://github.com/hluk/copyq/blob/master/docs/build-source-code.md Compiles and installs CopyQ from source using CMake and make. Optional flags can be used to disable specific features. ```bash cd CopyQ cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/usr/local . # Add -DWITH_QCA_ENCRYPTION=OFF for systems without `QCA` packages # Add -DWITH_NATIVE_NOTIFICATIONS=OFF for systems without `KF6` packages # Add -DWITH_AUDIO=OFF to disable audio support (or if miniaudio is unavailable) make make install ``` -------------------------------- ### Define Inno Setup Build Variables Source: https://github.com/hluk/copyq/wiki/Customize-and-build-the-Windows-installer Set these directives at the beginning of the Inno Setup script to define the application version, the source directory of the repository clone, and the destination directory for the portable application. ```innosetup #define AppVersion 2.8.1-beta #define Source C:\path\to\CopyQ-repository-clone #define Destination C:\path\to\CopyQ-portable ``` -------------------------------- ### Install Executable on Non-Windows Platforms Source: https://github.com/hluk/copyq/blob/master/src/CMakeLists.txt Installs the CopyQ executable on non-Windows platforms. It handles bundle installation for macOS and standard runtime installation for other Unix-like systems, placing the executable in 'bin'. ```cmake else() install(TARGETS ${COPYQ_EXECUTABLE_NAME} BUNDLE DESTINATION . COMPONENT Runtime RUNTIME DESTINATION bin COMPONENT Runtime ) ``` -------------------------------- ### Install Dependencies with Homebrew Source: https://github.com/hluk/copyq/blob/master/docs/build-source-code.md Installs necessary dependencies like Qt6 and CopyQ's specific KDE integrations using the Homebrew package manager. Ensure Homebrew is set up before running. ```bash brew install qt6 copyq/kde/kf6-knotifications copyq/kde/kf6-kstatusnotifieritem ``` -------------------------------- ### Install Weblate Client Source: https://github.com/hluk/copyq/blob/master/docs/translations.md Install the Weblate Client using pip. This tool helps manage translations and avoid merge conflicts. ```bash pip3 install -U --user wlc ``` -------------------------------- ### Install Executable on Windows Source: https://github.com/hluk/copyq/blob/master/src/CMakeLists.txt Installs the CopyQ executable, runtime components, and libraries to the specified destinations when building on Windows. It separates components into 'Runtime'. ```cmake if (WIN32) install(TARGETS ${COPYQ_EXECUTABLE_NAME} RUNTIME DESTINATION . COMPONENT Runtime LIBRARY DESTINATION . COMPONENT Runtime ) ``` -------------------------------- ### Setup X11 for CopyQ Tests Source: https://github.com/hluk/copyq/blob/master/AGENTS.md Set up Xvfb and openbox for running CopyQ tests. This requires a running X11 session. Ensure DISPLAY is exported correctly. ```bash Xvfb :99 -screen 0 1280x1024x24 & sleep 1 export DISPLAY=:99 openbox & sleep 1 ``` -------------------------------- ### Install Translation Files Source: https://github.com/hluk/copyq/blob/master/src/CMakeLists.txt Installs translation files (`.qm`) to a specified destination if the `TRANSLATION_INSTALL_PREFIX` variable is set. This ensures that translated user interfaces are available. ```cmake if (NOT APPLE) if (TRANSLATION_INSTALL_PREFIX) install(FILES ${copyq_QM} DESTINATION "${TRANSLATION_INSTALL_PREFIX}") endif() ``` -------------------------------- ### Install CopyQ with Homebrew on macOS Source: https://github.com/hluk/copyq/blob/master/docs/installation.md Use Homebrew to install the CopyQ application on macOS (version 13 and above). ```bash brew install --cask copyq ``` -------------------------------- ### Example Command Configuration Source: https://github.com/hluk/copyq/blob/master/docs/faq.md This INI-formatted code represents a command that can be imported into CopyQ to perform specific actions, such as toggling the main window. ```ini [Command] Name=Show/hide main window Command=copyq: toggle() Icon=\xf022 GlobalShortcut=ctrl+shift+1 ``` -------------------------------- ### Launch CopyQ Application Source: https://github.com/hluk/copyq/blob/master/README.md Starts the CopyQ application. This can be done by double-clicking the program icon or by running the command in a terminal. ```bash copyq ``` -------------------------------- ### Get Help for CopyQ Tests Source: https://github.com/hluk/copyq/wiki/Running-Tests Display additional help information and available options for the 'copyq tests' command. ```bash copyq tests --help ``` -------------------------------- ### Version Information and Platform-Specific Installation (Unix/macOS) Source: https://github.com/hluk/copyq/blob/master/CMakeLists.txt Includes version information and defines installation rules for various assets like icons, desktop files, man pages, and shell completion scripts on Unix-like systems and macOS. It also handles the installation of GNOME Shell extensions if enabled. ```cmake include(src/version.cmake) message(STATUS "Building CopyQ version ${copyq_version}.") if (UNIX AND NOT APPLE) install(FILES ${copyq_ICON_NORMAL} DESTINATION ${ICON_INSTALL_PREFIX} RENAME ${ICON_NAME}.svg) install(FILES ${copyq_ICON_MASK} DESTINATION ${ICON_INSTALL_PREFIX} RENAME ${ICON_NAME}_mask.svg) install(FILES ${copyq_APPDATA} DESTINATION ${APPDATA_INSTALL_PREFIX}) install(FILES ${copyq_MANPAGE} DESTINATION ${MANPAGE_INSTALL_PREFIX}) install(FILES ${copyq_BASH_COMPLETION} DESTINATION ${BASH_COMPLETION_INSTALL_PREFIX} RENAME copyq) if (WITH_GNOME_CLIPBOARD_EXTENSION) set(copyq_GNOME_EXTENSION_DESTINATION "${DATA_INSTALL_PREFIX}/gnome-shell/extensions/copyq-clipboard@hluk.github.com") install(FILES shared/gnome-extension/extension.js shared/gnome-extension/metadata.json DESTINATION "${copyq_GNOME_EXTENSION_DESTINATION}") endif() configure_file(${copyq_DESKTOP}.in ${copyq_DESKTOP}) install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${copyq_DESKTOP} DESTINATION ${DESKTOP_INSTALL_PREFIX}) foreach (copyq_ICON_EXTENT 16 22 24 32 48 64 128) set(copyq_ICON_SIZE "${copyq_ICON_EXTENT}x${copyq_ICON_EXTENT}") string(REPLACE "%SIZE%" "${copyq_ICON_SIZE}" copyq_ICON_TARGET_PREFIX "${ICON_INSTALL_PREFIX_TEMPLATE}") foreach (copyq_ICON_TYPE "") install(FILES "${copyq_ICON_PREFIX}${copyq_ICON_TYPE}_${copyq_ICON_SIZE}.png" DESTINATION "${copyq_ICON_TARGET_PREFIX}" RENAME "${ICON_NAME}${copyq_ICON_TYPE}.png") endforeach() endforeach() set(copyq_THEME_INSTALL_PREFIX ${THEME_INSTALL_PREFIX}) file(GLOB copyq_THEMES shared/themes/*.css shared/themes/*.ini) install(FILES ${copyq_THEMES} DESTINATION ${THEME_INSTALL_PREFIX}) add_definitions( -DCOPYQ_ICON_PREFIX="${ICON_INSTALL_PREFIX}/${ICON_NAME}" ) add_definitions( -DCOPYQ_THEME_PREFIX="${THEME_INSTALL_PREFIX}" ) add_definitions( -DCOPYQ_PLUGIN_PREFIX="${PLUGIN_INSTALL_PREFIX}" ) add_definitions( -DCOPYQ_DESKTOP_FILE="${DESKTOP_INSTALL_PREFIX}/${copyq_APP_ID}.desktop" ) add_definitions( -DCOPYQ_TRANSLATION_PREFIX="${TRANSLATION_INSTALL_PREFIX}" ) add_definitions( -DCOPYQ_BASH_COMPLETION_PREFIX="${BASH_COMPLETION_INSTALL_PREFIX}" ) add_definitions( -DCOPYQ_ICON_NAME="${ICON_NAME}" ) if (COPYQ_AUTOSTART) add_definitions( -DCOPYQ_AUTOSTART ) endif() if (COPYQ_AUTOSTART_COMMAND) add_definitions( -DCOPYQ_AUTOSTART_COMMAND="${COPYQ_AUTOSTART_COMMAND}" ) endif() elseif (APPLE) set(copyq_themes_dest_dir "${COPYQ_EXECUTABLE_NAME}.app/Contents/Resources/themes") file(GLOB copyq_THEMES shared/themes/*.css shared/themes/*.ini) install(FILES ${copyq_THEMES} DESTINATION "${copyq_themes_dest_dir}" COMPONENT Runtime) endif() ``` -------------------------------- ### provideClipboard Source: https://github.com/hluk/copyq/blob/master/docs/scripting-api.md Starts a process to provide data for the clipboard. The data can be set using setData(). Requires the script to be started with the --clipboard-access command line flag. ```APIDOC ## provideClipboard() ### Description Starts a process provides a data for clipboard. The data can be set using [`setData()`](#setData). The script must be started with `--clipboard-access` command line flag. ``` -------------------------------- ### monitorClipboard Source: https://github.com/hluk/copyq/blob/master/docs/scripting-api.md Starts a clipboard monitor process. Requires the script to be started with the --clipboard-access command line flag. ```APIDOC ## monitorClipboard() ### Description Starts a clipboard monitor process. The script must be started with `--clipboard-access` command line flag. ``` -------------------------------- ### CopyQ Scripting API Examples Source: https://github.com/hluk/copyq/blob/master/AGENTS.md Examples of using the CopyQ scripting API to manage tabs, items, and configuration. The `tab(...)` call is optional for default tab usage. ```javascript tab('TAB1'); add('ITEM') ``` ```javascript tab('TAB1'); size() ``` ```javascript tab('TAB1'); read(0,1,2) ``` ```javascript config() ``` ```javascript config('check_clipboard', 'false') ``` -------------------------------- ### Display Current Configuration Options Source: https://github.com/hluk/copyq/blob/master/CHANGES.md The `config()` script function now lists current values for each option. This output shows examples of configuration options and their descriptions. ```bash ... clipboard_notification_lines=3 Number of lines to show for new clipboard content. Set to 0 to disable. clipboard_tab=&clipboard Name of tab that will automatically store new clipboard content. Leave empty to disable automatic storing. close_on_unfocus=false Close main window when other application has focus ... ``` -------------------------------- ### Get All Commands Source: https://github.com/hluk/copyq/blob/master/docs/scripting-api.md Retrieves a list of all available commands in CopyQ. ```javascript commands() ``` -------------------------------- ### provideSelection Source: https://github.com/hluk/copyq/blob/master/docs/scripting-api.md Starts a process to provide data for the primary selection. The data can be set using setData(). Requires the script to be started with the --clipboard-access command line flag. ```APIDOC ## provideSelection() ### Description Starts a process that provides a data for [primary selection](). The data can be set using [`setData()`](#setData). The script must be started with `--clipboard-access` command line flag. ``` -------------------------------- ### Use CopyQ CLI commands on macOS Source: https://github.com/hluk/copyq/blob/master/docs/installation.md Examples of using the `copyq` command-line interface after enabling it on macOS. ```bash copyq --version ``` ```bash copyq clipboard ``` ```bash copyq size ``` -------------------------------- ### Get Application Version and Help Source: https://github.com/hluk/copyq/wiki/Development Retrieve application version or help information without requiring the server to be running. ```bash copyq help ``` ```bash copyq version ``` -------------------------------- ### Execute Commands and Get Output Source: https://github.com/hluk/copyq/wiki/Development Run commands in the current directory of the client process. Use 'execute().stdout' to get the standard output. ```bash copyq eval 'Dir().absolutePath()' ``` ```bash copyq eval 'execute("ls", "-l").stdout' ``` -------------------------------- ### Plugin Installation Configuration Source: https://github.com/hluk/copyq/blob/master/CMakeLists.txt Sets a global property for installed plugins and checks if plugins are enabled. This section likely prepares for or enables plugin management during the build process. ```cmake set_property(GLOBAL PROPERTY COPYQ_INSTALLED_PLUGINS) if (WITH_PLUGINS) ``` -------------------------------- ### Start CopyQ with a Specific Session Source: https://github.com/hluk/copyq/wiki/Advanced-Usage Run a new instance of CopyQ with a unique session name. This allows for isolated configurations, tabs, and clipboard items. ```bash copyq --session=test1 ``` -------------------------------- ### Get Application Configuration Options Source: https://github.com/hluk/copyq/blob/master/docs/scripting-api.md Retrieves a string containing a list of all available application options. These options can typically be modified through the CopyQ GUI. ```javascript config() ``` -------------------------------- ### Enable CopyQ CLI on macOS Source: https://github.com/hluk/copyq/blob/master/docs/installation.md Create a symbolic link to enable the `copyq` CLI command after installation via Homebrew on macOS. ```bash sudo ln -sf /Applications/CopyQ.app/Contents/MacOS/CopyQ /usr/local/bin/copyq ``` -------------------------------- ### Build CopyQ with CMake and CPack Source: https://github.com/hluk/copyq/blob/master/docs/build-source-code.md Configures, builds, and packages the CopyQ application using CMake and CPack. Assumes dependencies are installed and the source code is present. The CMake command sets the prefix path for Qt6. ```bash cmake -DCMAKE_PREFIX_PATH="$(brew --prefix qt6)" . cmake --build . cpack ``` -------------------------------- ### Get CopyQ Configuration Path Source: https://github.com/hluk/copyq/wiki/Backup Use this command to find the location of your CopyQ configuration directory, which is necessary for manual backups. ```bash copyq info config ``` -------------------------------- ### CopyQ Scripting API: Configuration Source: https://github.com/hluk/copyq/blob/master/CLAUDE.md Examples of using the CopyQ scripting API to view and modify configuration options. These scripts require the server to be running. ```javascript config() ``` ```javascript config('check_clipboard', 'false') ``` -------------------------------- ### Example Output of Tab Evaluation Source: https://github.com/hluk/copyq/blob/master/docs/command-line.md This shows the expected output when the 'Evaluate and Print All Items in Tab' command is executed. ```default This is the first note. This is second note. ``` -------------------------------- ### config() Source: https://github.com/hluk/copyq/blob/master/docs/scripting-api.md Returns a string containing help and a list of all available application options. ```APIDOC ## config() ### Description Returns help with list of available application options. These options can be changed via the CopyQ GUI and are persisted in the `copyq.ini` or `copyq.conf` file. ### Returns - A string listing available options. ``` -------------------------------- ### Perform Synchronous HTTP GET Request Source: https://github.com/hluk/copyq/blob/master/docs/scripting-api.md Sends an HTTP GET request and returns the reply. ```javascript networkGet(url) ``` -------------------------------- ### Connect with Custom Configuration Path Source: https://github.com/hluk/copyq/blob/master/docs/sessions.md Connect to CopyQ using a custom configuration path specified by the COPYQ_SETTINGS_PATH environment variable. Ensure the server is running. ```bash $ COPYQ_SETTINGS_PATH=$HOME/copyq-settings copyq tab &clipboard ``` -------------------------------- ### Install Additional Debian/Ubuntu QCA Packages Source: https://github.com/hluk/copyq/blob/master/docs/build-source-code.md Installs QCA packages required for tab encryption on newer Debian/Ubuntu versions. ```bash sudo apt install \ libqca-qt6-dev \ libqca-qt6-plugins ``` -------------------------------- ### Perform Asynchronous HTTP GET Request Source: https://github.com/hluk/copyq/blob/master/docs/scripting-api.md Sends an HTTP GET request asynchronously. The reply may not be immediately available. ```javascript networkGetAsync(url) ``` -------------------------------- ### Install Gpg4win on Windows Source: https://github.com/hluk/copyq/blob/master/docs/password-protection.md Use Chocolatey to install Gpg4win, a package that includes GnuPG for Windows. This is required for the legacy encryption plugin. ```bash choco install gpg4win ``` -------------------------------- ### Run CopyQ with Flatpak Source: https://github.com/hluk/copyq/blob/master/docs/installation.md Launch CopyQ using the Flatpak runtime environment on Linux distributions where Flatpak is configured. ```bash flatpak run com.github.hluk.copyq ``` -------------------------------- ### Create Build Directory Source: https://github.com/hluk/copyq/wiki/How-to-build-CopyQ-on-Windows Create a new directory for build artifacts and navigate into it. ```bash mkdir build && cd build ``` -------------------------------- ### Install Additional Debian/Ubuntu KF6 Packages Source: https://github.com/hluk/copyq/blob/master/docs/build-source-code.md Installs KF6 packages required for native notifications and Wayland clipboard support on newer Debian/Ubuntu versions. ```bash sudo apt install \ libkf6guiaddons-dev ``` -------------------------------- ### Build CopyQ Source: https://github.com/hluk/copyq/blob/master/AGENTS.md Build the CopyQ project using CMake and Ninja. ```bash cmake -B build --build ``` -------------------------------- ### Configure Visual Studio Project Source: https://github.com/hluk/copyq/blob/master/docs/build-source-code.md Generates a Visual Studio solution file for building CopyQ on Windows using CMake. ```bash cmake -G "Visual Studio 14 2015 Win64" . ``` -------------------------------- ### showAt() Source: https://github.com/hluk/copyq/blob/master/docs/scripting-api.md Displays the main CopyQ window under the mouse cursor. ```APIDOC ## / *cursor */ showAt() ### Description Shows main window under mouse cursor. The new window position will not be stored for `show()`. ``` -------------------------------- ### Read and Write INI Configuration Files with Settings Source: https://github.com/hluk/copyq/blob/master/docs/scripting-api.md Use the Settings class to manage INI configuration files. Call sync() to ensure changes are written immediately. ```javascript // Open INI file var configPath = Dir().homePath() + '/copyq.ini' var settings = new Settings(configPath) // Save an option settings.setValue('option1', 'test') // Store changes to the config file now instead of at the end of // executing the script settings.sync() // Read the option value var value = settings.value('option1') ``` -------------------------------- ### Environment Variables Source: https://github.com/hluk/copyq/blob/master/docs/scripting-api.md Functions for getting and setting environment variables. ```APIDOC ## env(name) ### Description Returns value of environment variable with given name. ### Returns: Value of the environment variable. ### Return type: [`ByteArray`](#ByteArray) ## setEnv(name, value) ### Description Sets environment variable with given name to given value. ### Returns: `true` if the variable was set, otherwise `false`. ### Return type: bool ``` -------------------------------- ### Build with Visual Studio Source: https://github.com/hluk/copyq/wiki/How-to-build-CopyQ-on-Windows Compile the project using MSBuild from the build directory. Ensure 'Visual Studio Command Prompt (2010)' is used. ```bash msbuild copyq.sln /p:Configuration=Release ``` -------------------------------- ### Get Environment Variable Source: https://github.com/hluk/copyq/blob/master/docs/scripting-api.md Retrieves the value of an environment variable by its name. ```javascript env(name) ``` -------------------------------- ### Display Help for Command Line Arguments Source: https://github.com/hluk/copyq/blob/master/README.md Prints help information for specific command-line arguments. Use this to understand available options for commands like 'add'. ```bash copyq --help ``` ```bash copyq --help add ``` -------------------------------- ### show() Source: https://github.com/hluk/copyq/blob/master/docs/scripting-api.md Displays the main CopyQ window. ```APIDOC ## show() ### Description Shows main window. This uses the last window position and size which is updated whenever the window is moved or resized. ``` -------------------------------- ### Get Current Path Source: https://github.com/hluk/copyq/blob/master/docs/scripting-api.md Retrieves the current working directory path. ```javascript currentPath() ``` -------------------------------- ### Get User-Defined Tags Source: https://github.com/hluk/copyq/blob/master/docs/scripting-api.md Retrieves a list of all user-defined tags available in the system. ```javascript var tags = plugins.itemtags.userTags ``` -------------------------------- ### Get Item Count Source: https://github.com/hluk/copyq/blob/master/docs/scripting-api.md Returns the total number of items in the current tab. ```javascript count() ``` ```javascript length() ``` ```javascript size() ``` -------------------------------- ### Run AppImage on Linux Source: https://github.com/hluk/copyq/blob/master/docs/installation.md Make the downloaded CopyQ AppImage executable and run it on Linux distributions. ```bash chmod +x CopyQ-*.AppImage ./CopyQ-*.AppImage ``` -------------------------------- ### Get Tab Names Source: https://github.com/hluk/copyq/blob/master/docs/scripting-api.md Retrieves an array of names for all existing tabs in CopyQ. ```javascript tab() ``` -------------------------------- ### help() Source: https://github.com/hluk/copyq/blob/master/docs/scripting-api.md Retrieves general help information. ```APIDOC ## help() ### Description Returns help string. ### Returns Help string. ### Return type string ``` -------------------------------- ### Network Operations Source: https://github.com/hluk/copyq/blob/master/docs/scripting-api.md Functions for sending HTTP GET and POST requests, both synchronously and asynchronously. ```APIDOC ## networkGet(url) ### Description Sends HTTP GET request. ### Returns: HTTP reply. ### Return type: [`NetworkReply`](#NetworkReply) ## networkPost(url, postData) ### Description Sends HTTP POST request. ### Returns: HTTP reply. ### Return type: [`NetworkReply`](#NetworkReply) ## networkGetAsync(url) ### Description Same as `networkGet()` but the request is asynchronous. The request is handled asynchronously and may not be finished until you get a property of the reply. ### Returns: HTTP reply. ### Return type: [`NetworkReply`](#NetworkReply) ## networkPostAsync(url, postData) ### Description Same as `networkPost()` but the request is asynchronous. The request is handled asynchronously and may not be finished until you get a property of the reply. ### Returns: HTTP reply. ### Return type: [`NetworkReply`](#NetworkReply) ``` -------------------------------- ### Get Available Screen Names Source: https://github.com/hluk/copyq/blob/master/docs/scripting-api.md Returns a list of names for all available screens on the system. ```javascript screenNames() ``` -------------------------------- ### Get All Custom Settings Source: https://github.com/hluk/copyq/blob/master/docs/scripting-api.md Retrieves an array of all available custom user option names. ```javascript settings() ``` -------------------------------- ### Get Default Configuration Path Source: https://github.com/hluk/copyq/blob/master/docs/sessions.md This command displays the current configuration path for CopyQ. ```bash $ copyq info config /home/user/.config/copyq/copyq.conf ``` -------------------------------- ### Icon and Theme Customization Source: https://github.com/hluk/copyq/blob/master/docs/scripting-api.md Functions for getting and setting icon colors, tags, and loading themes. ```APIDOC ## iconColor() ### Description Get current tray and window icon color name. ### Returns: Current icon color. ### Return type: string ## iconColor(colorName) ### Description Set current tray and window icon color name (examples: ‘orange’, ‘#ffa500’, ‘#09f’). Resets color if color name is empty string. ### Throws: `Error` – Thrown if the color name is empty or invalid. ### Example: ```js // Flash icon for few moments to get attention. var color = iconColor() for (var i = 0; i < 10; ++i) { iconColor("red") sleep(500) iconColor(color) sleep(500) } ``` #### SEE ALSO [`mimeColor`](#mimeColor) ## iconTag() ### Description Get current tray and window icon tag text. ### Returns: Current icon tag. ### Return type: string ## iconTag(tag) ### Description Set current tray and window tag text. ## iconTagColor() ### Description Get current tray and window tag color name. ### Returns: Current icon tag color. ### Return type: string ## iconTagColor(colorName) ### Description Set current tray and window tag color name. ### Throws: `Error` – Thrown if the color name is invalid. ## loadTheme(path) ### Description Loads theme from an INI file. ### Throws: `Error` – Thrown if the file cannot be read or is not valid INI format. ``` -------------------------------- ### Get Icon Tag Color Source: https://github.com/hluk/copyq/blob/master/docs/scripting-api.md Retrieves the current color name used for icon tags. ```javascript iconTagColor() ``` -------------------------------- ### Copy Configuration Path to Clipboard Source: https://github.com/hluk/copyq/blob/master/docs/backup.md Use this script in the Action dialog (F5) to copy the absolute path of the configuration directory to the clipboard. Ensure CopyQ is running. ```js copyq: dir = Dir(info('config') + '/..') copy(dir.absolutePath()) ``` -------------------------------- ### Get Icon Color Source: https://github.com/hluk/copyq/blob/master/docs/scripting-api.md Retrieves the current color name used for tray and window icons. ```javascript iconColor() ``` -------------------------------- ### Get Mouse Pointer Position Source: https://github.com/hluk/copyq/blob/master/docs/scripting-api.md Returns the current X and Y coordinates of the mouse pointer on the screen. ```javascript pointerPosition() ``` -------------------------------- ### Define and Use Script from File Source: https://github.com/hluk/copyq/blob/master/docs/scripting-api.md Demonstrates defining a function in a separate JavaScript file and then sourcing and executing it within CopyQ. This allows for modular script organization. ```javascript // File: c:/copyq/replace_clipboard_text.js replaceClipboardText = function(replaceWhat, replaceWith) { var text = str(clipboard()) var newText = text.replace(replaceWhat, replaceWith) if (text != newText) copy(newText) } ``` ```javascript source('c:/copyq/replace_clipboard_text.js') replaceClipboardText('secret', '*****') ``` -------------------------------- ### Get Item Separator Source: https://github.com/hluk/copyq/blob/master/docs/scripting-api.md Returns the current separator string used when concatenating item data. ```javascript separator() ``` -------------------------------- ### File() Source: https://github.com/hluk/copyq/blob/master/docs/scripting-api.md A wrapper class for Qt's QFile, providing methods to interact with files. Supports various opening modes like read-only, write-only, append, and read/write. Includes methods for reading all file content and writing data to a file, along with error handling. ```APIDOC ## *class* File() ### Description Wrapper for QFile Qt class. See [QFile](http://doc.qt.io/qt-6/qfile.html). To open file in different modes use: - open() - read/write - openReadOnly() - read only - openWriteOnly() - write only, truncates the file - openAppend() - write only, appends to the file ### Example: Reading a file ```js var f = new File('README.md') if (!f.openReadOnly()) throw 'Failed to open the file: ' + f.errorString() var bytes = f.readAll() ``` ### Example: Writing to a file ```js var dataToWrite = 'Hello, World!' var filePath = Dir().homePath() + '/copyq.txt' var f = new File(filePath) if (!f.openWriteOnly() || f.write(dataToWrite) == -1) throw 'Failed to save the file: ' + f.errorString() // Always flush the data and close the file, // before opening the file in other application. f.close() ``` ``` -------------------------------- ### Get Tab Icon Path Source: https://github.com/hluk/copyq/blob/master/docs/scripting-api.md Retrieves the file path of the icon associated with a specific tab. ```javascript tabIcon(tabName) ``` -------------------------------- ### Build with MinGW Source: https://github.com/hluk/copyq/wiki/How-to-build-CopyQ-on-Windows Compile the project using MinGW Makefiles from the build directory. ```bash mingw32-make ``` -------------------------------- ### Get Shortcut Information Source: https://github.com/hluk/copyq/blob/master/docs/scripting-api.md Retrieve the shortcut that activated the command using the application/x-copyq-shortcut mime type and display it. ```copyq-script copyq: var shortcut = data(mimeShortcut) popup("Shortcut Pressed", shortcut) ``` -------------------------------- ### Navigate to CopyQ Directory Source: https://github.com/hluk/copyq/wiki/How-to-build-CopyQ-on-Windows Change the current directory to the cloned CopyQ repository. ```bash cd CopyQ ``` -------------------------------- ### Add System Clipboard Static Library Source: https://github.com/hluk/copyq/blob/master/src/platform/x11/systemclipboard/CMakeLists.txt Creates a static library named 'systemclipboard' using the defined source files. ```cmake add_library(systemclipboard STATIC ${systemclipboard_SRCS}) ``` -------------------------------- ### Get Icon Tag Text Source: https://github.com/hluk/copyq/blob/master/docs/scripting-api.md Retrieves the current text tag associated with tray and window icons. ```javascript iconTag() ``` -------------------------------- ### Get Multiple User Inputs Source: https://github.com/hluk/copyq/blob/master/docs/scripting-api.md Collects multiple user inputs via a dialog and returns them as an object. ```javascript var result = dialog( 'Enter Amount', 'n/a', 'Choose File', new File(str(currentPath)) ) print('Amount: ' + result['Enter Amount'] + '\n') print('File: ' + result['Choose File'] + '\n') ``` -------------------------------- ### Get Standard Input Source: https://github.com/hluk/copyq/blob/master/docs/scripting-api.md Returns the data passed to the script via standard input as a ByteArray object. ```javascript input() ``` -------------------------------- ### Get Client Stdin in Script Source: https://github.com/hluk/copyq/wiki/Development Scripts can request standard input from the client using the 'input()' function. ```bash copyq eval 'var client_stdin = input()' ``` -------------------------------- ### Initialize Homebrew Tap for CopyQ Source: https://github.com/hluk/copyq/blob/master/docs/build-source-code.md Initializes and adds the CopyQ Homebrew tap for managing OS X specific build utilities. ```bash cd CopyQ git -C "utils/github/homebrew" init . git -C "utils/github/homebrew" add . git -C "utils/github/homebrew" commit -m "Initial" brew tap copyq/kde utils/github/homebrew/ ``` -------------------------------- ### Clone CopyQ Repository Source: https://github.com/hluk/copyq/wiki/How-to-build-CopyQ-on-Windows Clone the CopyQ repository to your local machine to begin the build process. ```bash git clone https://github.com/hluk/CopyQ.git ``` -------------------------------- ### Get Formatted Date String Source: https://github.com/hluk/copyq/blob/master/docs/scripting-api.md Returns the current date and time formatted according to the specified format string. ```javascript var now = dateString('yyyy-MM-dd HH:mm:ss') ``` -------------------------------- ### Call CopyQ from Python Source: https://github.com/hluk/copyq/wiki/Writing-Commands-and-Adding-Functionality Demonstrates how to invoke CopyQ commands from a Python script using the subprocess module. Ensure the COPYQ environment variable is set to the application binary path. ```python python: import os from subprocess import call copyq = os.environ['COPYQ'] call([copyq, 'read', '0']) ``` -------------------------------- ### Basic Scripting Functions Source: https://github.com/hluk/copyq/wiki/Scripting Demonstrates the availability of common command-line options as scripting functions. ```javascript show() hide() toggle() copy() paste() ``` -------------------------------- ### help(searchString, ...) Source: https://github.com/hluk/copyq/blob/master/docs/scripting-api.md Retrieves help information for matched commands. ```APIDOC ## / *search */ help(searchString, ...) ### Description Returns help for matched commands. ### Returns Help string. ### Return type string ``` -------------------------------- ### playSound(fileOrObject) Source: https://github.com/hluk/copyq/blob/master/docs/scripting-api.md Plays an audio file, supporting WAV, MP3, and FLAC formats. Playback starts immediately. ```APIDOC ## playSound(fileOrObject) ### Description Plays audio file. The argument can be a file path string or an object with `file` and optional `volume` properties. Supports WAV, MP3 and FLAC formats. The function starts playback and returns immediately. An exception is thrown if the file doesn’t exist or cannot be played. ### Arguments * **fileOrObject** (`string or object`) – Path to the audio file, or an object `{file: 'path', volume: 50}`. The `volume` property is a percentage (default `100`). Values above `100` amplify the sound; the maximum is `200`. ### Example — play a notification sound: ```js playSound('/path/to/notification.wav') ``` ### Example — play at 50% volume: ```js playSound({file: '/path/to/notification.wav', volume: 50}) ``` ``` -------------------------------- ### Help Information Source: https://github.com/hluk/copyq/blob/master/docs/scripting-api.md Retrieves general help strings or specific help for matched commands. ```javascript help() ``` ```javascript help(searchString, ...) ```