Skip to content

Commit

Permalink
cliphist
Browse files Browse the repository at this point in the history
  • Loading branch information
mightyiam committed Nov 22, 2024
1 parent eaee776 commit 91ad375
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions home-manager-modules/users/mightyiam/modules/clipboard.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
{
lib,
config,
pkgs,
...
}:
let
mod = config.wayland.windowManager.sway.config.modifier;

rofi-cliphist = pkgs.writeShellApplication {
name = "rofi-cliphist";
runtimeInputs = [
config.services.cliphist.package
config.programs.rofi.package
];
text = ''
prompt=$(if [ "$1" == "copy" ]; then echo ' 󰆏 '; else echo '   '; fi)
content=$(cliphist list | rofi -dmenu -p "$prompt")
decoded=$(cliphist decode <<<"$content")
if [ "$1" == "copy" ]; then
echo "$decoded" | wl-copy
else
echo "type $decoded" | ${config.dotoolc}
fi
'';
};
in
{
services.cliphist.enable = true;

wayland.windowManager.sway.config.keybindings = {
"--no-repeat ${mod}+p" = "exec ${lib.getExe rofi-cliphist} copy";
"--no-repeat ${mod}+Shift+p" = "exec ${lib.getExe rofi-cliphist} type";
};
}

0 comments on commit 91ad375

Please sign in to comment.