helic: Clipboard Manager

[ clipboard, library, program ] [ Propose Tags ]
Versions [RSS] 0.1.0.0, 0.1.1.0, 0.2.0.0, 0.3.0.0, 0.3.1.0, 0.3.2.0, 0.4.0.0, 0.5.0.0, 0.5.1.0, 0.5.2.0, 0.5.3.0, 0.6.0.0, 0.6.1.0
Change log changelog.md
Dependencies aeson (>=1.4), base (>=4 && <5), chronos (>=1.1.1), containers, data-default (>=0.2), either (>=5), exon (>=0.2.0.1), gi-gdk (>=3), gi-gtk (>=3), helic, hostname (>=1), http-client (>=0.5.14), http-client-tls (>=0.3.1), optparse-applicative (>=0.16), path, path-io, polysemy (>=1.6), polysemy-chronos (>=0.2.0.1), polysemy-conc (>=0.5), polysemy-http (>=0.5), polysemy-log (>=0.4), polysemy-plugin (>=0.4), polysemy-process (>=0.5), polysemy-resume (>=0.2), polysemy-time (>=0.1.4), relude (>=0.7), servant (>=0.18), servant-client (>=0.18), servant-client-core (>=0.18), servant-server (>=0.18), template-haskell, text, typed-process (>=0.2.6), unix, wai (>=3.2), wai-extra (>=3.1), warp (>=3.3), yaml (>=0.11) [details]
License BSD-2-Clause-Patent
Copyright 2021 Torsten Schmits
Author Torsten Schmits
Maintainer hackage@tryp.io
Revised Revision 1 made by tek at 2021-12-19T01:41:28Z
Category Clipboard
Home page https://github.com/tek/helic#readme
Bug tracker https://github.com/tek/helic/issues
Uploaded by tek at 2021-12-19T01:35:49Z
Distributions
Executables hel
Downloads 691 total (28 in the last 30 days)
Rating 2.0 (votes: 1) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Docs uploaded by user
Build status unknown [no reports yet]

Readme for helic-0.1.0.0

[back to package description]

About

Helic is a tool for synchronizing clipboard contents across X11, tmux and network, consisting of a daemon listening for changes and a CLI client for use in programs like Neovim.

When some text is copied or selected in X11, the daemon receives an event that it proceeds to broadcast to the configured targets. If the source was a selection, the X11 clipboard is updated as well. The CLI program hel can be used to manually send text to the daemon, for example from tmux or Neovim. If remote hosts are configured, each yank event is sent over the network to update their clipboards.

Several yank events are stored in memory in order to avoid duplicates and cycles.

Installing and Running Helic

Nix

The project uses a Nix flake to configure its build, and it is recommended to install or run it using Nix as well. If Nix is installed and configured for use with flakes, the app can be run like this:

$ nix run github:tek/helic -- listen
$ echo 'yank me' | nix run github:tek/helic -- yank

NixOS

The flake provides a NixOS module that can be used by adding it to /etc/nixos/configuration.nix:

{
  inputs.helic.url = github:/tek/helic;
  outputs = { nixpkgs, helic, ... }: {
    nixosConfigurations.myhost = nixpkgs.lib.nixosSystem {
      modules = [helic.nixosModule];
      services.helic.enable = true;
    };
  };
}

With this, a systemd user service will be started on login and the client will be in $PATH:

$ echo 'yank me' | hel yank

Without Nix

Alternatively, the app can be installed using a Haskell package manager, like Cabal:

$ cabal install helic
$ hel listen

CLI

If neither of the commands listen and yank have been specified explicitly, Helic decides which one to start by the presence of stdin data:

$ hel # start daemon
$ echo 'yank me' | hel # yank

Global CLI options are specified before the command name, command-specific ones after it.

|Command|Name|Description| |Global|--verbose|Increase the log level.| |Global|--config-file FILE|Use the specified file path instead of the default locations.| |listen|--agent NAME|Used to avoid sending yanks back to the application that sent them.|

Configuring Helic

The app reads the first existing one of these three configuration files:

  • The file specified with --config-file
  • $XDG_CONFIG_DIR/helic.yaml (most likely ~/.config/helic.yaml)
  • /etc/helic.yaml

An example config file looks like this:

name: myhost
maxHistory: 1000
net:
  port: 10001
  hosts:
    - "remote1:1000"
    - "remote2:2000"
  timeout: 5
tmux:
  enable: true
  exe: /bin/tmux

For NixOS, the file /etc/helic.yaml is generated from module options:

services.helic = {
  enable = true;
  name = "myhost";
  maxHistory = 1000;
  net = {
    port = 10001;
    hosts = ["remote1:1000" "remote2:2000"];
    timeout = 5;
  };
  tmux = {
    enable = true;
    package = old.tmux;
  };
};

The meaning of these options is:

|Key|Default|Description| |name|Host name|An identifier for the host, used for filtering duplicates.| |maxHistory|100|The number of yanks that should be kept.| |net.port|9500|The HTTP port the daemon listens to for both remote sync and hel yank.| |net.hosts|[]|The addresses (with port) of the hosts to which this instance should broadcast yank events.| |net.timeout|300|The timeout in milliseconds for requests to remote hosts.| |tmux.enable|true|Whether to send events to tmux.| |tmux.package|pkgs.tmux|Only for NixOS: The nixpkgs package used for the tmux executable.| |tmux.exe|tmux|Only for YAML file: The path to the tmux executable|

Neovim

Neovim's clipboard requires configuration with a tool in any case, so changing it to use hel is simple:

let g:clipboard = {
  \   'name': 'helic',
  \   'copy': {
  \      '+': 'hel yank --agent nvim',
  \      '+': 'hel yank --agent nvim',
  \    },
  \   'paste': {
  \      '+': 'xsel -bo',
  \      '*': 'xsel -bo',
  \   },
  \ }

Since Helic updates the X11 clipboard, a custom paste command is not necessary.