diff options
author | Soispha <soispha@vhack.eu> | 2023-08-01 15:31:42 +0200 |
---|---|---|
committer | Soispha <soispha@vhack.eu> | 2023-08-01 15:42:54 +0200 |
commit | 0a608bd781dcda40144097b007fac0a0c60a8ee1 (patch) | |
tree | e69fbc1fd0e15e3b86f31f47b776df21f6f0170d /home-manager/config/lf/commands | |
parent | Fix(hm/conf/gammastep): Use lighter settings on laptops (diff) | |
download | nixos-config-0a608bd781dcda40144097b007fac0a0c60a8ee1.zip |
Refactor(treewide): Move module configuration in separate files
Diffstat (limited to 'home-manager/config/lf/commands')
22 files changed, 0 insertions, 655 deletions
diff --git a/home-manager/config/lf/commands/default.nix b/home-manager/config/lf/commands/default.nix deleted file mode 100644 index 67362fd0..00000000 --- a/home-manager/config/lf/commands/default.nix +++ /dev/null @@ -1,222 +0,0 @@ -{ - pkgs, - sysLib, - shell_library, - system, - ... -}: let - functionCall = { - file, - dependencies, - replacementStrings, - ... - }: - sysLib.writeShellScriptWithLibraryAndKeepPath { - name = "${builtins.baseNameOf file}"; - src = file; - dependencies = dependencies ++ (builtins.attrValues {inherit (pkgs) dash coreutils;}); - inherit replacementStrings; - } - + "/bin/${builtins.baseNameOf file}"; - shell = { - file, - dependencies, - replacementStrings ? null, - ... - }: '' - ''${{ - ${functionCall {inherit file dependencies replacementStrings;}} - }} - ''; # closes the lf tui - pipe = { - file, - dependencies, - replacementStrings ? null, - ... - }: '' - %{{ - ${functionCall {inherit file dependencies replacementStrings;}} - }} - ''; # runs the command in the ui/term bar - async = { - file, - dependencies, - replacementStrings ? null, - ... - }: '' - &{{ - ${functionCall {inherit file dependencies replacementStrings;}} - }} - ''; # runs the command in the background - wait = { - file, - dependencies, - replacementStrings ? null, - ... - }: '' - !{{ - ${functionCall {inherit file dependencies replacementStrings;}} - }} - ''; # adds a prompt after the command has run -in { - archive = shell { - file = ./scripts/archive; - dependencies = builtins.attrValues { - inherit - (pkgs) - fzf - gnutar - xz - p7zip - zip - ; - }; - }; - broot_jump = shell { - file = ./scripts/broot_jump; - dependencies = builtins.attrValues { - inherit (pkgs) broot; - }; - }; - chmod = pipe { - file = ./scripts/chmod; - dependencies = []; - }; - clear_trash = shell { - file = ./scripts/clear_trash; - dependencies = builtins.attrValues { - inherit - (pkgs) - fzf - trashy - ; - }; - }; - dl_file = pipe { - file = ./scripts/dl_file; - dependencies = builtins.attrValues { - inherit - (pkgs) - xdragon - curl - ; - }; - }; - dragon = pipe { - file = ./scripts/dragon; - dependencies = builtins.attrValues { - inherit - (pkgs) - xdragon - ; - }; - }; - dragon_individual = pipe { - file = ./scripts/dragon_individual; - dependencies = builtins.attrValues { - inherit - (pkgs) - xdragon - ; - }; - }; - dragon_stay = pipe { - file = ./scripts/dragon_stay; - dependencies = builtins.attrValues { - inherit - (pkgs) - xdragon - ; - }; - }; - fzf_jump = shell { - file = ./scripts/fzf_jump; - dependencies = builtins.attrValues { - inherit (pkgs) fzf lf gnused; - }; - }; - mk_dir = pipe { - file = ./scripts/mk_dir; - dependencies = []; - }; - mk_file = shell { - file = ./scripts/mk_file; - dependencies = []; - }; - mk_ln = pipe { - file = ./scripts/mk_ln; - dependencies = []; - }; - mk_scr_default = shell { - file = ./scripts/mk_scr_default; - dependencies = builtins.attrValues {inherit (pkgs) neovim;}; - replacementStrings = { - SHELL_LIBRARY_TEMPLATE = "${shell_library.rawTemplate."${system}"}"; - }; - }; - mk_scr_temp = shell { - file = ./scripts/mk_scr_temp; - dependencies = builtins.attrValues {inherit (pkgs) neovim;}; - replacementStrings = { - SHELL_LIBRARY_TEMPLATE = "${shell_library.rawTemplate."${system}"}"; - TO_BE_SHELL_LIBRARY_PATH = "%SHELL_LIBRARY_PATH"; # replacement is not recursive - }; - }; - open = shell { - file = ./scripts/open; - dependencies = builtins.attrValues {inherit (pkgs) file xdg-utils neovim git;}; - }; - open_config = shell { - file = ./scripts/open_config; - dependencies = builtins.attrValues { - #inherit - #(pkgs) - ## TODO rewrite this: bookmenu, https://github.com/jarun/buku - # - #buku - #; - }; - }; - restore_trash = shell { - file = ./scripts/restore_trash; - dependencies = builtins.attrValues { - inherit - (pkgs) - fzf - trashy - ; - }; - }; - set_wall_paper = pipe { - file = ./scripts/set_wall_paper; - dependencies = []; - }; - stripspace = pipe { - file = ./scripts/stripspace; - dependencies = []; - }; - trash = pipe { - file = ./scripts/trash; - dependencies = builtins.attrValues { - inherit - (pkgs) - trashy - trash-cli - findutils - ; - }; - }; - unarchive = pipe { - file = ./scripts/unarchive; - dependencies = builtins.attrValues { - inherit - (pkgs) - gnutar - unzip - # TODO this is unfree! unrar - - p7zip - ; - }; - }; -} diff --git a/home-manager/config/lf/commands/scripts/archive b/home-manager/config/lf/commands/scripts/archive deleted file mode 100755 index 48fe25fc..00000000 --- a/home-manager/config/lf/commands/scripts/archive +++ /dev/null @@ -1,54 +0,0 @@ -#! /usr/bin/env dash - -# shellcheck source=/dev/null -SHELL_LIBRARY_VERSION="1.1.4" . %SHELL_LIBRARY_PATH - -# Option '-f' disables pathname expansion which can be useful when $f, $fs, and -# $fx variables contain names with '*' or '?' characters. However, this option -# is used selectively within individual commands as it can be limiting at -# times. -set -f - -archivers="$(tmp 'echo "gzip xz 7z zip"')"; - -prompt "Archive name: " -name="" -while [ -z "$name" ] || [ -e "$name" ] -do - read -r name - if [ -e "$name" ]; then - prompt "Archive already exists, overwrite [y|N]: " - read -r ans - - if [ "$ans" = "y" ]; then - break - else - prompt "Archive name: " - fi - fi -done - -root="$(if [ "$(pwd)" = "/" ]; then pwd; else echo "$(pwd)/";fi)"; - -# fx contains all selected file name separated by a newline -while read -r raw_file; do - file="$(echo "$raw_file" | sed "s|$root||")"; - set -- "$@" "$file"; -done < "$(tmp "echo '$fx'")"; - -case "$(awk '{for (i=1; i<=NF; i++) print $i}' "$archivers" | fzf)" in - "gzip") - tar -czf "$name".tar.gz "$@" - ;; - "xz") - tar -cf "$name".tar "$@" - xz -z -9 -e -T0 "$name".tar - ;; - "7z") - 7z a "$name".7z "$@" - ;; - "zip") - zip --symlinks -r "$name".zip "$@" - ;; -esac -# vim: ft=sh diff --git a/home-manager/config/lf/commands/scripts/broot_jump b/home-manager/config/lf/commands/scripts/broot_jump deleted file mode 100755 index abefc616..00000000 --- a/home-manager/config/lf/commands/scripts/broot_jump +++ /dev/null @@ -1,16 +0,0 @@ -#! /usr/bin/env dash - -# shellcheck source=/dev/null -SHELL_LIBRARY_VERSION="1.1.4" . %SHELL_LIBRARY_PATH - -tmp=$(mktmp) -res="$(broot --outcmd "$tmp" && sed 's/cd //' "$tmp")" - -if [ -f "$res" ]; then - cmd="select" -elif [ -d "$res" ]; then - cmd="cd" -fi - -lf -remote "send '$id' '$cmd' '$res'" -# vim: ft=sh diff --git a/home-manager/config/lf/commands/scripts/chmod b/home-manager/config/lf/commands/scripts/chmod deleted file mode 100755 index 07bc37cc..00000000 --- a/home-manager/config/lf/commands/scripts/chmod +++ /dev/null @@ -1,13 +0,0 @@ -#! /usr/bin/env dash - -# shellcheck source=/dev/null -SHELL_LIBRARY_VERSION="1.1.4" . %SHELL_LIBRARY_PATH - -readp "Mode bits: " bits - -while read -r file; do - chmod "$bits" "$file" -done < "$(tmp "echo $fx")" - -lf -remote 'send reload' -# vim: ft=sh diff --git a/home-manager/config/lf/commands/scripts/clear_trash b/home-manager/config/lf/commands/scripts/clear_trash deleted file mode 100755 index f2571fcc..00000000 --- a/home-manager/config/lf/commands/scripts/clear_trash +++ /dev/null @@ -1,8 +0,0 @@ -#! /usr/bin/env dash - -# shellcheck source=/dev/null -SHELL_LIBRARY_VERSION="1.1.4" . %SHELL_LIBRARY_PATH - -# could also use --force, for instand removal -trash list | fzf --multi | awk '{print $NF}' | xargs trash empty --match=exact -# vim: ft=sh diff --git a/home-manager/config/lf/commands/scripts/dl_file b/home-manager/config/lf/commands/scripts/dl_file deleted file mode 100755 index 54518049..00000000 --- a/home-manager/config/lf/commands/scripts/dl_file +++ /dev/null @@ -1,33 +0,0 @@ -#! /usr/bin/env dash - -# shellcheck source=/dev/null -SHELL_LIBRARY_VERSION="1.1.4" . %SHELL_LIBRARY_PATH - -# Provides the ability to download a file by dropping it into a window - -url="$(dragon -t -x)" - -if [ -n "$url" ]; then - prompt "File Name: " - name="" - while [ -z "$name" ] || [ -e "$name" ] - do - read -r name - if [ -e "$name" ]; then - prompt "File already exists, overwrite [y|N]: " - read -r ans - - if [ "$ans" = "y" ]; then - break - else - prompt "File Name: " - fi - fi - done - - # Download the file with curl - [ -n "$name" ] && curl -o "$name" "$url" || die "curl failed" -else - die "URL is null!" -fi -# vim: ft=sh diff --git a/home-manager/config/lf/commands/scripts/dragon b/home-manager/config/lf/commands/scripts/dragon deleted file mode 100755 index 7e2d9ba6..00000000 --- a/home-manager/config/lf/commands/scripts/dragon +++ /dev/null @@ -1,11 +0,0 @@ -#! /usr/bin/env dash - -# shellcheck source=/dev/null -SHELL_LIBRARY_VERSION="1.1.4" . %SHELL_LIBRARY_PATH - -while read -r file; do - set -- "$@" "$file" -done < "$(tmp "echo '$fx'")" - -dragon -a -x "$@" -# vim: ft=sh diff --git a/home-manager/config/lf/commands/scripts/dragon_individual b/home-manager/config/lf/commands/scripts/dragon_individual deleted file mode 100755 index 5d55aaa8..00000000 --- a/home-manager/config/lf/commands/scripts/dragon_individual +++ /dev/null @@ -1,11 +0,0 @@ -#! /usr/bin/env dash - -# shellcheck source=/dev/null -SHELL_LIBRARY_VERSION="1.1.4" . %SHELL_LIBRARY_PATH - -while read -r file; do - set -- "$@" "$file" -done < "$(tmp "echo '$fx'")" - -dragon "$@" -# vim: ft=sh diff --git a/home-manager/config/lf/commands/scripts/dragon_stay b/home-manager/config/lf/commands/scripts/dragon_stay deleted file mode 100755 index f3483483..00000000 --- a/home-manager/config/lf/commands/scripts/dragon_stay +++ /dev/null @@ -1,11 +0,0 @@ -#! /usr/bin/env dash - -# shellcheck source=/dev/null -SHELL_LIBRARY_VERSION="1.1.4" . %SHELL_LIBRARY_PATH - -while read -r file; do - set -- "$@" "$file"; -done < "$(tmp "echo '$fx'")" - -dragon -a "$@" -# vim: ft=sh diff --git a/home-manager/config/lf/commands/scripts/fzf_jump b/home-manager/config/lf/commands/scripts/fzf_jump deleted file mode 100755 index c05216f0..00000000 --- a/home-manager/config/lf/commands/scripts/fzf_jump +++ /dev/null @@ -1,15 +0,0 @@ -#! /usr/bin/env dash - -# shellcheck source=/dev/null -SHELL_LIBRARY_VERSION="1.1.4" . %SHELL_LIBRARY_PATH - -res="$(fd . --maxdepth 3 | fzf --header='Jump to location')" - -if [ -f "$res" ]; then - cmd="select" -elif [ -d "$res" ]; then - cmd="cd" -fi - -lf -remote "send '$id' '$cmd' '$res'" -# vim: ft=sh diff --git a/home-manager/config/lf/commands/scripts/mk_dir b/home-manager/config/lf/commands/scripts/mk_dir deleted file mode 100755 index 4dca06dc..00000000 --- a/home-manager/config/lf/commands/scripts/mk_dir +++ /dev/null @@ -1,24 +0,0 @@ -#! /usr/bin/env dash - -# shellcheck source=/dev/null -SHELL_LIBRARY_VERSION="1.1.4" . %SHELL_LIBRARY_PATH - -prompt "Directory Name: " -name="" -while [ -z "$name" ] || [ -e "$name" ] -do - read -r name - if [ -e "$name" ]; then - prompt "Directory already exists, overwrite [y|N]: " - read -r ans - - if [ "$ans" = "y" ]; then - break - else - prompt "Directory Name: " - fi - fi -done - -mkdir "$name" -# vim: ft=sh diff --git a/home-manager/config/lf/commands/scripts/mk_file b/home-manager/config/lf/commands/scripts/mk_file deleted file mode 100755 index 2e5a2deb..00000000 --- a/home-manager/config/lf/commands/scripts/mk_file +++ /dev/null @@ -1,25 +0,0 @@ -#! /usr/bin/env dash - -# shellcheck source=/dev/null -SHELL_LIBRARY_VERSION="1.1.4" . %SHELL_LIBRARY_PATH - -prompt "File name: " -name="" -while [ -z "$name" ] || [ -e "$name" ] -do - read -r name - if [ -e "$name" ]; then - prompt "File already exists, overwrite [y|N]: " - read -r ans - - if [ "$ans" = "y" ]; then - break - else - prompt "File name: " - fi - fi -done - -touch "$name" -"$EDITOR" "$name" -# vim: ft=sh diff --git a/home-manager/config/lf/commands/scripts/mk_ln b/home-manager/config/lf/commands/scripts/mk_ln deleted file mode 100755 index 1e97517f..00000000 --- a/home-manager/config/lf/commands/scripts/mk_ln +++ /dev/null @@ -1,36 +0,0 @@ -#! /usr/bin/env dash - -# shellcheck source=/dev/null -SHELL_LIBRARY_VERSION="1.1.4" . %SHELL_LIBRARY_PATH - -while IFS= read -r i;do - set -- "$@" "$i" -done < "$HOME"/.local/share/lf/files - -mode="$1" -shift - -if [ "$#" -eq 0 ]; then - msg "no files to link" - exit 0 -fi - -case "$mode" in - copy) - while [ "$#" -gt 0 ]; do - file="$1" - ans="$(basename "$file")" - - while [ -e "$ans" ];do - prompt "$ans already exists, new name for link: " - read -r ans - done - - ln -s "$file" "$(pwd)/$ans" - shift - done - ;; -esac -rm ~/.local/share/lf/files -# lf -remote "send clear" -# vim: ft=sh diff --git a/home-manager/config/lf/commands/scripts/mk_scr_default b/home-manager/config/lf/commands/scripts/mk_scr_default deleted file mode 100755 index b13ca9f5..00000000 --- a/home-manager/config/lf/commands/scripts/mk_scr_default +++ /dev/null @@ -1,31 +0,0 @@ -#! /usr/bin/env dash - -# shellcheck source=/dev/null -SHELL_LIBRARY_VERSION="1.1.4" . %SHELL_LIBRARY_PATH - - -prompt "Script name: " -name="" -while [ -z "$name" ] || [ -e "$name" ] -do - read -r name - if [ -e "$name" ]; then - prompt "Script already exists, overwrite [y|N]: " - read -r ans - - if [ "$ans" = "y" ]; then - break - else - prompt "Script Name: " - fi - fi -done - -script="$(pwd)"/"$name" - -cat "%SHELL_LIBRARY_TEMPLATE" > "$script" -chmod +x "$script" -"$VISUAL" "$script" - - -# vim: ft=sh diff --git a/home-manager/config/lf/commands/scripts/mk_scr_temp b/home-manager/config/lf/commands/scripts/mk_scr_temp deleted file mode 100755 index a520469c..00000000 --- a/home-manager/config/lf/commands/scripts/mk_scr_temp +++ /dev/null @@ -1,31 +0,0 @@ -#! /usr/bin/env dash - -# shellcheck source=/dev/null -SHELL_LIBRARY_VERSION="1.1.4" . %SHELL_LIBRARY_PATH - - -prompt "Script name: " -name="" -while [ -z "$name" ] || [ -e "$name" ] -do - read -r name - if [ -e "$name" ]; then - prompt "Script already exists, overwrite [y|N]: " - read -r ans - - if [ "$ans" = "y" ]; then - break - else - prompt "Script Name: " - fi - fi -done - -script="$(pwd)"/"$name" - -sed 's|%TO_BE_SHELL_LIBRARY_PATH|%SHELL_LIBRARY_PATH|' "%SHELL_LIBRARY_TEMPLATE" > "$script" -chmod +x "$script" -"$VISUAL" "$script" - - -# vim: ft=sh diff --git a/home-manager/config/lf/commands/scripts/open b/home-manager/config/lf/commands/scripts/open deleted file mode 100755 index c507482b..00000000 --- a/home-manager/config/lf/commands/scripts/open +++ /dev/null @@ -1,11 +0,0 @@ -#! /usr/bin/env dash - -# shellcheck source=/dev/null -SHELL_LIBRARY_VERSION="1.1.4" . %SHELL_LIBRARY_PATH - -case $(file --mime-type "$f" -bL) in - text/*|application/json|application/vnd.hp-HPGL) "$EDITOR" "$f";; - image/*) "$IVIEWER" "$f";; - *) xdg-open "$f";; -esac -# vim: ft=sh diff --git a/home-manager/config/lf/commands/scripts/open_config b/home-manager/config/lf/commands/scripts/open_config deleted file mode 100755 index c99422f1..00000000 --- a/home-manager/config/lf/commands/scripts/open_config +++ /dev/null @@ -1,7 +0,0 @@ -#! /usr/bin/env dash - -# shellcheck source=/dev/null -SHELL_LIBRARY_VERSION="1.1.4" . %SHELL_LIBRARY_PATH - -"$EDITOR" "$(bookmenu -b ~/.config/bookmenu/configs -f fzf -o)" # TODO implement this -# vim: ft=sh diff --git a/home-manager/config/lf/commands/scripts/restore_trash b/home-manager/config/lf/commands/scripts/restore_trash deleted file mode 100755 index a7bf0094..00000000 --- a/home-manager/config/lf/commands/scripts/restore_trash +++ /dev/null @@ -1,7 +0,0 @@ -#! /usr/bin/env dash - -# shellcheck source=/dev/null -SHELL_LIBRARY_VERSION="1.1.4" . %SHELL_LIBRARY_PATH - -trash list | fzf --multi | awk '{print $NF}' | xargs trash restore --match=exact -# vim: ft=sh diff --git a/home-manager/config/lf/commands/scripts/set_wall_paper b/home-manager/config/lf/commands/scripts/set_wall_paper deleted file mode 100755 index 45049283..00000000 --- a/home-manager/config/lf/commands/scripts/set_wall_paper +++ /dev/null @@ -1,10 +0,0 @@ -#! /usr/bin/env dash - -# shellcheck source=/dev/null -SHELL_LIBRARY_VERSION="1.1.4" . %SHELL_LIBRARY_PATH - -die "No yet implemented" # TODO do what the 'die' says -#sed -i "s,export AWMWALLPAPER='.*',export AWMWALLPAPER='${f}'," ${ZDOTDIR}/.zshenv -#nohub swaybg -i "$f" -#feh --bg-max --no-fehbg "$f" -# vim: ft=sh diff --git a/home-manager/config/lf/commands/scripts/stripspace b/home-manager/config/lf/commands/scripts/stripspace deleted file mode 100755 index 91714712..00000000 --- a/home-manager/config/lf/commands/scripts/stripspace +++ /dev/null @@ -1,31 +0,0 @@ -#! /usr/bin/env dash - -# shellcheck source=/dev/null -SHELL_LIBRARY_VERSION="1.1.4" . %SHELL_LIBRARY_PATH - -files=$(mktmp); -echo "$fx" > "$files"; - -awk_source=$(mktmp); -cat << OFT > "$awk_source" -BEGIN {FS=" "} -{for (i=1; i != NF + 1; i++) - if (i == NF) { - parts[i]=tolower(\$i); - } else { - parts[i]=tolower(\$i"_"); - } -} -END {for (i in parts) printf parts[i]} -OFT - -while read -r file; do - dirty_name=$(mktmp) - basename "$file" > "$dirty_name"; - clean_name=$(awk -f "$awk_source" "$dirty_name"); - - [ -e "$clean_name" ] && die "file \"$clean_name\" already exists!"; - mv "$(cat "$dirty_name")" "$clean_name" || die "Move failed"; - lf -remote 'send reload' -done < "$files"; -# vim: ft=sh diff --git a/home-manager/config/lf/commands/scripts/trash b/home-manager/config/lf/commands/scripts/trash deleted file mode 100755 index 7f477550..00000000 --- a/home-manager/config/lf/commands/scripts/trash +++ /dev/null @@ -1,26 +0,0 @@ -#! /usr/bin/env dash - -# shellcheck source=/dev/null -SHELL_LIBRARY_VERSION="1.1.4" . %SHELL_LIBRARY_PATH - -trash_output=$(mktmp); -expected_error_output=$(mktmp); - -while read -r file; do - set -- "$@" "$file" -done < "$(tmp "echo '$fx'")" - -# TODO why are we using trashy at all, when trash-cli can do everything? -# try trashy first, trough nix because both trashy and trash-cli provide a trash command, which conflicts -nix run nixpkgs#trashy -- put "$@" 2> "$trash_output"; - -cat << EOF > "$expected_error_output"; -[1;31merror:[0m Error during a \`trash\` operation: Unknown { description: "Path: '\"/.Trash-1000\"'. Message: Permission denied (os error 13)" } -EOF - -if [ "$(cat "$expected_error_output")" = "$(cat "$trash_output")" ];then - warning "Deleting with trash-cli to the /.Trash folder"; - # this file could not be trashed because it is on the tempfs volume, trash-cli can do this this - trash-put "$@"; -fi -# vim: ft=sh diff --git a/home-manager/config/lf/commands/scripts/unarchive b/home-manager/config/lf/commands/scripts/unarchive deleted file mode 100755 index 69cc601c..00000000 --- a/home-manager/config/lf/commands/scripts/unarchive +++ /dev/null @@ -1,22 +0,0 @@ -#! /usr/bin/env dash - -# shellcheck source=/dev/null -SHELL_LIBRARY_VERSION="1.1.4" . %SHELL_LIBRARY_PATH - -# extract the current file with the right command -# (xkcd link: https://xkcd.com/1168/) -set -f -# TODO add support for multiple files at once -case "$f" in - *.tar.bz|*.tar.bz2|*.tbz|*.tbz2) tar xjvf "$f";; - *.tar.gz|*.tgz) tar xzvf "$f";; - *.tar.xz|*.txz) tar xJvf "$f";; - *.zip) unzip "$f";; - *.rar) - die "rar is a unfree format!" - #unrar x $f - ;; - *.7z) 7z x "$f";; - *) die "Unsupported format" ;; -esac -# vim: ft=sh |