From c081c63146c6ec9f66b95c3c115c605a7b250d9f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Leonardo=20Eug=C3=AAnio?= Date: Fri, 27 Jan 2023 17:09:48 -0300 Subject: [PATCH] scripts: add wl-copy-file --- scripts/default.nix | 1 + scripts/wl-copy-file | 21 +++++++++++++++++++++ user/fish/default.nix | 6 +++++- 3 files changed, 27 insertions(+), 1 deletion(-) create mode 100644 scripts/wl-copy-file diff --git a/scripts/default.nix b/scripts/default.nix index 3c8168e..4b248fb 100644 --- a/scripts/default.nix +++ b/scripts/default.nix @@ -24,6 +24,7 @@ create_scripts { br = [ ]; bmenu = [ final.bemenu final.dhist fish j4-dmenu-desktop jq sway ]; + wl-copy-file = [ wl-clipboard fish ]; _diffr = [ diffr ]; _thunar-terminal = [ final.terminal ]; kak-pager = [ fish final._diffr ]; diff --git a/scripts/wl-copy-file b/scripts/wl-copy-file new file mode 100644 index 0000000..05ffe06 --- /dev/null +++ b/scripts/wl-copy-file @@ -0,0 +1,21 @@ +#!/usr/bin/env fish + +function die + echo $argv[2..] >&2 + exit $argv[1] +end + +if test (count $argv) != 1 + die 1 "Incorrect number of arguments porvided" >&2 +end + +set -a file (realpath $argv[1]) +set -e argv[1] + +if test -d "$file" + die 1 "Cannot copy directories" >&2 +else if test -f "$file" + wl-copy $argv -t text/uri-list "file:///$file" +else + die 2 "No file found" >&2 +end diff --git a/user/fish/default.nix b/user/fish/default.nix index 46e05d5..ca88feb 100644 --- a/user/fish/default.nix +++ b/user/fish/default.nix @@ -34,6 +34,7 @@ in { "kakoune" = "kak"; }.${editor}; ns = "nix develop --command $SHELL"; + wcf = "wl-copy-file"; # system sv = "sudo systemct"; suv = "sudo systemct --user"; @@ -75,6 +76,9 @@ in { }; # programs.command-not-found.enable = true; programs.nix-index.enable = true; - home.packages = with pkgs; [ trash-cli ]; + home.packages = with pkgs; [ + trash-cli + wl-copy-file + ]; }; }