Add custom clipboard scripts

Signed-off-by: Nikolaos Karaolidis <nick@karaolidis.com>
This commit is contained in:
2024-08-15 14:14:28 +02:00
parent 3749c22df5
commit 63cd833778
6 changed files with 57 additions and 9 deletions

View File

@@ -69,14 +69,12 @@
wayland.windowManager.hyprland.settings.bind =
let
cliphist-rofi = lib.meta.getExe (pkgs.callPackage ./rofi.nix { });
cliphist = lib.meta.getExe pkgs.cliphist;
rofi = lib.meta.getExe pkgs.rofi-wayland;
wl-copy = "${pkgs.wl-clipboard}/bin/wl-copy";
in
[
"$mod, v, exec, ${cliphist} list | ${rofi} -cache-dir ${home}/.cache/rofi -dmenu -display-columns 2 | ${cliphist} decode | ${wl-copy}"
"$mod_Ctrl, v, exec, ${cliphist} list | ${rofi} -cache-dir ${home}/.cache/rofi -dmenu -display-columns 2 | ${cliphist} delete"
"$mod_Ctrl_Shift, v, exec, ${cliphist} wipe"
"$mod, v, exec, ${cliphist-rofi}"
"$mod_Ctrl, v, exec, ${cliphist} wipe"
];
};
}

View File

@@ -0,0 +1,26 @@
{ lib, pkgs, ... }:
let
copy = lib.meta.getExe (
pkgs.writeShellApplication {
name = "copy";
runtimeInputs = with pkgs; [
cliphist
wl-clipboard
];
text = builtins.readFile ./scripts/copy.sh;
}
);
delete = lib.meta.getExe (
pkgs.writeShellApplication {
name = "delete";
runtimeInputs = with pkgs; [ cliphist ];
text = builtins.readFile ./scripts/delete.sh;
}
);
in
pkgs.writeShellApplication {
name = "cliphist-rofi";
runtimeInputs = with pkgs; [ rofi-wayland ];
text = "rofi -modi \"copy:${copy},delete:${delete}\" -show copy";
}

View File

@@ -0,0 +1,13 @@
list() {
echo -en "\0keep-selection\x1ftrue\n"
cliphist list
}
handle() {
cliphist decode <<< "$1" | wl-copy
}
case $ROFI_RETV in
0) list ;;
1) handle "$@" ;;
esac

View File

@@ -0,0 +1,13 @@
list() {
echo -en "\0keep-selection\x1ftrue\n"
cliphist list
}
handle() {
cliphist delete <<< "$1"
}
case $ROFI_RETV in
0) list ;;
1) handle "$@" && list ;;
esac