From 82fa6002f9a91a72e70b53bcf6ad3e64b81a84d8 Mon Sep 17 00:00:00 2001 From: MoritzBoehme Date: Fri, 21 Jan 2022 22:03:51 +0100 Subject: [PATCH] :rocket: add share bin --- modules/cli/bin/default.nix | 3 ++- modules/cli/bin/share.nix | 21 +++++++++++++++++++++ 2 files changed, 23 insertions(+), 1 deletion(-) create mode 100644 modules/cli/bin/share.nix diff --git a/modules/cli/bin/default.nix b/modules/cli/bin/default.nix index 0201b50..b4572b1 100644 --- a/modules/cli/bin/default.nix +++ b/modules/cli/bin/default.nix @@ -4,8 +4,9 @@ let cheat = import ./cheat.nix { inherit pkgs; }; cycleSinks = import ./cycleSinks.nix { inherit pkgs; }; protonge = import ./protonge.nix { inherit pkgs; }; + share = import ./share.nix { inherit pkgs; }; sxhkdHelp = import ./sxhkdHelp.nix { inherit pkgs; }; in { home-manager.users.moritz.home.packages = - [ cycleSinks cheat sxhkdHelp protonge ]; + [ cheat cycleSinks protonge share sxhkdHelp ]; } diff --git a/modules/cli/bin/share.nix b/modules/cli/bin/share.nix new file mode 100644 index 0000000..9f7ef11 --- /dev/null +++ b/modules/cli/bin/share.nix @@ -0,0 +1,21 @@ +{ pkgs }: + +pkgs.writeShellApplication { + name = "share"; + + runtimeInputs = with pkgs; [ curl coreutils rofi p7zip xclip ]; + + text = '' + files="$(find "$HOME" -maxdepth 10 -type 'f' -not -path '*/.*' | rofi -dmenu -d 15 -p 'Files to share')" + password="$(rofi -dmenu -p 'Password for encryption')" + zipname="$HOME/Downloads/share-$(date +"%Y-%m-%d").zip" + if [[ $password == "" ]]; then + args="" + else + args="-p""$password""" + fi + 7z a "$zipname" "$files" "$args" -mx9 > /dev/null + curl -s -F"file=@$zipname" 0x0.st | xclip -sel c + rm "$zipname" + ''; +}