feat(desktop): add clipboard history (task 0027)
Add a clipboard module to the desktop group, enabled through the aggregator. Home-manager's services.cliphist runs the text and image watchers as systemd user services bound to the graphical-session target, and a rofi-dmenu picker recalls history on Super+Shift+V.
This commit is contained in:
42
modules/desktop/clipboard.nix
Normal file
42
modules/desktop/clipboard.nix
Normal file
@@ -0,0 +1,42 @@
|
||||
{
|
||||
config,
|
||||
lib,
|
||||
pkgs,
|
||||
...
|
||||
}:
|
||||
# Clipboard history: cliphist records every copy, picked back through rofi.
|
||||
let
|
||||
cfg = config.modules.desktop.clipboard;
|
||||
user = config.user.name;
|
||||
|
||||
cliphist = "${pkgs.cliphist}/bin/cliphist";
|
||||
rofi = "${pkgs.rofi}/bin/rofi";
|
||||
wl-copy = "${pkgs.wl-clipboard}/bin/wl-copy";
|
||||
|
||||
# The picker reuses the themed rofi, so history looks like every other menu
|
||||
# the launcher drives.
|
||||
# decode is needed because list emits id-prefixed lines rather than the copied
|
||||
# bytes, so the chosen id has to be resolved back before it can be re-copied.
|
||||
picker = pkgs.writeShellScript "clipboard-picker" ''
|
||||
${cliphist} list \
|
||||
| ${rofi} -dmenu -i -p Clipboard \
|
||||
| ${cliphist} decode \
|
||||
| ${wl-copy}
|
||||
'';
|
||||
in
|
||||
{
|
||||
options.modules.desktop.clipboard.enable = lib.mkEnableOption "cliphist clipboard history";
|
||||
|
||||
config = lib.mkIf cfg.enable {
|
||||
home-manager.users.${user} = {
|
||||
# Two watchers record text and images to history, bound to the graphical
|
||||
# session so uwsm starts and stops them with it.
|
||||
services.cliphist.enable = true;
|
||||
|
||||
# $mod is defined by the compositor config these binds share.
|
||||
wayland.windowManager.hyprland.settings.bind = [
|
||||
"$mod SHIFT, V, exec, ${picker}"
|
||||
];
|
||||
};
|
||||
};
|
||||
}
|
||||
@@ -9,6 +9,7 @@ in
|
||||
# Each piece is turned on at default priority, so a host can still override
|
||||
# any one of them while the single flag above enables the whole desktop.
|
||||
config = lib.mkIf cfg.enable {
|
||||
modules.desktop.clipboard.enable = lib.mkDefault true;
|
||||
modules.desktop.hyprland.enable = lib.mkDefault true;
|
||||
modules.desktop.hyprlock.enable = lib.mkDefault true;
|
||||
modules.desktop.hypridle.enable = lib.mkDefault true;
|
||||
|
||||
Reference in New Issue
Block a user