{ pkgs, config, ... }:
{
  home.packages = [
    pkgs.clipster
  ];
  systemd.user.services.clipster = {
    Unit = {
      Description = "clipster clipboard manager daemon";
      After = [ "graphical-session-pre.target" ];
      PartOf = [ "graphical-session.target" ];
    };
    Service = {
      ExecStart = "${pkgs.clipster}/bin/clipster -d";
      Restart = "always";
    };
    Install = { WantedBy = [ "graphical-session.target" ]; };
  };
  xdg.configFile."clipster/clipster.ini".text = ''
    [clipster]
    # Directory for clipster data/files (usually `$HOME/.local/share/clipster`)
    #data_dir = $XDG_DATA_HOME

    # Default selection (if no -p of -c given on command-line): can be PRIMARY or CLIPBOARD
    default_selection = PRIMARY

    # Comma-separated list of selections to be watched and written to history
    active_selections = PRIMARY,CLIPBOARD

    # Enable synchronising of clipboards
    # Only clipboards listed in 'active selections' will be synchronised
    sync_selections = yes

    # full path to the clipster history file (JSON)
    # Maximum file size is: 'history_size * max_input * 2' (defaults: 10MB)
    #history_file = %(data_dir)s/history

    # Number of items to save in the history file for each selection. 0 - don't save history.
    history_size = 20

    # Time in seconds to flush history to disk, if changed
    # Set to 0 to only write history file on (clean) exit
    #history_update_interval = 60

    # Write history file immediately after selection changes?
    # If yes, disables history_update_interval
    #write_on_change = no

    # Full path to the clipster socket file
    #socket_file = %(data_dir)s/clipster_sock

    # Full path to the clipster pid file
    #pid_file = %(data_dir)s/clipster.pid

    # Maximum length for new clipboard items
    #max_input = 50000

    # Number of rows of clipboard content to show in the selection widget before truncating
    # Set to a high number to avoid truncation
    #row_height = 3

    # Allow duplicates in the clipboard (if set to no, the earlier entry will be removed)
    duplicates = no

    # smart_update tries to be clever about small changes to the selection, and only adds
    # to the history if the number of characters added or removed is greater than it's value.
    # for example, if set to 2: the latest clipboard entry catch, would be replaced by any of:
    # cat, catc, catchy, catcher, but not ca or catchers.
    # Defaults to 1, as some applications update the clipboard by continually adding new
    # items with a single character added or removed each time.
    # Set to 0 to disable.
    #smart_update = 1

    # Extract uris from the selection text and add them to the default clipboard
    extract_uris = no

    # Extract emails from the selection text and add them to the default clipboard
    extract_emails = no

    # Extract patterns (as specified in patterns file: clipster_dir/patterns) and add them to the default clipboard
    extract_patterns = no
    #patterns_file = %(conf_dir)s/patterns

    # Ignore selections matching certain patterns (as specified in patterns file: clipster_dir/ignore_patterns)
    #ignore_patterns = no
    #ignore_patterns_file = %(conf_dir)s/ignore_patterns

    # Extracted patterns are added to the history before the selection, and the clipbaord buffer is left unchanged.
    # Enabling this option adds the pattern as the last item int he history, and updates the clipboard buffer with the pattern.
    # NOTE: Multiple patterns will be applied sequentially: last one will be used for selection.
    # This option also applies to email and uri patterns (which are processed before additional patterns).
    #pattern_as_selection = no

    # Comma-separated list of WM_CLASS properties for apps where clipboard changes should be ignored.
    # Used to ignore clipboard changes from sensitive apps, e.g. password managers.
    #blacklist_classes =

    # Comma-separated list of WM_CLASS properties for apps where clipboard changes should NOT be ignored.
    # Used to only monitor clipboard changes from whitelisted apps, all other apps will be ignored!
    #whitelist_classes =
  '';
}