From 022418881b5928a0f345bc90812c094019477981 Mon Sep 17 00:00:00 2001 From: Benedikt Peetz Date: Tue, 26 Nov 2024 17:44:03 +0100 Subject: feat(modules/lf): Add `set_clipboard_path` command and keybinding --- modules/by-name/lf/lf/commands/default.nix | 4 ++++ .../lf/lf/commands/scripts/set_clipboard_path.sh | 23 ++++++++++++++++++++++ modules/by-name/lf/lf/keybindings/default.nix | 1 + 3 files changed, 28 insertions(+) create mode 100755 modules/by-name/lf/lf/commands/scripts/set_clipboard_path.sh diff --git a/modules/by-name/lf/lf/commands/default.nix b/modules/by-name/lf/lf/commands/default.nix index 933769ac..b3c9acab 100644 --- a/modules/by-name/lf/lf/commands/default.nix +++ b/modules/by-name/lf/lf/commands/default.nix @@ -194,6 +194,10 @@ in { ; }; }; + set_clipboard_path = async { + name = "set_clipboard_path"; + dependencies = [pkgs.wl-clipboard]; + }; set_wall_paper = pipe { name = "set_wall_paper"; dependencies = []; diff --git a/modules/by-name/lf/lf/commands/scripts/set_clipboard_path.sh b/modules/by-name/lf/lf/commands/scripts/set_clipboard_path.sh new file mode 100755 index 00000000..460eeedb --- /dev/null +++ b/modules/by-name/lf/lf/commands/scripts/set_clipboard_path.sh @@ -0,0 +1,23 @@ +#! /usr/bin/env dash + +# shellcheck source=/dev/null +SHELL_LIBRARY_VERSION="2.1.2" . %SHELL_LIBRARY_PATH + +# shellcheck disable=SC2269 +f="$f" +# shellcheck disable=SC2269 +fx="$fx" +# shellcheck disable=SC2269 +fs="$fs" +# shellcheck disable=SC2269 +id="$id" + +if [ -n "$fx" ]; then + echo "$fx" | wl-copy --trim-newline +elif [ -n "$f" ]; then + echo "$f" | wl-copy --trim-newline +else + lf -remote "send $id echo 'No file selected.'" +fi + +# vim: ft=sh diff --git a/modules/by-name/lf/lf/keybindings/default.nix b/modules/by-name/lf/lf/keybindings/default.nix index b6feffe3..7ae720e0 100644 --- a/modules/by-name/lf/lf/keybindings/default.nix +++ b/modules/by-name/lf/lf/keybindings/default.nix @@ -30,6 +30,7 @@ cc = "\$sudo -e \"$f\""; fe = "execute"; fl = "follow_link"; + cp = "set_clipboard_path"; # Archive Mappings au = "unarchive"; -- cgit 1.4.1