From 425e8b5454d193dae0d5a5c4931319186edd380b Mon Sep 17 00:00:00 2001 From: Gabriel Date: Mon, 12 Sep 2022 17:07:23 +0200 Subject: [PATCH] gosh i barely understand nix --- modules/desktop.nix | 10 +++++--- scripts/desktop/permaclip/default.nix | 37 --------------------------- scripts/desktop/permaclip/pc-get.sh | 15 +++++++++++ scripts/desktop/permaclip/pc-set.sh | 16 ++++++++++++ 4 files changed, 37 insertions(+), 41 deletions(-) delete mode 100644 scripts/desktop/permaclip/default.nix create mode 100644 scripts/desktop/permaclip/pc-get.sh create mode 100644 scripts/desktop/permaclip/pc-set.sh diff --git a/modules/desktop.nix b/modules/desktop.nix index de19389..5409b02 100644 --- a/modules/desktop.nix +++ b/modules/desktop.nix @@ -5,7 +5,9 @@ let window-screenshot = pkgs.writeShellScriptBin "window-screenshot.sh" (builtins.readFile ../scripts/desktop/window-screenshot.sh); # desktop-ctl = pkgs.writeShellScriptBin "desktop-ctl.sh" (builtins.readFile ../scripts/desktop/desktop-ctl.sh); desktop-ctl = import ../scripts/desktop/desktopctl.nix { pkgs = pkgs; }; - permaclip = import ../scripts/desktop/permaclip { pkgs = pkgs; }; + # permaclip + pc-get = pkgs.writeShellScriptBin "pc-get.sh" (builtins.readFile ../scripts/desktop/permaclip/pc-get.sh); + pc-set = pkgs.writeShellScriptBin "pc-set.sh" (builtins.readFile ../scripts/desktop/permaclip/pc-set.sh); em-record = pkgs.writeShellScriptBin "em-record.sh" (builtins.readFile ../scripts/desktop/macros/record.sh); em-play = pkgs.writeShellScriptBin "em-play.sh" (builtins.readFile ../scripts/desktop/macros/play.sh); em-play-loop = pkgs.writeShellScriptBin "em-play-loop.sh" (builtins.readFile ../scripts/desktop/macros/play-loop.sh); @@ -29,7 +31,7 @@ in with lib; { libqalculate # needed by menu-qalc # custom scripts window-screenshot desktop-ctl em-record em-play em-play-loop ocr-screenshot menu-qalc - permaclip + pc-get pc-set # themes gruvbox-dark-gtk gruvbox-dark-icons-gtk @@ -139,8 +141,8 @@ in with lib; { "${mod}+Shift+p" = "exec em-play-loop.sh"; # permaclip - "${mod}+c" = "rofi -show permaclip -modes \"permaclip:${permaclip.outPath}/bin/pc-set\" -theme gruvbox-dark"; - "${mod}+v" = "rofi -show permaclip -modes \"permaclip:${permaclip.outPath}/bin/pc-get\" -theme gruvbox-dark"; + "${mod}+c" = "rofi -show permaclip -modes \"permaclip:${pc-set.outPath}/bin/pc-set.sh\" -theme gruvbox-dark"; + "${mod}+v" = "rofi -show permaclip -modes \"permaclip:${pc-get.outPath}/bin/pc-get.sh\" -theme gruvbox-dark"; }; # }}} # Visuals {{{ diff --git a/scripts/desktop/permaclip/default.nix b/scripts/desktop/permaclip/default.nix deleted file mode 100644 index db2e02e..0000000 --- a/scripts/desktop/permaclip/default.nix +++ /dev/null @@ -1,37 +0,0 @@ -{ pkgs, ... }: -pkgs.writeShellScriptBin "pc-set" '' - # create ~/permaclip if it doesnt exist already - mkdir -p $HOME/permaclip - - tr_name=$(echo $@ | xargs) - if [ x"$tr_name" != x"" ]; then - tr_name="''${tr_name% (*}" - clipdata=$(xclip -selection c -o) - echo $clipdata > $HOME/permaclip/$tr_name - fi - - echo -e "\0markup-rows\x1ftrue" - - for reg in $(ls ~/permaclip); do - content=$(cat ~/permaclip/$reg) - echo -e "$reg (''${content:0:30})" - done -''; - -pkgs.writeShellScriptBin "pc-get" '' - # create ~/permaclip if it doesnt exist already - mkdir -p $HOME/permaclip - - tr_name=$(echo ''${@% (*} | xargs) - if [ x"$tr_name" != x"" ]; then - xclip -selection c -i $HOME/permaclip/''${tr_name% (*} &> /dev/null - exit 0 - fi - - echo -e "\0markup-rows\x1ftrue" - - for reg in $(ls ~/permaclip); do - content=$(cat ~/permaclip/$reg) - echo -e "$reg (''${content:0:50}...)" - done -''; diff --git a/scripts/desktop/permaclip/pc-get.sh b/scripts/desktop/permaclip/pc-get.sh new file mode 100644 index 0000000..bfda40f --- /dev/null +++ b/scripts/desktop/permaclip/pc-get.sh @@ -0,0 +1,15 @@ +# create ~/permaclip if it doesnt exist already +mkdir -p $HOME/permaclip + +tr_name=$(echo ''${@% (*} | xargs) +if [ x"$tr_name" != x"" ]; then + xclip -selection c -i $HOME/permaclip/''${tr_name% (*} &> /dev/null + exit 0 +fi + +echo -e "\0markup-rows\x1ftrue" + +for reg in $(ls ~/permaclip); do + content=$(cat ~/permaclip/$reg) + echo -e "$reg (''${content:0:50}...)" +done diff --git a/scripts/desktop/permaclip/pc-set.sh b/scripts/desktop/permaclip/pc-set.sh new file mode 100644 index 0000000..bcadffc --- /dev/null +++ b/scripts/desktop/permaclip/pc-set.sh @@ -0,0 +1,16 @@ +# create ~/permaclip if it doesnt exist already +mkdir -p $HOME/permaclip + +tr_name=$(echo $@ | xargs) +if [ x"$tr_name" != x"" ]; then + tr_name="''${tr_name% (*}" + clipdata=$(xclip -selection c -o) + echo $clipdata > $HOME/permaclip/$tr_name +fi + +echo -e "\0markup-rows\x1ftrue" + +for reg in $(ls ~/permaclip); do + content=$(cat ~/permaclip/$reg) + echo -e "$reg (''${content:0:30})" +done