diff options
Diffstat (limited to '')
90 files changed, 1273 insertions, 1607 deletions
diff --git a/hm/soispha/conf/alacritty/toml/hints.toml b/hm/soispha/conf/alacritty/toml/hints.toml index 33b21924..af01dc3e 100644 --- a/hm/soispha/conf/alacritty/toml/hints.toml +++ b/hm/soispha/conf/alacritty/toml/hints.toml @@ -2,12 +2,12 @@ alphabet = "jfkdls;ahgurieowpq" [[hints.enabled]] -command = "xdg-open" # On Linux/BSD -hyperlinks = true +command = "xdg-open" # On Linux/BSD +hyperlinks = true post_processing = true -persist = false -mouse.enabled = true -binding = { key = "U", mods = "Control|Shift" } +persist = false +mouse.enabled = true +binding = { key = "U", mods = "Control|Shift" } regex = "(ipfs:|ipns:|magnet:|mailto:|gemini://|gopher://|https://|http://|news:|file:|git://|ssh:|ftp://)[^\u0000-\u001F\u007F-\u009F<>\"\\s{-}\\^⟨⟩`]+" diff --git a/hm/soispha/conf/firefox/scripts/extract_cookies.sh b/hm/soispha/conf/firefox/scripts/extract_cookies.sh index e4eec72c..e3d50d43 100755 --- a/hm/soispha/conf/firefox/scripts/extract_cookies.sh +++ b/hm/soispha/conf/firefox/scripts/extract_cookies.sh @@ -10,7 +10,6 @@ # which means cookies which are kept only in memory ("session cookies") # will not be extracted. You will need an extension to do that. - # USAGE: # # $ extract_cookies.sh > /tmp/cookies.txt @@ -31,20 +30,17 @@ # # B) If you've redirected stdin (with < or |) , then that will be used. - # HISTORY: I believe this is circa 2010 from: # http://slacy.com/blog/2010/02/using-cookies-sqlite-in-wget-or-curl/ # However, that site is down now. # Cleaned up by Hackerb9 (2017) to be more robust and require less typing. - cleanup() { rm -f "$TMPFILE" exit 0 } -trap cleanup EXIT INT QUIT TERM - +trap cleanup EXIT INT QUIT TERM if [ "$#" -ge 1 ]; then SQLFILE="$1" @@ -59,14 +55,13 @@ fi # We have to copy cookies.sqlite, because FireFox has a lock on it TMPFILE=$(mktemp /tmp/cookies.sqlite.XXXXXXXXXX) -cat "$SQLFILE" >> "$TMPFILE" - +cat "$SQLFILE" >>"$TMPFILE" # This is the format of the sqlite database: # CREATE TABLE moz_cookies (id INTEGER PRIMARY KEY, name TEXT, value TEXT, host TEXT, path TEXT,expiry INTEGER, lastAccessed INTEGER, isSecure INTEGER, isHttpOnly INTEGER); echo "# Netscape HTTP Cookie File" -sqlite3 -separator $'\t' "$TMPFILE" << EOF +sqlite3 -separator $'\t' "$TMPFILE" <<EOF .mode tabs .header off select host, diff --git a/hm/soispha/conf/firefox/scripts/unzip_mozlz4.py b/hm/soispha/conf/firefox/scripts/unzip_mozlz4.py index 90dfdd29..44e00d53 100755 --- a/hm/soispha/conf/firefox/scripts/unzip_mozlz4.py +++ b/hm/soispha/conf/firefox/scripts/unzip_mozlz4.py @@ -18,26 +18,27 @@ def mozlz4_to_text(filepath): def main(args): - # Given command-line arguments of an input filepath for a ".mozlz4" file - # and optionally an output filepath, write the decompressed text to the - # output filepath. - # Default output filepath is the input filepath minus the last three characters - # (e.g. "foo.jsonlz4" becomes "foo.json") - filepath_in = args[0] - if len(args) < 2: - filepath_out = filepath_in[:-3] - else: - filepath_out = args[1] - text = mozlz4_to_text(filepath_in) - with open(filepath_out, "wb") as outfile: - outfile.write(text) - print("Wrote decompressed text to {}".format(filepath_out)) + # Given command-line arguments of an input filepath for a ".mozlz4" file + # and optionally an output filepath, write the decompressed text to the + # output filepath. + # Default output filepath is the input filepath minus the last three characters + # (e.g. "foo.jsonlz4" becomes "foo.json") + filepath_in = args[0] + if len(args) < 2: + filepath_out = filepath_in[:-3] + else: + filepath_out = args[1] + text = mozlz4_to_text(filepath_in) + with open(filepath_out, "wb") as outfile: + outfile.write(text) + print("Wrote decompressed text to {}".format(filepath_out)) if __name__ == "__main__": - import sys - args = sys.argv[1:] - if args and not args[0] in ("--help", "-h"): - main(args) - else: - print("Usage: mozlz4.py <mozlz4 file to read> <location to write>") + import sys + + args = sys.argv[1:] + if args and not args[0] in ("--help", "-h"): + main(args) + else: + print("Usage: mozlz4.py <mozlz4 file to read> <location to write>") diff --git a/hm/soispha/conf/firefox/scripts/update_extensions.sh b/hm/soispha/conf/firefox/scripts/update_extensions.sh index f8ed3a9a..83b0146d 100755 --- a/hm/soispha/conf/firefox/scripts/update_extensions.sh +++ b/hm/soispha/conf/firefox/scripts/update_extensions.sh @@ -1,8 +1,7 @@ #!/bin/sh - tmp=$(mktemp) -cat << EOF > "$tmp" +cat <<EOF >"$tmp" darkreader:navbar keepassxc-browser:navbar vhack-libredirect:navbar @@ -15,8 +14,6 @@ EOF # The bin is provided in the devshell; # The cat execution should be unquoted; # shellcheck disable=SC2046 -generate_extensions $(cat "$tmp") > "$(dirname "$0")"/../config/extensions/extensions.json - - +generate_extensions $(cat "$tmp") >"$(dirname "$0")"/../config/extensions/extensions.json -rm "$tmp"; +rm "$tmp" diff --git a/hm/soispha/conf/git/scripts/commit.sh b/hm/soispha/conf/git/scripts/commit.sh index 9baf93bb..c0d706e2 100755 --- a/hm/soispha/conf/git/scripts/commit.sh +++ b/hm/soispha/conf/git/scripts/commit.sh @@ -3,17 +3,16 @@ # shellcheck source=/dev/null SHELL_LIBRARY_VERSION="2.0.13" . %SHELL_LIBRARY_PATH -ROOT="$(git rev-parse --show-toplevel)"; +ROOT="$(git rev-parse --show-toplevel)" # Take first line from previous commit if [ -f "$ROOT/.git/COMMIT_EDITMSG" ]; then - sed '1s/\(.*\)\((.*)\)\?\(:.*\)/\1\2: /;1p;d' "$ROOT/.git/COMMIT_EDITMSG" > "$ROOT/.git/COMMIT_TEMPLATE" + sed '1s/\(.*\)\((.*)\)\?\(:.*\)/\1\2: /;1p;d' "$ROOT/.git/COMMIT_EDITMSG" >"$ROOT/.git/COMMIT_TEMPLATE" else - printf "\n" > "$ROOT/.git/COMMIT_TEMPLATE" + printf "\n" >"$ROOT/.git/COMMIT_TEMPLATE" fi -sed '1d' "$(git config commit.template)" >> "$ROOT/.git/COMMIT_TEMPLATE" +sed '1d' "$(git config commit.template)" >>"$ROOT/.git/COMMIT_TEMPLATE" git commit --template "$ROOT/.git/COMMIT_TEMPLATE" --verbose "$@" - # vim: ft=sh diff --git a/hm/soispha/conf/lf/commands/default.nix b/hm/soispha/conf/lf/commands/default.nix index 1cb6996a..f5372a38 100644 --- a/hm/soispha/conf/lf/commands/default.nix +++ b/hm/soispha/conf/lf/commands/default.nix @@ -233,7 +233,7 @@ in { gnutar unzip # TODO: this is unfree! unrar - + p7zip ; }; diff --git a/hm/soispha/conf/lf/commands/scripts/archive.sh b/hm/soispha/conf/lf/commands/scripts/archive.sh index 5f4e3792..9ac07898 100755 --- a/hm/soispha/conf/lf/commands/scripts/archive.sh +++ b/hm/soispha/conf/lf/commands/scripts/archive.sh @@ -9,46 +9,52 @@ SHELL_LIBRARY_VERSION="2.0.13" . %SHELL_LIBRARY_PATH # times. set -f -archivers="$(tmp echo gzip xz 7z zip)"; +# shellcheck disable=SC2269 +f="$f" +# shellcheck disable=SC2269 +fx="$fx" +# shellcheck disable=SC2269 +fs="$fs" + +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: " +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 - fi done -root="$(if [ "$(pwd)" = "/" ]; then pwd; else echo "$(pwd)/";fi)"; +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")"; + 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 "$@" - ;; +"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/hm/soispha/conf/lf/commands/scripts/broot_jump.sh b/hm/soispha/conf/lf/commands/scripts/broot_jump.sh index 0feb5daf..4afb36ac 100755 --- a/hm/soispha/conf/lf/commands/scripts/broot_jump.sh +++ b/hm/soispha/conf/lf/commands/scripts/broot_jump.sh @@ -3,6 +3,15 @@ # shellcheck source=/dev/null SHELL_LIBRARY_VERSION="2.0.13" . %SHELL_LIBRARY_PATH +# shellcheck disable=SC2269 +f="$f" +# shellcheck disable=SC2269 +fx="$fx" +# shellcheck disable=SC2269 +fs="$fs" +# shellcheck disable=SC2269 +id="$id" + tmp=$(mktmp) res="$(broot --outcmd "$tmp" && sed 's/cd //' "$tmp")" diff --git a/hm/soispha/conf/lf/commands/scripts/chmod.sh b/hm/soispha/conf/lf/commands/scripts/chmod.sh index f2cc0dc8..81373352 100755 --- a/hm/soispha/conf/lf/commands/scripts/chmod.sh +++ b/hm/soispha/conf/lf/commands/scripts/chmod.sh @@ -3,11 +3,22 @@ # shellcheck source=/dev/null SHELL_LIBRARY_VERSION="2.0.13" . %SHELL_LIBRARY_PATH +# shellcheck disable=SC2269 +f="$f" +# shellcheck disable=SC2269 +fx="$fx" +# shellcheck disable=SC2269 +fs="$fs" +# shellcheck disable=SC2269 +id="$id" + readp "Mode bits: " bits +# shellcheck disable=SC2269 +bits="$bits" while read -r file; do chmod "$bits" "$file" -done < "$(tmp echo "$fx")" +done <"$(tmp echo "$fx")" lf -remote 'send reload' # vim: ft=sh diff --git a/hm/soispha/conf/lf/commands/scripts/cow_cp.sh b/hm/soispha/conf/lf/commands/scripts/cow_cp.sh index 85fd3431..c17b7668 100755 --- a/hm/soispha/conf/lf/commands/scripts/cow_cp.sh +++ b/hm/soispha/conf/lf/commands/scripts/cow_cp.sh @@ -1,8 +1,17 @@ -#!/usr/bin/env dash +#!/usr/bin/env bash # shellcheck source=/dev/null SHELL_LIBRARY_VERSION="2.0.13" . %SHELL_LIBRARY_PATH +# shellcheck disable=SC2269 +f="$f" +# shellcheck disable=SC2269 +fx="$fx" +# shellcheck disable=SC2269 +fs="$fs" +# shellcheck disable=SC2269 +id="$id" + # source: https://github.com/gokcehan/lf/wiki/Tips#use-copy-on-write-when-possible # # # FIXME: Add this. The hardest part is in checking, if a file can be reflinked, as fuse and bind mount are hard to @@ -31,13 +40,13 @@ if [ "$mode" = 'copy' ]; then src_targets="$(df --output=target -- "$@" | sed '1d' | sort -u)" if [ "$(df --output=target -- "$PWD" | tail -n 1)" = \ - "$(echo "$src_targets" | tail -n 1)" ] && \ - (( "$(echo "$src_targets" | wc -l)" == 1 )) && \ + "$(echo "$src_targets" | tail -n 1)" ] && + (("$(echo "$src_targets" | wc -l)" == 1)) && [[ "$(df --output=fstype -- "$PWD" | tail -n 1)" =~ ^(btrfs|xfs|zfs)$ ]]; then - echo 'selected copy and cp reflink paste' + echo 'selected copy and cp reflink paste' - start=$(date '+%s') + start=$(date '+%s') # Handle same names in dst # TODO parallelism, idk - but exit/return/break won't stop the loop from subshell... @@ -47,7 +56,7 @@ if [ "$mode" = 'copy' ]; then count=0 while [ -w "$PWD/$name" ]; do - count=$((count+1)) + count=$((count + 1)) name="$original.~$count~" done @@ -55,15 +64,15 @@ if [ "$mode" = 'copy' ]; then cp_out="$(cp -rn --reflink=always -- "$i" "$PWD/$name" 2>&1)" set -e - if [ ! -z "$cp_out" ]; then + if [ -n "$cp_out" ]; then lf -remote "send $id echoerr $cp_out" exit 0 fi done - finish=$(( $(date '+%s') - $start )) + finish=$(($(date '+%s') - start)) t='' - if (( $finish > 2 )); then + if ((finish > 2)); then t="${finish}s" fi @@ -80,14 +89,14 @@ if [ "$mode" = 'copy' ]; then echo 'selected copy and lf native paste' lf -remote "send $id paste" lf -remote "send clear" - fi - - elif [ $mode = 'move' ]; then - echo 'selected move and lf native paste' - lf -remote "send $id paste" - lf -remote "send clear" fi +elif [ "$mode" = 'move' ]; then + echo 'selected move and lf native paste' + lf -remote "send $id paste" + lf -remote "send clear" +fi + # # for debug # set +x diff --git a/hm/soispha/conf/lf/commands/scripts/dl_file.sh b/hm/soispha/conf/lf/commands/scripts/dl_file.sh index 5092174f..4f97f9b9 100755 --- a/hm/soispha/conf/lf/commands/scripts/dl_file.sh +++ b/hm/soispha/conf/lf/commands/scripts/dl_file.sh @@ -3,31 +3,41 @@ # shellcheck source=/dev/null SHELL_LIBRARY_VERSION="2.0.13" . %SHELL_LIBRARY_PATH +# shellcheck disable=SC2269 +f="$f" +# shellcheck disable=SC2269 +fx="$fx" +# shellcheck disable=SC2269 +fs="$fs" +# shellcheck disable=SC2269 +id="$id" + # 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 + 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 + 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" + # Download the file with curl + if [ -n "$name" ]; then + curl -o "$name" "$url" || die "curl failed" + fi else - die "URL is null!" + die "URL is null!" fi # vim: ft=sh diff --git a/hm/soispha/conf/lf/commands/scripts/dragon.sh b/hm/soispha/conf/lf/commands/scripts/dragon.sh index 59a50920..70633583 100755 --- a/hm/soispha/conf/lf/commands/scripts/dragon.sh +++ b/hm/soispha/conf/lf/commands/scripts/dragon.sh @@ -3,9 +3,18 @@ # shellcheck source=/dev/null SHELL_LIBRARY_VERSION="2.0.13" . %SHELL_LIBRARY_PATH +# shellcheck disable=SC2269 +f="$f" +# shellcheck disable=SC2269 +fx="$fx" +# shellcheck disable=SC2269 +fs="$fs" +# shellcheck disable=SC2269 +id="$id" + while read -r file; do set -- "$@" "$file" -done < "$(tmp echo "$fx")" +done <"$(tmp echo "$fx")" dragon -a -x "$@" # vim: ft=sh diff --git a/hm/soispha/conf/lf/commands/scripts/dragon_individual.sh b/hm/soispha/conf/lf/commands/scripts/dragon_individual.sh index 051537f9..500be67c 100755 --- a/hm/soispha/conf/lf/commands/scripts/dragon_individual.sh +++ b/hm/soispha/conf/lf/commands/scripts/dragon_individual.sh @@ -3,9 +3,18 @@ # shellcheck source=/dev/null SHELL_LIBRARY_VERSION="2.0.13" . %SHELL_LIBRARY_PATH +# shellcheck disable=SC2269 +f="$f" +# shellcheck disable=SC2269 +fx="$fx" +# shellcheck disable=SC2269 +fs="$fs" +# shellcheck disable=SC2269 +id="$id" + while read -r file; do set -- "$@" "$file" -done < "$(tmp echo "$fx")" +done <"$(tmp echo "$fx")" dragon "$@" # vim: ft=sh diff --git a/hm/soispha/conf/lf/commands/scripts/dragon_stay.sh b/hm/soispha/conf/lf/commands/scripts/dragon_stay.sh index 8f880848..273482ea 100755 --- a/hm/soispha/conf/lf/commands/scripts/dragon_stay.sh +++ b/hm/soispha/conf/lf/commands/scripts/dragon_stay.sh @@ -3,9 +3,18 @@ # shellcheck source=/dev/null SHELL_LIBRARY_VERSION="2.0.13" . %SHELL_LIBRARY_PATH +# shellcheck disable=SC2269 +f="$f" +# shellcheck disable=SC2269 +fx="$fx" +# shellcheck disable=SC2269 +fs="$fs" +# shellcheck disable=SC2269 +id="$id" + while read -r file; do - set -- "$@" "$file"; -done < "$(tmp echo "$fx")" + set -- "$@" "$file" +done <"$(tmp echo "$fx")" dragon -a "$@" # vim: ft=sh diff --git a/hm/soispha/conf/lf/commands/scripts/fzf_jump.sh b/hm/soispha/conf/lf/commands/scripts/fzf_jump.sh index 172c44d3..6f8981f3 100755 --- a/hm/soispha/conf/lf/commands/scripts/fzf_jump.sh +++ b/hm/soispha/conf/lf/commands/scripts/fzf_jump.sh @@ -5,12 +5,20 @@ SHELL_LIBRARY_VERSION="2.0.13" . %SHELL_LIBRARY_PATH res="$(fd . --maxdepth 3 | fzf --header='Jump to location')" +# shellcheck disable=SC2269 +f="$f" +# shellcheck disable=SC2269 +fx="$fx" +# shellcheck disable=SC2269 +fs="$fs" +# shellcheck disable=SC2269 +id="$id" + 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/hm/soispha/conf/lf/commands/scripts/go_project_root.sh b/hm/soispha/conf/lf/commands/scripts/go_project_root.sh index 9ed9f7ad..e1147fce 100755 --- a/hm/soispha/conf/lf/commands/scripts/go_project_root.sh +++ b/hm/soispha/conf/lf/commands/scripts/go_project_root.sh @@ -3,11 +3,20 @@ # shellcheck source=/dev/null SHELL_LIBRARY_VERSION="2.0.13" . %SHELL_LIBRARY_PATH -flake_base_dir="$(search_flake_base_dir)"; +# shellcheck disable=SC2269 +f="$f" +# shellcheck disable=SC2269 +fx="$fx" +# shellcheck disable=SC2269 +fs="$fs" +# shellcheck disable=SC2269 +id="$id" + +flake_base_dir="$(search_flake_base_dir)" if [ "$flake_base_dir" ]; then lf -remote "send $id cd $flake_base_dir" || die "Bug: No base dir ($flake_base_dir)" else - die "Unable to locate base dir"; + die "Unable to locate base dir" fi # vim: ft=sh diff --git a/hm/soispha/conf/lf/commands/scripts/mk_dir.sh b/hm/soispha/conf/lf/commands/scripts/mk_dir.sh index adf60d99..6079b85d 100755 --- a/hm/soispha/conf/lf/commands/scripts/mk_dir.sh +++ b/hm/soispha/conf/lf/commands/scripts/mk_dir.sh @@ -3,21 +3,29 @@ # shellcheck source=/dev/null SHELL_LIBRARY_VERSION="2.0.13" . %SHELL_LIBRARY_PATH +# shellcheck disable=SC2269 +f="$f" +# shellcheck disable=SC2269 +fx="$fx" +# shellcheck disable=SC2269 +fs="$fs" +# shellcheck disable=SC2269 +id="$id" + 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 +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: " + if [ "$ans" = "y" ]; then + break + else + prompt "Directory Name: " + fi fi - fi done mkdir "$name" diff --git a/hm/soispha/conf/lf/commands/scripts/mk_file.sh b/hm/soispha/conf/lf/commands/scripts/mk_file.sh index cdef38a0..9fb0a000 100755 --- a/hm/soispha/conf/lf/commands/scripts/mk_file.sh +++ b/hm/soispha/conf/lf/commands/scripts/mk_file.sh @@ -3,21 +3,29 @@ # shellcheck source=/dev/null SHELL_LIBRARY_VERSION="2.0.13" . %SHELL_LIBRARY_PATH +# shellcheck disable=SC2269 +f="$f" +# shellcheck disable=SC2269 +fx="$fx" +# shellcheck disable=SC2269 +fs="$fs" +# shellcheck disable=SC2269 +id="$id" + 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 +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: " + if [ "$ans" = "y" ]; then + break + else + prompt "File name: " + fi fi - fi done touch "$name" diff --git a/hm/soispha/conf/lf/commands/scripts/mk_file_and_edit.sh b/hm/soispha/conf/lf/commands/scripts/mk_file_and_edit.sh index 662b29ac..2007cc99 100755 --- a/hm/soispha/conf/lf/commands/scripts/mk_file_and_edit.sh +++ b/hm/soispha/conf/lf/commands/scripts/mk_file_and_edit.sh @@ -3,21 +3,29 @@ # shellcheck source=/dev/null SHELL_LIBRARY_VERSION="2.0.13" . %SHELL_LIBRARY_PATH +# shellcheck disable=SC2269 +f="$f" +# shellcheck disable=SC2269 +fx="$fx" +# shellcheck disable=SC2269 +fs="$fs" +# shellcheck disable=SC2269 +id="$id" + 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 +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: " + if [ "$ans" = "y" ]; then + break + else + prompt "File name: " + fi fi - fi done touch "$name" diff --git a/hm/soispha/conf/lf/commands/scripts/mk_ln.sh b/hm/soispha/conf/lf/commands/scripts/mk_ln.sh index f5dcd395..e767c848 100755 --- a/hm/soispha/conf/lf/commands/scripts/mk_ln.sh +++ b/hm/soispha/conf/lf/commands/scripts/mk_ln.sh @@ -3,9 +3,18 @@ # shellcheck source=/dev/null SHELL_LIBRARY_VERSION="2.0.13" . %SHELL_LIBRARY_PATH -while IFS= read -r i;do +# shellcheck disable=SC2269 +f="$f" +# shellcheck disable=SC2269 +fx="$fx" +# shellcheck disable=SC2269 +fs="$fs" +# shellcheck disable=SC2269 +id="$id" + +while IFS= read -r i; do set -- "$@" "$i" -done < "$HOME"/.local/share/lf/files +done <"$HOME"/.local/share/lf/files mode="$1" shift @@ -16,20 +25,20 @@ if [ "$#" -eq 0 ]; then 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 +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" diff --git a/hm/soispha/conf/lf/commands/scripts/mk_scr_default.sh b/hm/soispha/conf/lf/commands/scripts/mk_scr_default.sh index 6e69fc4f..915725cc 100755 --- a/hm/soispha/conf/lf/commands/scripts/mk_scr_default.sh +++ b/hm/soispha/conf/lf/commands/scripts/mk_scr_default.sh @@ -3,29 +3,35 @@ # shellcheck source=/dev/null SHELL_LIBRARY_VERSION="2.0.13" . %SHELL_LIBRARY_PATH +# shellcheck disable=SC2269 +f="$f" +# shellcheck disable=SC2269 +fx="$fx" +# shellcheck disable=SC2269 +fs="$fs" +# shellcheck disable=SC2269 +id="$id" 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: " +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 - fi done script="$(pwd)"/"$name" -cat "%SHELL_LIBRARY_TEMPLATE" > "$script" +cat "%SHELL_LIBRARY_TEMPLATE" >"$script" chmod +x "$script" "$VISUAL" "$script" - # vim: ft=sh diff --git a/hm/soispha/conf/lf/commands/scripts/mk_scr_temp.sh b/hm/soispha/conf/lf/commands/scripts/mk_scr_temp.sh index 612ff19d..0f8394fa 100755 --- a/hm/soispha/conf/lf/commands/scripts/mk_scr_temp.sh +++ b/hm/soispha/conf/lf/commands/scripts/mk_scr_temp.sh @@ -3,30 +3,36 @@ # shellcheck source=/dev/null SHELL_LIBRARY_VERSION="2.0.13" . %SHELL_LIBRARY_PATH +# shellcheck disable=SC2269 +f="$f" +# shellcheck disable=SC2269 +fx="$fx" +# shellcheck disable=SC2269 +fs="$fs" +# shellcheck disable=SC2269 +id="$id" 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: " +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 - fi done script="$(pwd)"/"$name" -sed 's|%TO_BE_SHELL_LIBRARY_PATH|%SHELL_LIBRARY_PATH|' "%SHELL_LIBRARY_TEMPLATE" > "$script" +sed 's|%TO_BE_SHELL_LIBRARY_PATH|%SHELL_LIBRARY_PATH|' "%SHELL_LIBRARY_TEMPLATE" >"$script" sed -i 's|dash|sh|' "$script" chmod +x "$script" "$VISUAL" "$script" - # vim: ft=sh diff --git a/hm/soispha/conf/lf/commands/scripts/open.sh b/hm/soispha/conf/lf/commands/scripts/open.sh index 3dd8f485..4df06dd8 100755 --- a/hm/soispha/conf/lf/commands/scripts/open.sh +++ b/hm/soispha/conf/lf/commands/scripts/open.sh @@ -3,9 +3,18 @@ # shellcheck source=/dev/null SHELL_LIBRARY_VERSION="2.0.13" . %SHELL_LIBRARY_PATH +# shellcheck disable=SC2269 +f="$f" +# shellcheck disable=SC2269 +fx="$fx" +# shellcheck disable=SC2269 +fs="$fs" +# shellcheck disable=SC2269 +id="$id" + case $(file --mime-type "$f" -bL) in - text/*|application/json|application/vnd.hp-HPGL) "$EDITOR" "$f";; - image/*) "$IVIEWER" "$f";; - *) xdg-open "$f";; +text/* | application/json | application/vnd.hp-HPGL) "$EDITOR" "$f" ;; +image/*) "$IVIEWER" "$f" ;; +*) xdg-open "$f" ;; esac # vim: ft=sh diff --git a/hm/soispha/conf/lf/commands/scripts/open_config.sh b/hm/soispha/conf/lf/commands/scripts/open_config.sh index 4054abdd..455ca25a 100755 --- a/hm/soispha/conf/lf/commands/scripts/open_config.sh +++ b/hm/soispha/conf/lf/commands/scripts/open_config.sh @@ -3,5 +3,14 @@ # shellcheck source=/dev/null SHELL_LIBRARY_VERSION="2.0.13" . %SHELL_LIBRARY_PATH +# shellcheck disable=SC2269 +f="$f" +# shellcheck disable=SC2269 +fx="$fx" +# shellcheck disable=SC2269 +fs="$fs" +# shellcheck disable=SC2269 +id="$id" + "$EDITOR" "$(bookmenu -b ~/.config/bookmenu/configs -f fzf -o)" # TODO: implement this # vim: ft=sh diff --git a/hm/soispha/conf/lf/commands/scripts/restore_trash.sh b/hm/soispha/conf/lf/commands/scripts/restore_trash.sh index 94d26a26..7aeed7bf 100755 --- a/hm/soispha/conf/lf/commands/scripts/restore_trash.sh +++ b/hm/soispha/conf/lf/commands/scripts/restore_trash.sh @@ -3,5 +3,14 @@ # shellcheck source=/dev/null SHELL_LIBRARY_VERSION="2.0.13" . %SHELL_LIBRARY_PATH +# shellcheck disable=SC2269 +f="$f" +# shellcheck disable=SC2269 +fx="$fx" +# shellcheck disable=SC2269 +fs="$fs" +# shellcheck disable=SC2269 +id="$id" + trash list | fzf --multi | awk '{print $NF}' | xargs trash restore --match=exact # vim: ft=sh diff --git a/hm/soispha/conf/lf/commands/scripts/set_wall_paper.sh b/hm/soispha/conf/lf/commands/scripts/set_wall_paper.sh index f7714880..828c0708 100755 --- a/hm/soispha/conf/lf/commands/scripts/set_wall_paper.sh +++ b/hm/soispha/conf/lf/commands/scripts/set_wall_paper.sh @@ -3,6 +3,15 @@ # shellcheck source=/dev/null SHELL_LIBRARY_VERSION="2.0.13" . %SHELL_LIBRARY_PATH +# shellcheck disable=SC2269 +f="$f" +# shellcheck disable=SC2269 +fx="$fx" +# shellcheck disable=SC2269 +fs="$fs" +# shellcheck disable=SC2269 +id="$id" + die "No yet implemented" # TODO: do what the 'die' says #sed -i "s,export AWMWALLPAPER='.*',export AWMWALLPAPER='${f}'," ${ZDOTDIR}/.zshenv #nohub swaybg -i "$f" diff --git a/hm/soispha/conf/lf/commands/scripts/stripspace.sh b/hm/soispha/conf/lf/commands/scripts/stripspace.sh index c8781a60..65eefbcd 100755 --- a/hm/soispha/conf/lf/commands/scripts/stripspace.sh +++ b/hm/soispha/conf/lf/commands/scripts/stripspace.sh @@ -3,11 +3,20 @@ # shellcheck source=/dev/null SHELL_LIBRARY_VERSION="2.0.13" . %SHELL_LIBRARY_PATH -files=$(mktmp); -echo "$fx" > "$files"; +# shellcheck disable=SC2269 +f="$f" +# shellcheck disable=SC2269 +fx="$fx" +# shellcheck disable=SC2269 +fs="$fs" +# shellcheck disable=SC2269 +id="$id" -awk_source=$(mktmp); -cat << OFT > "$awk_source" +files=$(mktmp) +echo "$fx" >"$files" + +awk_source=$(mktmp) +cat <<OFT >"$awk_source" BEGIN {FS=" "} {for (i=1; i != NF + 1; i++) if (i == NF) { @@ -21,11 +30,11 @@ OFT while read -r file; do dirty_name=$(mktmp) - basename "$file" > "$dirty_name"; - clean_name=$(awk -f "$awk_source" "$dirty_name"); + 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"; + [ -e "$clean_name" ] && die "file \"$clean_name\" already exists!" + mv "$(cat "$dirty_name")" "$clean_name" || die "Move failed" lf -remote 'send reload' -done < "$files"; +done <"$files" # vim: ft=sh diff --git a/hm/soispha/conf/lf/commands/scripts/trash.sh b/hm/soispha/conf/lf/commands/scripts/trash.sh index 4da188e5..c605420e 100755 --- a/hm/soispha/conf/lf/commands/scripts/trash.sh +++ b/hm/soispha/conf/lf/commands/scripts/trash.sh @@ -3,26 +3,35 @@ # shellcheck source=/dev/null SHELL_LIBRARY_VERSION="2.0.13" . %SHELL_LIBRARY_PATH -trash_output=$(mktmp); -expected_error_output=$(mktmp); +# shellcheck disable=SC2269 +f="$f" +# shellcheck disable=SC2269 +fx="$fx" +# shellcheck disable=SC2269 +fs="$fs" +# shellcheck disable=SC2269 +id="$id" + +trash_output=$(mktmp) +expected_error_output=$(mktmp) while read -r file; do set -- "$@" "$file" -done < "$(tmp echo "$fx")" +done <"$(tmp echo "$fx")" # TODO: why are we using trashy at all, when trash-cli can do everything? # # try trashy first, through nix because both trashy and trash-cli provide a trash command, which conflicts -nix run nixpkgs#trashy -- put "$@" 2> "$trash_output"; +nix run nixpkgs#trashy -- put "$@" 2>"$trash_output" # FIXME: Find a way, that does not depend on parsing an error message <2023-08-29> -cat << EOF > "$expected_error_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"; +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 "$@"; + trash-put "$@" fi # vim: ft=sh diff --git a/hm/soispha/conf/lf/commands/scripts/unarchive.sh b/hm/soispha/conf/lf/commands/scripts/unarchive.sh index 1ecc702b..d52eee61 100755 --- a/hm/soispha/conf/lf/commands/scripts/unarchive.sh +++ b/hm/soispha/conf/lf/commands/scripts/unarchive.sh @@ -3,20 +3,29 @@ # shellcheck source=/dev/null SHELL_LIBRARY_VERSION="2.0.13" . %SHELL_LIBRARY_PATH +# shellcheck disable=SC2269 +f="$f" +# shellcheck disable=SC2269 +fx="$fx" +# shellcheck disable=SC2269 +fs="$fs" +# shellcheck disable=SC2269 +id="$id" + # 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" ;; +*.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 diff --git a/hm/soispha/conf/nvim/files/ftplugin/tex.lua b/hm/soispha/conf/nvim/files/ftplugin/tex.lua index 05a2c593..f3fffa86 100644 --- a/hm/soispha/conf/nvim/files/ftplugin/tex.lua +++ b/hm/soispha/conf/nvim/files/ftplugin/tex.lua @@ -19,40 +19,39 @@ -- -- - -- Set tex specific telescope extension require("telescope").setup({ extensions = { bibtex = { -- Depth for the *.bib file - depth = 1; + depth = 1, -- Path to global bibliographies (placed outside of the project) - global_files = {}; + global_files = {}, -- Define the search keys to use in the picker - search_keys = { "author"; "year"; "title"; }; + search_keys = { "author", "year", "title" }, -- Template for the formatted citation - citation_format = "{{author}} ({{year}}), {{title}}."; + citation_format = "{{author}} ({{year}}), {{title}}.", -- Only use initials for the authors first name - citation_trim_firstname = true; + citation_trim_firstname = true, -- Max number of authors to write in the formatted citation -- following authors will be replaced by "et al." - citation_max_auth = 2; + citation_max_auth = 2, -- Wrapping in the preview window is disabled by default - wrap = false; + wrap = false, -- Custom format for citation label custom_formats = { - { id = "tex_autocite"; cite_marker = "\\autocite{%s}"; }; - }; - format = "tex_autocite"; + { id = "tex_autocite", cite_marker = "\\autocite{%s}" }, + }, + format = "tex_autocite", -- Use context awareness - context = true; + context = true, -- Fallback to global/directory .bib files if context not found -- This setting has no effect if context = false - context_fallback = true; - }; - }; + context_fallback = true, + }, + }, }) require("telescope").load_extension("bibtex") vim.keymap.set("n", "<leader>ib", function() - require("telescope").extensions.bibtex.bibtex() - end, { noremap = true; silent = true; desc = "list bibtex entries in telescope"; }) + require("telescope").extensions.bibtex.bibtex() +end, { noremap = true, silent = true, desc = "list bibtex entries in telescope" }) diff --git a/hm/soispha/conf/nvim/plgs/colorscheme/lua/mk_todos_readable.lua b/hm/soispha/conf/nvim/plgs/colorscheme/lua/mk_todos_readable.lua index ee28151c..d02171b5 100644 --- a/hm/soispha/conf/nvim/plgs/colorscheme/lua/mk_todos_readable.lua +++ b/hm/soispha/conf/nvim/plgs/colorscheme/lua/mk_todos_readable.lua @@ -1,17 +1,16 @@ -local opts = { bg = "NONE"; bold = true; } - +local opts = { bg = "NONE", bold = true } ---@param hl_group string: The name of the hl group ---@param extra_opts table: Extra options to pass to nvim_set_hl local set_hl = function(hl_group, extra_opts) - local local_opts = vim.deepcopy(opts); + local local_opts = vim.deepcopy(opts) for k, v in ipairs(extra_opts) do - local_opts[k] = v; + local_opts[k] = v end vim.api.nvim_set_hl(0, hl_group, local_opts) end -set_hl("@text.danger", { fg = "red"; }) -set_hl("@text.note", { fg = "blue"; }) -set_hl("@text.todo", { fg = "green"; }) -set_hl("@text.warning", { fg = "yellow"; }) +set_hl("@text.danger", { fg = "red" }) +set_hl("@text.note", { fg = "blue" }) +set_hl("@text.todo", { fg = "green" }) +set_hl("@text.warning", { fg = "yellow" }) diff --git a/hm/soispha/conf/nvim/plgs/colorscheme/lua/nightfox.lua b/hm/soispha/conf/nvim/plgs/colorscheme/lua/nightfox.lua index 025eb133..4c502153 100644 --- a/hm/soispha/conf/nvim/plgs/colorscheme/lua/nightfox.lua +++ b/hm/soispha/conf/nvim/plgs/colorscheme/lua/nightfox.lua @@ -1,44 +1,44 @@ require("nightfox").setup({ options = { -- Compiled file's destination location - compile_path = vim.fn.stdpath("cache") .. "/nightfox"; - compile_file_suffix = "_compiled"; -- Compiled file suffix - transparent = true; -- Disable setting background - terminal_colors = true; -- Set terminal colors (vim.g.terminal_color_*) used in `:terminal` - dim_inactive = true; -- Non focused panes set to alternative background - module_default = true; -- Default enable value for modules + compile_path = vim.fn.stdpath("cache") .. "/nightfox", + compile_file_suffix = "_compiled", -- Compiled file suffix + transparent = true, -- Disable setting background + terminal_colors = true, -- Set terminal colors (vim.g.terminal_color_*) used in `:terminal` + dim_inactive = true, -- Non focused panes set to alternative background + module_default = true, -- Default enable value for modules colorblind = { - enable = true; -- Enable colorblind support - simulate_only = false; -- Only show simulated colorblind colors and not diff shifted + enable = true, -- Enable colorblind support + simulate_only = false, -- Only show simulated colorblind colors and not diff shifted severity = { - protan = 0.3; -- Severity [0,1] for protan (red) - deutan = 0.9; -- Severity [0,1] for deutan (green) - tritan = 0; -- Severity [0,1] for tritan (blue) - }; - }; - styles = { -- Style to be applied to different syntax groups - comments = "italic"; -- Value is any valid attr-list value `:help attr-list` - conditionals = "NONE"; - constants = "NONE"; - functions = "bold"; - keywords = "bold"; - numbers = "NONE"; - operators = "NONE"; - strings = "NONE"; - types = "NONE"; - variables = "NONE"; - }; + protan = 0.3, -- Severity [0,1] for protan (red) + deutan = 0.9, -- Severity [0,1] for deutan (green) + tritan = 0, -- Severity [0,1] for tritan (blue) + }, + }, + styles = { -- Style to be applied to different syntax groups + comments = "italic", -- Value is any valid attr-list value `:help attr-list` + conditionals = "NONE", + constants = "NONE", + functions = "bold", + keywords = "bold", + numbers = "NONE", + operators = "NONE", + strings = "NONE", + types = "NONE", + variables = "NONE", + }, inverse = { -- Inverse highlight for different types - match_paren = false; - visual = false; - search = false; - }; + match_paren = false, + visual = false, + search = false, + }, modules = { -- List of various plugins and additional options - diagnostic = { enable = true; background = false; }; - native_lsp = { enable = true; background = false; }; - }; - }; - palettes = {}; - specs = {}; - groups = {}; + diagnostic = { enable = true, background = false }, + native_lsp = { enable = true, background = false }, + }, + }, + palettes = {}, + specs = {}, + groups = {}, }) diff --git a/hm/soispha/conf/nvim/plgs/debugprint/lua/debugprint.lua b/hm/soispha/conf/nvim/plgs/debugprint/lua/debugprint.lua index 2ea38df4..da7e1735 100644 --- a/hm/soispha/conf/nvim/plgs/debugprint/lua/debugprint.lua +++ b/hm/soispha/conf/nvim/plgs/debugprint/lua/debugprint.lua @@ -1,4 +1,3 @@ require("debugprint").setup({ - create_keymaps = false; + create_keymaps = false, }) - diff --git a/hm/soispha/conf/nvim/plgs/femaco/lua/femaco.lua b/hm/soispha/conf/nvim/plgs/femaco/lua/femaco.lua index 10064b5e..da3be8e1 100644 --- a/hm/soispha/conf/nvim/plgs/femaco/lua/femaco.lua +++ b/hm/soispha/conf/nvim/plgs/femaco/lua/femaco.lua @@ -1,4 +1,4 @@ -local clip_val = require('femaco.utils').clip_val +local clip_val = require("femaco.utils").clip_val require("femaco").setup({ -- should prepare a new buffer and return the winid -- by default opens a floating window @@ -7,7 +7,7 @@ require("femaco").setup({ prepare_buffer = function(opts) local buf = vim.api.nvim_create_buf(false, false) return vim.api.nvim_open_win(buf, true, opts) - end; + end, -- should return options passed to nvim_open_win -- @param code_block: data about the code-block with the keys -- * range @@ -15,30 +15,30 @@ require("femaco").setup({ -- * lang float_opts = function(code_block) return { - relative = "cursor"; - width = clip_val(5, 120, vim.api.nvim_win_get_width(0) - 10); -- TODO: how to offset sign column etc? - height = clip_val(5, #code_block.lines, vim.api.nvim_win_get_height(0) - 6); - anchor = "NW"; - row = 0; - col = 0; - style = "minimal"; - border = "rounded"; - zindex = 1; + relative = "cursor", + width = clip_val(5, 120, vim.api.nvim_win_get_width(0) - 10), -- TODO: how to offset sign column etc? + height = clip_val(5, #code_block.lines, vim.api.nvim_win_get_height(0) - 6), + anchor = "NW", + row = 0, + col = 0, + style = "minimal", + border = "rounded", + zindex = 1, } - end; + end, -- return filetype to use for a given lang -- lang can be nil ft_from_lang = function(lang) return lang - end; + end, -- what to do after opening the float post_open_float = function(winnr) vim.wo.signcolumn = "no" - end; + end, -- create the path to a temporary file create_tmp_filepath = function(filetype) return os.tmpname() - end; + end, -- if a newline should always be used, useful for multiline injections -- which separators needs to be on separate lines such as markdown, neorg etc -- @param base_filetype: The filetype which FeMaco is called from, not the @@ -46,5 +46,5 @@ require("femaco").setup({ -- get it from vim.bo.filetyp). ensure_newline = function(base_filetype) return false - end; + end, }) diff --git a/hm/soispha/conf/nvim/plgs/flatten-nvim/lua/flatten-nvim.lua b/hm/soispha/conf/nvim/plgs/flatten-nvim/lua/flatten-nvim.lua index 8db7d293..42ea1eb6 100644 --- a/hm/soispha/conf/nvim/plgs/flatten-nvim/lua/flatten-nvim.lua +++ b/hm/soispha/conf/nvim/plgs/flatten-nvim/lua/flatten-nvim.lua @@ -21,16 +21,16 @@ require("flatten").setup({ ---Called to determine if a nested session should wait for the host to close the file. ---param argv: a list of all the arguments in the nested session ---@type fun(argv: table): boolean - should_block = require("flatten").default_should_block; + should_block = require("flatten").default_should_block, ---If this returns true, the nested session will be opened. ---If false, default behavior is used, and ---config.nest_if_no_args is respected. ---@type fun(host: channel):boolean - should_nest = require("flatten").default_should_nest; + should_nest = require("flatten").default_should_nest, ---Called before a nested session is opened. - pre_open = function() end; + pre_open = function() end, ---Called after a nested session is opened. ---@param bufnr buffer @@ -42,27 +42,27 @@ require("flatten").setup({ -- If the file is a git commit, create one-shot autocmd to delete its buffer on write if filetype == "gitcommit" or filetype == "gitrebase" then vim.api.nvim_create_autocmd("BufWritePost", { - buffer = bufnr; - once = true; + buffer = bufnr, + once = true, callback = vim.schedule_wrap(function() vim.api.nvim_buf_delete(bufnr, {}) - end); + end), }) end - end; + end, ---Called when a nested session is done waiting for the host. ---@param filetype string - block_end = function(filetype) end; - }; + block_end = function(filetype) end, + }, -- <String, Bool> dictionary of filetypes that should be blocking block_for = { - gitcommit = true; - }; + gitcommit = true, + }, -- Command passthrough - allow_cmd_passthrough = true; + allow_cmd_passthrough = true, -- Allow a nested session to open if Neovim is opened without arguments - nest_if_no_args = false; + nest_if_no_args = false, -- Window options window = { -- Options: @@ -75,7 +75,7 @@ require("flatten").setup({ -- OpenHandler -> allows you to handle file opening yourself (see Types) -- -- TODO: Open gitcommit filetypes in the current buffer, everything else in a new tab <2023-08-29> - open = "split"; + open = "split", -- Options: -- vsplit -> opens files in diff vsplits @@ -83,24 +83,24 @@ require("flatten").setup({ -- tab_vsplit -> creates a new tabpage, and opens diff vsplits -- tab_split -> creates a new tabpage, and opens diff splits -- OpenHandler -> allows you to handle file opening yourself (see Types) - diff = "tab_vsplit"; + diff = "tab_vsplit", -- Affects which file gets focused when opening multiple at once -- Options: -- "first" -> open first file of new files (default) -- "last" -> open last file of new files - focus = "first"; - }; + focus = "first", + }, -- Override this function to use a different socket to connect to the host -- On the host side this can return nil or the socket address. -- On the guest side this should return the socket address -- or a non-zero channel id from `sockconnect` -- flatten.nvim will detect if the address refers to this instance of nvim, to determine if this is a host or a guest - pipe_path = require"flatten".default_pipe_path; + pipe_path = require("flatten").default_pipe_path, -- The `default_pipe_path` will treat the first nvim instance within a single kitty/wezterm session as the host -- You can configure this behaviour using the following: one_per = { - kitty = true; -- Flatten all instance in the current Kitty session - wezterm = true; -- Flatten all instance in the current Wezterm session - }; + kitty = true, -- Flatten all instance in the current Kitty session + wezterm = true, -- Flatten all instance in the current Wezterm session + }, }) diff --git a/hm/soispha/conf/nvim/plgs/goto-preview/lua/goto-preview.lua b/hm/soispha/conf/nvim/plgs/goto-preview/lua/goto-preview.lua index cde50d3e..9687a5a0 100644 --- a/hm/soispha/conf/nvim/plgs/goto-preview/lua/goto-preview.lua +++ b/hm/soispha/conf/nvim/plgs/goto-preview/lua/goto-preview.lua @@ -1,21 +1,21 @@ require("goto-preview").setup({ - width = 120; -- Width of the floating window - height = 15; -- Height of the floating window - border = { "↖"; "─"; "┐"; "│"; "┘"; "─"; "└"; "│"; }; -- Border characters of the floating window - default_mappings = false; -- Bind default mappings - debug = false; -- Print debug information - opacity = nil; -- 0-100 opacity level of the floating window where 100 is fully transparent. - resizing_mappings = false; -- Binds arrow keys to resizing the floating window. - post_open_hook = nil; -- A function taking two arguments, a buffer and a window to be ran as a hook. - post_close_hook = nil; -- A function taking two arguments, a buffer and a window to be ran as a hook. + width = 120, -- Width of the floating window + height = 15, -- Height of the floating window + border = { "↖", "─", "┐", "│", "┘", "─", "└", "│" }, -- Border characters of the floating window + default_mappings = false, -- Bind default mappings + debug = false, -- Print debug information + opacity = nil, -- 0-100 opacity level of the floating window where 100 is fully transparent. + resizing_mappings = false, -- Binds arrow keys to resizing the floating window. + post_open_hook = nil, -- A function taking two arguments, a buffer and a window to be ran as a hook. + post_close_hook = nil, -- A function taking two arguments, a buffer and a window to be ran as a hook. references = { -- Configure the telescope UI for slowing the references cycling window. - telescope = {}; -- require("telescope.themes").get_dropdown({ hide_preview = false }) - }; + telescope = {}, -- require("telescope.themes").get_dropdown({ hide_preview = false }) + }, -- These two configs can also be passed down to the goto-preview definition and implementation calls for one off "peak" functionality. - focus_on_open = true; -- Focus the floating window when opening it. - dismiss_on_move = false; -- Dismiss the floating window when moving the cursor. - force_close = true; -- passed into vim.api.nvim_win_close's second argument. See :h nvim_win_close - bufhidden = "wipe"; -- the bufhidden option to set on the floating window. See :h bufhidden - stack_floating_preview_windows = true; -- Whether to nest floating windows - preview_window_title = { enable = true; position = "left"; }; -- Whether to set the preview window title as the filename + focus_on_open = true, -- Focus the floating window when opening it. + dismiss_on_move = false, -- Dismiss the floating window when moving the cursor. + force_close = true, -- passed into vim.api.nvim_win_close's second argument. See :h nvim_win_close + bufhidden = "wipe", -- the bufhidden option to set on the floating window. See :h bufhidden + stack_floating_preview_windows = true, -- Whether to nest floating windows + preview_window_title = { enable = true, position = "left" }, -- Whether to set the preview window title as the filename }) diff --git a/hm/soispha/conf/nvim/plgs/lf-nvim/lua/lf-nvim.lua b/hm/soispha/conf/nvim/plgs/lf-nvim/lua/lf-nvim.lua index 8a0cf817..1eadf375 100644 --- a/hm/soispha/conf/nvim/plgs/lf-nvim/lua/lf-nvim.lua +++ b/hm/soispha/conf/nvim/plgs/lf-nvim/lua/lf-nvim.lua @@ -2,42 +2,42 @@ local fn = vim.fn -- Defaults require("lf").setup({ - default_action = "drop"; -- default action when `Lf` opens a file + default_action = "drop", -- default action when `Lf` opens a file -- TODO: what do these mappings do? - default_actions = { -- default action keybindings - ["<C-t>"] = "tabedit"; - ["<C-x>"] = "split"; - ["<C-v>"] = "vsplit"; - ["<C-o>"] = "tab drop"; - }; + default_actions = { -- default action keybindings + ["<C-t>"] = "tabedit", + ["<C-x>"] = "split", + ["<C-v>"] = "vsplit", + ["<C-o>"] = "tab drop", + }, - winblend = 10; -- psuedotransparency level - dir = ""; -- directory where `lf` starts ('gwd' is git-working-directory, ""/nil is CWD) - direction = "float"; -- window type: float horizontal vertical - border = "rounded"; -- border kind: single double shadow curved - height = fn.float2nr(fn.round(0.75 * vim.o.lines)); -- height of the *floating* window - width = fn.float2nr(fn.round(0.75 * vim.o.columns)); -- width of the *floating* window - escape_quit = true; -- map escape to the quit command (so it doesn't go into a meta normal mode) - focus_on_open = true; -- focus the current file when opening Lf (experimental) - mappings = true; -- whether terminal buffer mapping is enabled - tmux = false; -- tmux statusline can be disabled on opening of Lf - default_file_manager = true; -- make lf default file manager - disable_netrw_warning = true; -- don't display a message when opening a directory with `default_file_manager` as true - highlights = { -- highlights passed to toggleterm - Normal = { link = "Normal"; }; - NormalFloat = { link = "Normal"; }; - FloatBorder = { guifg = "#cdcbe0"; guibg = "#191726"; }; - }; + winblend = 10, -- psuedotransparency level + dir = "", -- directory where `lf` starts ('gwd' is git-working-directory, ""/nil is CWD) + direction = "float", -- window type: float horizontal vertical + border = "rounded", -- border kind: single double shadow curved + height = fn.float2nr(fn.round(0.75 * vim.o.lines)), -- height of the *floating* window + width = fn.float2nr(fn.round(0.75 * vim.o.columns)), -- width of the *floating* window + escape_quit = true, -- map escape to the quit command (so it doesn't go into a meta normal mode) + focus_on_open = true, -- focus the current file when opening Lf (experimental) + mappings = true, -- whether terminal buffer mapping is enabled + tmux = false, -- tmux statusline can be disabled on opening of Lf + default_file_manager = true, -- make lf default file manager + disable_netrw_warning = true, -- don't display a message when opening a directory with `default_file_manager` as true + highlights = { -- highlights passed to toggleterm + Normal = { link = "Normal" }, + NormalFloat = { link = "Normal" }, + FloatBorder = { guifg = "#cdcbe0", guibg = "#191726" }, + }, -- Layout configurations - layout_mapping = "<M-u>"; -- resize window with this key - views = { -- window dimensions to rotate through - { width = 0.800; height = 0.800; }; - { width = 0.600; height = 0.600; }; - { width = 0.950; height = 0.950; }; - { width = 0.500; height = 0.500; col = 0; row = 0; }; - { width = 0.500; height = 0.500; col = 0; row = 0.5; }; - { width = 0.500; height = 0.500; col = 0.5; row = 0; }; - { width = 0.500; height = 0.500; col = 0.5; row = 0.5; }; - }; + layout_mapping = "<M-u>", -- resize window with this key + views = { -- window dimensions to rotate through + { width = 0.800, height = 0.800 }, + { width = 0.600, height = 0.600 }, + { width = 0.950, height = 0.950 }, + { width = 0.500, height = 0.500, col = 0, row = 0 }, + { width = 0.500, height = 0.500, col = 0, row = 0.5 }, + { width = 0.500, height = 0.500, col = 0.5, row = 0 }, + { width = 0.500, height = 0.500, col = 0.5, row = 0.5 }, + }, }) diff --git a/hm/soispha/conf/nvim/plgs/lsp-progress-nvim/lua/lsp-progress-nvim.lua b/hm/soispha/conf/nvim/plgs/lsp-progress-nvim/lua/lsp-progress-nvim.lua index 4273085c..efb15720 100644 --- a/hm/soispha/conf/nvim/plgs/lsp-progress-nvim/lua/lsp-progress-nvim.lua +++ b/hm/soispha/conf/nvim/plgs/lsp-progress-nvim/lua/lsp-progress-nvim.lua @@ -3,12 +3,12 @@ require("lsp-progress").setup({ -- Spinning icons. -- --- @type string[] - spinner = { "⣾"; "⣽"; "⣻"; "⢿"; "⡿"; "⣟"; "⣯"; "⣷"; }; + spinner = { "⣾", "⣽", "⣻", "⢿", "⡿", "⣟", "⣯", "⣷" }, -- Spinning update time in milliseconds. -- --- @type integer - spin_update_time = 200; + spin_update_time = 200, -- Last message cached decay time in milliseconds. -- @@ -17,12 +17,12 @@ require("lsp-progress").setup({ -- for a while for user view. -- --- @type integer - decay = 700; + decay = 700, -- User event name. -- --- @type string - event = "LspProgressStatusUpdated"; + event = "LspProgressStatusUpdated", -- Event update time limit in milliseconds. -- @@ -31,12 +31,12 @@ require("lsp-progress").setup({ -- event rate to reduce this cost. -- --- @type integer - event_update_time_limit = 100; + event_update_time_limit = 100, -- Max progress string length, by default -1 is unlimited. -- --- @type integer - max_size = -1; + max_size = -1, -- Regular internal update time. -- @@ -44,7 +44,7 @@ require("lsp-progress").setup({ -- message. -- --- @type integer - regular_internal_update_time = 500; + regular_internal_update_time = 500, -- Disable emitting events on specific mode/filetype. -- User events would interrupt insert mode, thus break which-key like plugins behaviour. @@ -53,7 +53,7 @@ require("lsp-progress").setup({ -- * https://neovim.io/doc/user/builtin.html#mode() -- --- @type table[] - disable_events_opts = { { mode = "i"; filetype = "TelescopePrompt"; }; }; + disable_events_opts = { { mode = "i", filetype = "TelescopePrompt" } }, -- Format series message. -- @@ -89,7 +89,7 @@ require("lsp-progress").setup({ table.insert(builder, "- done") end return table.concat(builder, " ") - end; + end, -- Format client message. -- @@ -107,9 +107,9 @@ require("lsp-progress").setup({ --- `client_messages` array, or ignored if return nil. client_format = function(client_name, spinner, series_messages) return #series_messages > 0 - and ("[" .. client_name .. "] " .. spinner .. " " .. table.concat(series_messages, ", ")) + and ("[" .. client_name .. "] " .. spinner .. " " .. table.concat(series_messages, ", ")) or nil - end; + end, -- Format (final) message. -- @@ -123,22 +123,22 @@ require("lsp-progress").setup({ format = function(client_messages) local sign = " LSP" -- nf-fa-gear \uf013 return #client_messages > 0 and (sign .. " " .. table.concat(client_messages, " ")) or sign - end; + end, -- Enable debug. -- --- @type boolean - debug = false; + debug = false, -- Print log to console(command line). -- --- @type boolean - console_log = false; + console_log = false, -- Print log to file. -- --- @type boolean - file_log = true; + file_log = true, -- Log file to write, work with `file_log=true`. -- @@ -146,5 +146,5 @@ require("lsp-progress").setup({ -- For *NIX: `~/.local/share/nvim/lsp-progress.log`. -- --- @type string - file_log_name = "lsp-progress.log"; + file_log_name = "lsp-progress.log", }) diff --git a/hm/soispha/conf/nvim/plgs/ltex_extra/lua/ltex_extra.lua b/hm/soispha/conf/nvim/plgs/ltex_extra/lua/ltex_extra.lua index 9bcfd33c..f55a9ba7 100644 --- a/hm/soispha/conf/nvim/plgs/ltex_extra/lua/ltex_extra.lua +++ b/hm/soispha/conf/nvim/plgs/ltex_extra/lua/ltex_extra.lua @@ -1,16 +1,16 @@ require("ltex_extra").setup({ -- table <string> : languages for witch dictionaries will be loaded, e.g. { "es-AR", "en-US" } -- https://valentjn.github.io/ltex/supported-languages.html#natural-languages - load_langs = {"en-CA", "de-DE"}; -- en-US as default + load_langs = { "en-CA", "de-DE" }, -- en-US as default -- boolean : whether to load dictionaries on startup - init_check = true; + init_check = true, -- string : relative or absolute path to store dictionaries -- e.g. subfolder in the project root or the current working directory: ".ltex" -- e.g. shared files for all projects: vim.fn.expand("~") .. "/.local/share/ltex" - path = vim.fn.expand("~") .. "/.local/state/nvim/ltex"; -- project root or current working directory + path = vim.fn.expand("~") .. "/.local/state/nvim/ltex", -- project root or current working directory -- string : "none", "trace", "debug", "info", "warn", "error", "fatal" - log_level = "warn"; + log_level = "warn", -- table : configurations of the ltex language server. -- Only if you are calling the server from ltex_extra - server_opts = nil; + server_opts = nil, }) diff --git a/hm/soispha/conf/nvim/plgs/luasnip/lua/luasnip.lua b/hm/soispha/conf/nvim/plgs/luasnip/lua/luasnip.lua index 0a603692..a05fa57f 100644 --- a/hm/soispha/conf/nvim/plgs/luasnip/lua/luasnip.lua +++ b/hm/soispha/conf/nvim/plgs/luasnip/lua/luasnip.lua @@ -1,7 +1,7 @@ require("luasnip").config.set_config({ -- Enable auto triggered snippets - enable_autosnippets = true; + enable_autosnippets = true, -- Use Tab (or some other key if you prefer) to trigger visual selection - store_selection_keys = "<Tab>"; + store_selection_keys = "<Tab>", }) diff --git a/hm/soispha/conf/nvim/plgs/luasnip/lua/snippets/all.lua b/hm/soispha/conf/nvim/plgs/luasnip/lua/snippets/all.lua index c98ee7d2..c3f75058 100644 --- a/hm/soispha/conf/nvim/plgs/luasnip/lua/snippets/all.lua +++ b/hm/soispha/conf/nvim/plgs/luasnip/lua/snippets/all.lua @@ -1,4 +1,4 @@ -local ls = require("luasnip"); +local ls = require("luasnip") -- auto_pairs {{{ local get_visual = function(args, parent) if #parent.snippet.env.SELECT_RAW > 0 then @@ -29,31 +29,31 @@ local function pair(pair_begin, pair_end, file_types, condition_function) -- file_types = file_types or {}; return s( - { trig = pair_begin; wordTrig = false; snippetType = "autosnippet"; }, - { t({ pair_begin; }); d(1, get_visual); t({ pair_end; }); }, + { trig = pair_begin, wordTrig = false, snippetType = "autosnippet" }, + { t({ pair_begin }), d(1, get_visual), t({ pair_end }) }, { condition = function() - local filetype_check = true; + local filetype_check = true if file_types ~= nil then - filetype_check = file_types[vim.bo.filetype] or false; - end; + filetype_check = file_types[vim.bo.filetype] or false + end return (not condition_function(pair_begin, pair_end)) and filetype_check - end; + end, } ) end local auto_pairs = { - pair("(", ")", nil, char_count_same); - pair("{", "}", nil, char_count_same); - pair("[", "]", nil, char_count_same); - pair("<", ">", { ["rust"] = true; ["tex"] = true; }, char_count_same); - pair("'", "'", nil, even_count); - pair('"', '"', nil, even_count); - pair("`", "`", nil, even_count); + pair("(", ")", nil, char_count_same), + pair("{", "}", nil, char_count_same), + pair("[", "]", nil, char_count_same), + pair("<", ">", { ["rust"] = true, ["tex"] = true }, char_count_same), + pair("'", "'", nil, even_count), + pair('"', '"', nil, even_count), + pair("`", "`", nil, even_count), } -ls.add_snippets("all", auto_pairs, { type = "snippets"; key = "auto_pairs"; }) +ls.add_snippets("all", auto_pairs, { type = "snippets", key = "auto_pairs" }) -- }}} -- todo_comments {{{ @@ -65,34 +65,33 @@ local utils = require("Comment.utils") ---@return table comment_strings {begcstring, endcstring} local get_cstring = function(ctype) -- use the `Comments.nvim` API to fetch the comment string for the region (eq. '--%s' or '--[[%s]]' for `lua`) - local cstring = calculate_comment_string{ ctype = ctype; range = utils.get_region(); } or vim.bo.commentstring + local cstring = calculate_comment_string({ ctype = ctype, range = utils.get_region() }) or vim.bo.commentstring -- as we want only the strings themselves and not strings ready for using `format` we want to split the left and right side local left, right = utils.unwrap_cstr(cstring) -- create a `{left, right}` table for it - return { left; right; } + return { left, right } end _G.luasnip = {} _G.luasnip.vars = { - username = "@soispha"; - email = "soispha@vhack.eu"; + username = "@soispha", + email = "soispha@vhack.eu", } - --- Options for marks to be used in a TODO comment ---@return table,table: The first table contains a node for the date, the second for the signature local marks = { signature = function() return t("(" .. _G.luasnip.vars.username .. ")"), t("") - end; + end, date_signature = function() - return t("<" .. os.date"%Y-%m-%d" .. ">"), t("(" .. _G.luasnip.vars.username .. ")") - end; + return t("<" .. os.date("%Y-%m-%d") .. ">"), t("(" .. _G.luasnip.vars.username .. ")") + end, date = function() - return t("<" .. os.date"%Y-%m-%d" .. ">"), t("") - end; + return t("<" .. os.date("%Y-%m-%d") .. ">"), t("") + end, empty = function() return t(""), t("") - end; + end, } ---@param alias string @@ -100,19 +99,19 @@ local marks = { ---@param mark_function function: This function should return two nodes ---@return table: Returns the comment node local todo_snippet_nodes = function(alias, opts, mark_function) - local date_node, signature_node = mark_function(); + local date_node, signature_node = mark_function() -- format them into the actual snippet local comment_node = fmta("<> <><>: <> <> <>", { f(function() return get_cstring(opts.ctype)[1] -- get <comment-string[1]> - end); - t(alias); -- [name-of-comment] - signature_node; - i(0); -- {comment-text} - date_node; + end), + t(alias), -- [name-of-comment] + signature_node, + i(0), -- {comment-text} + date_node, f(function() return get_cstring(opts.ctype)[2] -- get <comment-string[2]> - end); + end), }) return comment_node end @@ -128,17 +127,13 @@ local todo_snippet = function(context, alias, opts, mark_function) if not context.trig then return error("context doesn't include a `trig` key which is mandatory", 2) -- all we need from the context is the trigger end - opts.ctype = opts.ctype or - 1 -- comment type can be passed in the `opts` table, but if it is not, we have to ensure, it is defined - local alias_string = alias -- `choice_node` documentation - context.name = context.name or - (alias_string .. " comment") -- generate the `name` of the snippet if not defined - context.dscr = context.dscr or - (alias_string .. " comment with a signature-mark") -- generate the `dscr` if not defined - context.docstring = context.docstring or - (" {1:" .. alias_string .. "}: {3} <{2:mark}>{0} ") -- generate the `docstring` if not defined + opts.ctype = opts.ctype or 1 -- comment type can be passed in the `opts` table, but if it is not, we have to ensure, it is defined + local alias_string = alias -- `choice_node` documentation + context.name = context.name or (alias_string .. " comment") -- generate the `name` of the snippet if not defined + context.dscr = context.dscr or (alias_string .. " comment with a signature-mark") -- generate the `dscr` if not defined + context.docstring = context.docstring or (" {1:" .. alias_string .. "}: {3} <{2:mark}>{0} ") -- generate the `docstring` if not defined local comment_node = todo_snippet_nodes(alias, opts, mark_function) - return s(context, comment_node, opts) -- the final todo-snippet constructed from our parameters + return s(context, comment_node, opts) -- the final todo-snippet constructed from our parameters end ---@param context table: The luasnip context @@ -147,39 +142,41 @@ end ---@param marks table: Possible marks to account in snipped generation ---@return table: All possible snippets build from the marks local process_marks = function(context, aliases, opts, marks) - local output = {}; + local output = {} for mark_name, mark_function in pairs(marks) do - local contex_trig_local = context.trig; - context.trig = context.trig .. "-" .. mark_name; - output[#output + 1] = todo_snippet(context, aliases, opts, mark_function); - context.trig = contex_trig_local; + local contex_trig_local = context.trig + context.trig = context.trig .. "-" .. mark_name + output[#output + 1] = todo_snippet(context, aliases, opts, mark_function) + context.trig = contex_trig_local end - return output; + return output end local todo_snippet_specs = { - { { trig = "todo"; }; { "TODO"; }; { ctype = 1; }; }; - { { trig = "fix"; }; { "FIXME"; "ISSUE"; }; { ctype = 1; }; }; - { { trig = "hack"; }; { "HACK"; }; { ctype = 1; }; }; - { { trig = "warn"; }; { "WARNING"; }; { ctype = 1; }; }; - { { trig = "perf"; }; { "PERFORMANCE"; "OPTIMIZE"; }; { ctype = 1; }; }; - { { trig = "note"; }; { "NOTE"; "INFO"; }; { ctype = 1; }; }; + { { trig = "todo" }, { "TODO" }, { ctype = 1 } }, + { { trig = "fix" }, { "FIXME", "ISSUE" }, { ctype = 1 } }, + { { trig = "hack" }, { "HACK" }, { ctype = 1 } }, + { { trig = "warn" }, { "WARNING" }, { ctype = 1 } }, + { { trig = "perf" }, { "PERFORMANCE", "OPTIMIZE" }, { ctype = 1 } }, + { { trig = "note" }, { "NOTE", "INFO" }, { ctype = 1 } }, -- NOTE: Block commented todo-comments - { { trig = "todob"; }; { "TODO"; }; { ctype = 2; }; }; - { { trig = "fixb"; }; { "FIXME"; "ISSUE"; }; { ctype = 2; }; }; - { { trig = "hackb"; }; { "HACK"; }; { ctype = 2; }; }; - { { trig = "warnb"; }; { "WARNING"; }; { ctype = 2; }; }; - { { trig = "perfb"; }; { "PERF"; "PERFORMANCE"; "OPTIM"; "OPTIMIZE"; }; { ctype = 2; }; }; - { { trig = "noteb"; }; { "NOTE"; "INFO"; }; { ctype = 2; }; }; + { { trig = "todob" }, { "TODO" }, { ctype = 2 } }, + { { trig = "fixb" }, { "FIXME", "ISSUE" }, { ctype = 2 } }, + { { trig = "hackb" }, { "HACK" }, { ctype = 2 } }, + { { trig = "warnb" }, { "WARNING" }, { ctype = 2 } }, + { { trig = "perfb" }, { "PERF", "PERFORMANCE", "OPTIM", "OPTIMIZE" }, { ctype = 2 } }, + { { trig = "noteb" }, { "NOTE", "INFO" }, { ctype = 2 } }, } local todo_comment_snippets = {} for _, v in ipairs(todo_snippet_specs) do local snippets = process_marks(v[1], v[2][1], v[3], marks) - for _, value in pairs(snippets) do table.insert(todo_comment_snippets, value) end + for _, value in pairs(snippets) do + table.insert(todo_comment_snippets, value) + end end -ls.add_snippets("all", todo_comment_snippets, { type = "snippets"; key = "todo_comments"; }) +ls.add_snippets("all", todo_comment_snippets, { type = "snippets", key = "todo_comments" }) -- }}} diff --git a/hm/soispha/conf/nvim/plgs/luasnip/lua/snippets/html/html.lua b/hm/soispha/conf/nvim/plgs/luasnip/lua/snippets/html/html.lua index c467dd68..17e1e7fb 100644 --- a/hm/soispha/conf/nvim/plgs/luasnip/lua/snippets/html/html.lua +++ b/hm/soispha/conf/nvim/plgs/luasnip/lua/snippets/html/html.lua @@ -12,10 +12,10 @@ return { -- HEADER s( { - trig = "h([123456])"; - regTrig = true; - wordTrig = false; - snippetType = "autosnippet"; + trig = "h([123456])", + regTrig = true, + wordTrig = false, + snippetType = "autosnippet", }, fmt( [[ @@ -24,50 +24,50 @@ return { { f(function(_, snip) return snip.captures[1] - end); - d(1, get_visual); + end), + d(1, get_visual), f(function(_, snip) return snip.captures[1] - end); + end), } ), - { condition = line_begin; } - ); -- PARAGRAPH + { condition = line_begin } + ), -- PARAGRAPH s( - { trig = "pp"; snippetType = "autosnippet"; }, + { trig = "pp", snippetType = "autosnippet" }, fmt( [[ <p>{}</p> ]], - { d(1, get_visual); } + { d(1, get_visual) } ), - { condition = line_begin; } - ); -- UNORDERED LIST + { condition = line_begin } + ), -- UNORDERED LIST s( - { trig = "itt"; snippetType = "autosnippet"; }, + { trig = "itt", snippetType = "autosnippet" }, fmt( [[ <ul> <li>{}</li>{} </ul> ]], - { i(1); i(0); } + { i(1), i(0) } ), - { condition = line_begin; } - ); -- LIST ITEM + { condition = line_begin } + ), -- LIST ITEM s( - { trig = "ii"; snippetType = "autosnippet"; }, + { trig = "ii", snippetType = "autosnippet" }, fmt( [[ <li>{}</li> ]], - { d(1, get_visual); } + { d(1, get_visual) } ), - { condition = line_begin; } - ); + { condition = line_begin } + ), -- DOCUMENT TEMPLATE s( - { trig = "base"; }, + { trig = "base" }, fmt( [[ <!doctype HTML> @@ -81,16 +81,16 @@ return { </body> </html> ]], - { i(1, "FooBar"); i(0); } + { i(1, "FooBar"), i(0) } ), - { condition = line_begin; } - ); -- ANCHOR TAG + { condition = line_begin } + ), -- ANCHOR TAG s( { - trig = "([^%l])aa"; - regTrig = true; - wordTrig = false; - snippetType = "autosnippet"; + trig = "([^%l])aa", + regTrig = true, + wordTrig = false, + snippetType = "autosnippet", }, fmt( [[ @@ -99,10 +99,10 @@ return { { f(function(_, snip) return snip.captures[1] - end); - i(1); - d(2, get_visual); + end), + i(1), + d(2, get_visual), } ) - ); + ), } diff --git a/hm/soispha/conf/nvim/plgs/luasnip/lua/snippets/tex/delimiter.lua b/hm/soispha/conf/nvim/plgs/luasnip/lua/snippets/tex/delimiter.lua index e50898fc..22434aa3 100644 --- a/hm/soispha/conf/nvim/plgs/luasnip/lua/snippets/tex/delimiter.lua +++ b/hm/soispha/conf/nvim/plgs/luasnip/lua/snippets/tex/delimiter.lua @@ -6,29 +6,29 @@ local get_visual = function(args, parent) end end -local translation_table = { ["("] = ")"; ["{"] = "}"; ["["] = "]"; } +local translation_table = { ["("] = ")", ["{"] = "}", ["["] = "]" } -- Return snippet tables return { -- LEFT/RIGHT ALL BRACES s( { - trig = "([^%a])l([%(%[%{])"; - regTrig = true; - wordTrig = false; - snippetType = "autosnippet"; + trig = "([^%a])l([%(%[%{])", + regTrig = true, + wordTrig = false, + snippetType = "autosnippet", }, fmta("<>\\left<><>\\right<>", { f(function(_, snip) return snip.captures[1] - end); + end), f(function(_, snip) return snip.captures[2] - end); - d(1, get_visual); + end), + d(1, get_visual), f(function(_, snip) return translation_table[snip.captures[2]] - end); + end), }) - ); + ), } diff --git a/hm/soispha/conf/nvim/plgs/luasnip/lua/snippets/tex/greek.lua b/hm/soispha/conf/nvim/plgs/luasnip/lua/snippets/tex/greek.lua index 19989093..ebf4f9d7 100644 --- a/hm/soispha/conf/nvim/plgs/luasnip/lua/snippets/tex/greek.lua +++ b/hm/soispha/conf/nvim/plgs/luasnip/lua/snippets/tex/greek.lua @@ -1,37 +1,37 @@ -- Return snippet tables return { - s({ trig = ";a"; snippetType = "autosnippet"; }, { t("\\alpha"); }); - s({ trig = ";b"; snippetType = "autosnippet"; }, { t("\\beta"); }); - s({ trig = ";g"; snippetType = "autosnippet"; }, { t("\\gamma"); }); - s({ trig = ";G"; snippetType = "autosnippet"; }, { t("\\Gamma"); }); - s({ trig = ";d"; snippetType = "autosnippet"; }, { t("\\delta"); }); - s({ trig = ";D"; snippetType = "autosnippet"; }, { t("\\Delta"); }); - s({ trig = ";e"; snippetType = "autosnippet"; }, { t("\\epsilon"); }); - s({ trig = ";ve"; snippetType = "autosnippet"; }, { t("\\varepsilon"); }); - s({ trig = ";z"; snippetType = "autosnippet"; }, { t("\\zeta"); }); - s({ trig = ";h"; snippetType = "autosnippet"; }, { t("\\eta"); }); - s({ trig = ";o"; snippetType = "autosnippet"; }, { t("\\theta"); }); - s({ trig = ";vo"; snippetType = "autosnippet"; }, { t("\\vartheta"); }); - s({ trig = ";O"; snippetType = "autosnippet"; }, { t("\\Theta"); }); - s({ trig = ";k"; snippetType = "autosnippet"; }, { t("\\kappa"); }); - s({ trig = ";l"; snippetType = "autosnippet"; }, { t("\\lambda"); }); - s({ trig = ";L"; snippetType = "autosnippet"; }, { t("\\Lambda"); }); - s({ trig = ";m"; snippetType = "autosnippet"; }, { t("\\mu"); }); - s({ trig = ";n"; snippetType = "autosnippet"; }, { t("\\nu"); }); - s({ trig = ";x"; snippetType = "autosnippet"; }, { t("\\xi"); }); - s({ trig = ";X"; snippetType = "autosnippet"; }, { t("\\Xi"); }); - s({ trig = ";i"; snippetType = "autosnippet"; }, { t("\\pi"); }); - s({ trig = ";I"; snippetType = "autosnippet"; }, { t("\\Pi"); }); - s({ trig = ";r"; snippetType = "autosnippet"; }, { t("\\rho"); }); - s({ trig = ";s"; snippetType = "autosnippet"; }, { t("\\sigma"); }); - s({ trig = ";S"; snippetType = "autosnippet"; }, { t("\\Sigma"); }); - s({ trig = ";t"; snippetType = "autosnippet"; }, { t("\\tau"); }); - s({ trig = ";f"; snippetType = "autosnippet"; }, { t("\\phi"); }); - s({ trig = ";vf"; snippetType = "autosnippet"; }, { t("\\varphi"); }); - s({ trig = ";F"; snippetType = "autosnippet"; }, { t("\\Phi"); }); - s({ trig = ";c"; snippetType = "autosnippet"; }, { t("\\chi"); }); - s({ trig = ";p"; snippetType = "autosnippet"; }, { t("\\psi"); }); - s({ trig = ";P"; snippetType = "autosnippet"; }, { t("\\Psi"); }); - s({ trig = ";w"; snippetType = "autosnippet"; }, { t("\\omega"); }); - s({ trig = ";W"; snippetType = "autosnippet"; }, { t("\\Omega"); }); + s({ trig = ";a", snippetType = "autosnippet" }, { t("\\alpha") }), + s({ trig = ";b", snippetType = "autosnippet" }, { t("\\beta") }), + s({ trig = ";g", snippetType = "autosnippet" }, { t("\\gamma") }), + s({ trig = ";G", snippetType = "autosnippet" }, { t("\\Gamma") }), + s({ trig = ";d", snippetType = "autosnippet" }, { t("\\delta") }), + s({ trig = ";D", snippetType = "autosnippet" }, { t("\\Delta") }), + s({ trig = ";e", snippetType = "autosnippet" }, { t("\\epsilon") }), + s({ trig = ";ve", snippetType = "autosnippet" }, { t("\\varepsilon") }), + s({ trig = ";z", snippetType = "autosnippet" }, { t("\\zeta") }), + s({ trig = ";h", snippetType = "autosnippet" }, { t("\\eta") }), + s({ trig = ";o", snippetType = "autosnippet" }, { t("\\theta") }), + s({ trig = ";vo", snippetType = "autosnippet" }, { t("\\vartheta") }), + s({ trig = ";O", snippetType = "autosnippet" }, { t("\\Theta") }), + s({ trig = ";k", snippetType = "autosnippet" }, { t("\\kappa") }), + s({ trig = ";l", snippetType = "autosnippet" }, { t("\\lambda") }), + s({ trig = ";L", snippetType = "autosnippet" }, { t("\\Lambda") }), + s({ trig = ";m", snippetType = "autosnippet" }, { t("\\mu") }), + s({ trig = ";n", snippetType = "autosnippet" }, { t("\\nu") }), + s({ trig = ";x", snippetType = "autosnippet" }, { t("\\xi") }), + s({ trig = ";X", snippetType = "autosnippet" }, { t("\\Xi") }), + s({ trig = ";i", snippetType = "autosnippet" }, { t("\\pi") }), + s({ trig = ";I", snippetType = "autosnippet" }, { t("\\Pi") }), + s({ trig = ";r", snippetType = "autosnippet" }, { t("\\rho") }), + s({ trig = ";s", snippetType = "autosnippet" }, { t("\\sigma") }), + s({ trig = ";S", snippetType = "autosnippet" }, { t("\\Sigma") }), + s({ trig = ";t", snippetType = "autosnippet" }, { t("\\tau") }), + s({ trig = ";f", snippetType = "autosnippet" }, { t("\\phi") }), + s({ trig = ";vf", snippetType = "autosnippet" }, { t("\\varphi") }), + s({ trig = ";F", snippetType = "autosnippet" }, { t("\\Phi") }), + s({ trig = ";c", snippetType = "autosnippet" }, { t("\\chi") }), + s({ trig = ";p", snippetType = "autosnippet" }, { t("\\psi") }), + s({ trig = ";P", snippetType = "autosnippet" }, { t("\\Psi") }), + s({ trig = ";w", snippetType = "autosnippet" }, { t("\\omega") }), + s({ trig = ";W", snippetType = "autosnippet" }, { t("\\Omega") }), } diff --git a/hm/soispha/conf/nvim/plgs/nvim-lint/lua/nvim-lint.lua b/hm/soispha/conf/nvim/plgs/nvim-lint/lua/nvim-lint.lua index c6cd1420..4ed49f7b 100644 --- a/hm/soispha/conf/nvim/plgs/nvim-lint/lua/nvim-lint.lua +++ b/hm/soispha/conf/nvim/plgs/nvim-lint/lua/nvim-lint.lua @@ -1,6 +1,6 @@ require("lint").linters_by_ft = { -- text - markdown = {}; + markdown = {}, -- tex = {'chktex'}, -- maybe add some text linters ? -- shell (already covered by the bash language sever) @@ -9,12 +9,12 @@ require("lint").linters_by_ft = { -- zsh = { "shellcheck"; }; -- dash = { "shellcheck"; }; - yaml = { "yamllint"; }; - nix = { "nix"; "statix"; }; + yaml = { "yamllint" }, + nix = { "nix", "statix" }, } -vim.api.nvim_create_autocmd({ "BufEnter"; "BufWritePost"; }, { +vim.api.nvim_create_autocmd({ "BufEnter", "BufWritePost" }, { callback = function() require("lint").try_lint() - end; + end, }) diff --git a/hm/soispha/conf/nvim/plgs/telescope/extensions/rooter/lua/rooter.lua b/hm/soispha/conf/nvim/plgs/telescope/extensions/rooter/lua/rooter.lua index eaf68ecf..7235c5a3 100644 --- a/hm/soispha/conf/nvim/plgs/telescope/extensions/rooter/lua/rooter.lua +++ b/hm/soispha/conf/nvim/plgs/telescope/extensions/rooter/lua/rooter.lua @@ -11,7 +11,7 @@ if not has_plenary then return end -local log = plenary.log.new({ plugin = "telescope_rooter"; level = "info"; }) +local log = plenary.log.new({ plugin = "telescope_rooter", level = "info" }) -- TODO: expose this function local toggle = function(_) @@ -19,19 +19,19 @@ local toggle = function(_) print("Telescope#rooter#enabled=" .. vim.inspect(vim.g["Telescope#rooter#enabled"])) end -local config = { patterns = { ".git"; }; enable = true; debug = false; } +local config = { patterns = { ".git" }, enable = true, debug = false } -- default enabled vim.g["Telescope#rooter#enabled"] = vim.F.if_nil(config.enable, true) -- redefine log if debug enabled if vim.F.if_nil(config.debug, false) then - log = plenary.log.new({ plugin = "telescope_rooter"; level = "debug"; }) + log = plenary.log.new({ plugin = "telescope_rooter", level = "debug" }) end -local group = vim.api.nvim_create_augroup("TelescopeRooter", { clear = true; }) +local group = vim.api.nvim_create_augroup("TelescopeRooter", { clear = true }) -vim.api.nvim_create_autocmd({ "DirChangedPre"; }, { +vim.api.nvim_create_autocmd({ "DirChangedPre" }, { callback = function() if vim.g["Telescope#rooter#enabled"] ~= true then return @@ -41,11 +41,11 @@ vim.api.nvim_create_autocmd({ "DirChangedPre"; }, { vim.g["Telescope#rooter#oldpwd"] = vim.loop.cwd() log.debug("before " .. vim.inspect(vim.loop.cwd())) end - end; - group = group; + end, + group = group, }) -vim.api.nvim_create_autocmd({ "BufEnter"; "BufWinEnter"; }, { +vim.api.nvim_create_autocmd({ "BufEnter", "BufWinEnter" }, { callback = function() if vim.g["Telescope#rooter#enabled"] ~= true then return @@ -53,18 +53,18 @@ vim.api.nvim_create_autocmd({ "BufEnter"; "BufWinEnter"; }, { vim.schedule(function() if vim.bo.filetype == "TelescopePrompt" then - local rootdir = vim.fs.dirname(vim.fs.find(config.patterns, { upward = true; })[1]) + local rootdir = vim.fs.dirname(vim.fs.find(config.patterns, { upward = true })[1]) if rootdir ~= nil then vim.api.nvim_set_current_dir(rootdir) log.debug("changing dir to " .. rootdir) end end end) - end; - group = group; + end, + group = group, }) -vim.api.nvim_create_autocmd({ "BufWinLeave"; }, { +vim.api.nvim_create_autocmd({ "BufWinLeave" }, { callback = function() if vim.g["Telescope#rooter#enabled"] ~= true then return @@ -79,6 +79,6 @@ vim.api.nvim_create_autocmd({ "BufWinLeave"; }, { end end end) - end; - group = group; + end, + group = group, }) diff --git a/hm/soispha/conf/taskwarrior/hooks/scripts/on-add_enforce-policies.sh b/hm/soispha/conf/taskwarrior/hooks/scripts/on-add_enforce-policies.sh index 9ac1ab91..6f09a7e6 100755 --- a/hm/soispha/conf/taskwarrior/hooks/scripts/on-add_enforce-policies.sh +++ b/hm/soispha/conf/taskwarrior/hooks/scripts/on-add_enforce-policies.sh @@ -6,37 +6,36 @@ SHELL_LIBRARY_VERSION="2.0.13" . %SHELL_LIBRARY_PATH # override shell lib output to stdout eprint() { # shellcheck disable=SC2317 - print "$@"; -}; + print "$@" +} eprintln() { # shellcheck disable=SC2317 - println "$@"; -}; + println "$@" +} enable_hook_dbg() { - debug_hooks="$(task _get rc.debug.hooks)"; + debug_hooks="$(task _get rc.debug.hooks)" [ "$debug_hooks" ] && [ "$debug_hooks" -ge 1 ] && dbg_enable } enforce_project() { - project="$(jq '.project' "$(ptmp "$1")")"; + project="$(jq '.project' "$(ptmp "$1")")" [ "$project" = "null" ] && die "No project supplied!" if grep -q "^$(echo "$project" | sed 's|"\(.*\)"|\1|')\$" "$(ptmp "%PROJECTS_NEWLINE")"; then - dbg "project('$project') is a valid part of %PROJECTS_COMMA"; + dbg "project('$project') is a valid part of %PROJECTS_COMMA" else - die "The project '$(echo "$project" | sed 's|"||g')' is not registered with the nix config, registered projects: %PROJECTS_COMMA"; + die "The project '$(echo "$project" | sed 's|"||g')' is not registered with the nix config, registered projects: %PROJECTS_COMMA" fi } - -read -r new_task; +read -r new_task # We don't change the task, thus immediately return the json -echo "$new_task"; +echo "$new_task" -enable_hook_dbg; -enforce_project "$new_task"; +enable_hook_dbg +enforce_project "$new_task" -exit 0; +exit 0 # vim: ft=sh diff --git a/hm/soispha/conf/taskwarrior/hooks/scripts/on-add_sync-git-repo.sh b/hm/soispha/conf/taskwarrior/hooks/scripts/on-add_sync-git-repo.sh index 8a776d3a..085115e7 100755 --- a/hm/soispha/conf/taskwarrior/hooks/scripts/on-add_sync-git-repo.sh +++ b/hm/soispha/conf/taskwarrior/hooks/scripts/on-add_sync-git-repo.sh @@ -6,38 +6,37 @@ SHELL_LIBRARY_VERSION="2.0.13" . %SHELL_LIBRARY_PATH # override shell lib output to stdout eprint() { # shellcheck disable=SC2317 - print "$@"; -}; + print "$@" +} eprintln() { # shellcheck disable=SC2317 - println "$@"; -}; + println "$@" +} enable_hook_dbg() { - debug_hooks="$(task _get rc.debug.hooks)"; + debug_hooks="$(task _get rc.debug.hooks)" [ "$debug_hooks" ] && [ "$debug_hooks" -ge 1 ] && dbg_enable } update_git_repo() { - task_data="$(task _get rc.data.location)"; + task_data="$(task _get rc.data.location)" [ "$task_data" ] || die "Taskwarrior should have a location set" cd "$task_data" || die "(BUG?): Your data.location path is not accessable" [ -d ./.git/ ] || git init - git add .; - git commit --message="chore: Update" --no-gpg-sign; + git add . + git commit --message="chore: Update" --no-gpg-sign } - -read -r new_task; +read -r new_task # We don't change the task, thus immediately return the json -echo "$new_task"; +echo "$new_task" -enable_hook_dbg; -update_git_repo; +enable_hook_dbg +update_git_repo -exit 0; +exit 0 # vim: ft=sh diff --git a/hm/soispha/conf/taskwarrior/hooks/scripts/on-modify_sync-git-repo.sh b/hm/soispha/conf/taskwarrior/hooks/scripts/on-modify_sync-git-repo.sh index b043f141..996e105a 100755 --- a/hm/soispha/conf/taskwarrior/hooks/scripts/on-modify_sync-git-repo.sh +++ b/hm/soispha/conf/taskwarrior/hooks/scripts/on-modify_sync-git-repo.sh @@ -6,39 +6,38 @@ SHELL_LIBRARY_VERSION="2.0.13" . %SHELL_LIBRARY_PATH # override shell lib output to stdout eprint() { # shellcheck disable=SC2317 - print "$@"; -}; + print "$@" +} eprintln() { # shellcheck disable=SC2317 - println "$@"; -}; + println "$@" +} enable_hook_dbg() { - debug_hooks="$(task _get rc.debug.hooks)"; + debug_hooks="$(task _get rc.debug.hooks)" [ "$debug_hooks" ] && [ "$debug_hooks" -ge 1 ] && dbg_enable } update_git_repo() { - task_data="$(task _get rc.data.location)"; + task_data="$(task _get rc.data.location)" [ "$task_data" ] || die "Taskwarrior should have a location set" cd "$task_data" || die "(BUG?): Your data.location path is not accessable" [ -d ./.git/ ] || git init - git add .; - git commit --message="chore: Update" --no-gpg-sign; + git add . + git commit --message="chore: Update" --no-gpg-sign } - -read -r _old_task; -read -r new_task; +read -r _old_task +read -r new_task # We don't change the task, thus immediately return the json -echo "$new_task"; +echo "$new_task" -enable_hook_dbg; -update_git_repo; +enable_hook_dbg +update_git_repo -exit 0; +exit 0 # vim: ft=sh diff --git a/hm/soispha/conf/taskwarrior/hooks/scripts/on-modify_track-timewarrior.py b/hm/soispha/conf/taskwarrior/hooks/scripts/on-modify_track-timewarrior.py index 03b4ce42..c8efb596 100755 --- a/hm/soispha/conf/taskwarrior/hooks/scripts/on-modify_track-timewarrior.py +++ b/hm/soispha/conf/taskwarrior/hooks/scripts/on-modify_track-timewarrior.py @@ -70,12 +70,17 @@ combined = " ".join(["'%s'" % tag for tag in tags]).encode("utf-8").strip() # Task has been started. if "start" in new and not "start" in old: # Prevent this task from starting if "task +ACTIVE count" is greater than "MAX_ACTIVE". - p = subprocess.Popen(["task", "+ACTIVE", "status:pending", "count", "rc.verbose:off"], stdout=subprocess.PIPE) + p = subprocess.Popen( + ["task", "+ACTIVE", "status:pending", "count", "rc.verbose:off"], + stdout=subprocess.PIPE, + ) out, err = p.communicate() count = int(out.rstrip()) if count >= MAX_ACTIVE: - print("Only %d task(s) can be active at a time. " - "See 'max_active_tasks' in .taskrc." % MAX_ACTIVE) + print( + "Only %d task(s) can be active at a time. " + "See 'max_active_tasks' in .taskrc." % MAX_ACTIVE + ) sys.exit(1) system("timew start " + combined.decode() + " :yes") diff --git a/hm/soispha/conf/taskwarrior/hooks/scripts/on-modify_track-total-active-time.py b/hm/soispha/conf/taskwarrior/hooks/scripts/on-modify_track-total-active-time.py index 88234cbf..d5b380d0 100755 --- a/hm/soispha/conf/taskwarrior/hooks/scripts/on-modify_track-total-active-time.py +++ b/hm/soispha/conf/taskwarrior/hooks/scripts/on-modify_track-total-active-time.py @@ -102,12 +102,17 @@ def main(): # An active task has just been started. if "start" in modified and "start" not in original: # Prevent this task from starting if "task +ACTIVE count" is greater than "MAX_ACTIVE". - p = subprocess.Popen(["task", "+ACTIVE", "status:pending", "count", "rc.verbose:off"], stdout=subprocess.PIPE) + p = subprocess.Popen( + ["task", "+ACTIVE", "status:pending", "count", "rc.verbose:off"], + stdout=subprocess.PIPE, + ) out, err = p.communicate() count = int(out.rstrip()) if count >= MAX_ACTIVE: - print("Only %d task(s) can be active at a time. " - "See 'max_active_tasks' in .taskrc." % MAX_ACTIVE) + print( + "Only %d task(s) can be active at a time. " + "See 'max_active_tasks' in .taskrc." % MAX_ACTIVE + ) sys.exit(1) # An active task has just been stopped. @@ -119,10 +124,18 @@ def main(): if UDA_KEY not in modified: modified[UDA_KEY] = 0 - this_duration = (end - start) - total_duration = (this_duration + duration_str_to_time_delta(str(modified[UDA_KEY]))) - print("Total Time Tracked: %s (%s in this instance)" % (total_duration, this_duration)) - modified[UDA_KEY] = str(int(total_duration.days * (60 * 60 * 24) + total_duration.seconds)) + "seconds" + this_duration = end - start + total_duration = this_duration + duration_str_to_time_delta( + str(modified[UDA_KEY]) + ) + print( + "Total Time Tracked: %s (%s in this instance)" + % (total_duration, this_duration) + ) + modified[UDA_KEY] = ( + str(int(total_duration.days * (60 * 60 * 24) + total_duration.seconds)) + + "seconds" + ) return json.dumps(modified, separators=(",", ":")) diff --git a/hm/soispha/conf/xdg/url_handler.sh b/hm/soispha/conf/xdg/url_handler.sh index 9cca2fc0..53ae4986 100755 --- a/hm/soispha/conf/xdg/url_handler.sh +++ b/hm/soispha/conf/xdg/url_handler.sh @@ -3,18 +3,16 @@ # shellcheck source=/dev/null SHELL_LIBRARY_VERSION="2.0.13" . %SHELL_LIBRARY_PATH - -project="$(echo "%ALL_PROJECTS_PIPE|nvim|zathura|" | rofi -sep "|" -dmenu)"; +project="$(echo "%ALL_PROJECTS_PIPE|nvim|zathura|" | rofi -sep "|" -dmenu)" if [ "$project" = "nvim" ]; then "$TERMINAL" -e nvim "$1" elif [ "$project" = "zathura" ]; then zathura "$1" elif [ "$project" ]; then - firefox -P "$project" "$1"; + firefox -P "$project" "$1" else notify-send "(URL HANDLER) No project selected" && exit 1 fi - # vim: ft=sh diff --git a/hm/soispha/conf/yambar/scripts/disk.sh b/hm/soispha/conf/yambar/scripts/disk.sh index 003455ab..284661b9 100755 --- a/hm/soispha/conf/yambar/scripts/disk.sh +++ b/hm/soispha/conf/yambar/scripts/disk.sh @@ -5,18 +5,17 @@ SHELL_LIBRARY_VERSION="2.0.13" . %SHELL_LIBRARY_PATH # Main loop while true; do - # vars - used_space=$(btrfs filesystem usage /srv 2> /dev/null | awk '{if ( /Used:/ ) { print $2 } } ' | head -n1) - all_space=$(btrfs filesystem usage /srv 2> /dev/null | awk '{if ( /Device size:/ ) { print $3 } } ' | head -n1 | tr -d "GiB") + # vars + used_space=$(btrfs filesystem usage /srv 2>/dev/null | awk '{if ( /Used:/ ) { print $2 } } ' | head -n1) + all_space=$(btrfs filesystem usage /srv 2>/dev/null | awk '{if ( /Device size:/ ) { print $3 } } ' | head -n1 | tr -d "GiB") + # Check space available (4) and percentage used (5) + spaceperc=$(echo "$(echo "$used_space" | tr -d "GiB")" "$all_space" | awk '{div=$1/$2;div *= 100; printf"%2d%%\n",div }') - # Check space available (4) and percentage used (5) - spaceperc=$(echo "$(echo "$used_space" | tr -d "GiB" )" "$all_space" | awk '{div=$1/$2;div *= 100; printf"%2d%%\n",div }') - - echo "diskspace|string|$used_space" - echo "diskperc|string|$spaceperc" - echo "" - sleep 1 + echo "diskspace|string|$used_space" + echo "diskperc|string|$spaceperc" + echo "" + sleep 1 done # vim: ft=sh diff --git a/hm/soispha/conf/yambar/scripts/grades-average.sh b/hm/soispha/conf/yambar/scripts/grades-average.sh index 8c1900cf..b93869c5 100755 --- a/hm/soispha/conf/yambar/scripts/grades-average.sh +++ b/hm/soispha/conf/yambar/scripts/grades-average.sh @@ -4,12 +4,12 @@ SHELL_LIBRARY_VERSION="2.0.13" . %SHELL_LIBRARY_PATH while true; do - grade="$(grades list average | awk '{print $2}')"; + grade="$(grades list average | awk '{print $2}')" - echo "grade|string|$grade"; - echo ""; + echo "grade|string|$grade" + echo "" - sleep 1; + sleep 1 done # vim: ft=sh diff --git a/hm/soispha/conf/yambar/scripts/mpd_song_name.sh b/hm/soispha/conf/yambar/scripts/mpd_song_name.sh index b778afbc..b251619b 100755 --- a/hm/soispha/conf/yambar/scripts/mpd_song_name.sh +++ b/hm/soispha/conf/yambar/scripts/mpd_song_name.sh @@ -3,12 +3,11 @@ # shellcheck source=/dev/null SHELL_LIBRARY_VERSION="2.0.13" . %SHELL_LIBRARY_PATH - while true; do - state="$(mpc status '%state%')"; + state="$(mpc status '%state%')" if [ "$state" = "playing" ]; then - song="$(mpc --format '[[%artist% - ]%title%]|[%file%]' current)"; + song="$(mpc --format '[[%artist% - ]%title%]|[%file%]' current)" echo "playing|bool|true" echo "song|string|$song" else @@ -16,7 +15,7 @@ while true; do fi echo "" # commit - sleep 2; + sleep 2 done # vim: ft=sh diff --git a/hm/soispha/conf/yambar/scripts/network.sh b/hm/soispha/conf/yambar/scripts/network.sh index 717ea6be..b4396640 100755 --- a/hm/soispha/conf/yambar/scripts/network.sh +++ b/hm/soispha/conf/yambar/scripts/network.sh @@ -8,40 +8,40 @@ retest_if_con_fails=10 backend=nmcli case "$backend" in - "nmcli") # Test for connectivity with nmcli - while true; do - connection_status=$(nmcli networking connectivity) - if [ "$connection_status" = "full" ]; then - echo "internet|string|Connected" - echo "" - sleep $retest - else - echo "internet|string|Disconnected" - echo "" - sleep $retest_if_con_fails - fi - done - ;; - "ping") # Test for connectivity with ping - ip_address='8.8.8.8' - ping_number=3 +"nmcli") # Test for connectivity with nmcli + while true; do + connection_status=$(nmcli networking connectivity) + if [ "$connection_status" = "full" ]; then + echo "internet|string|Connected" + echo "" + sleep $retest + else + echo "internet|string|Disconnected" + echo "" + sleep $retest_if_con_fails + fi + done + ;; +"ping") # Test for connectivity with ping + ip_address='8.8.8.8' + ping_number=3 - while true; do + while true; do - ping_result=$(mktmp) - ping $ip_address -c $ping_number -q | awk 'BEGIN {FS="/"} END {print $5}' > "$ping_result" + ping_result=$(mktmp) + ping $ip_address -c $ping_number -q | awk 'BEGIN {FS="/"} END {print $5}' >"$ping_result" - if [ "$(cat "$ping_result" | wc -l)" -eq 0 ]; then - echo "med|string|No connection" - echo "" - sleep $retest_if_con_fails - else - echo "med|string|$(cat "$ping_result") ms" - echo "" - sleep $retest - fi - done - ;; + if [ "$(wc -l <"$ping_result")" -eq 0 ]; then + echo "med|string|No connection" + echo "" + sleep $retest_if_con_fails + else + echo "med|string|$(cat "$ping_result") ms" + echo "" + sleep $retest + fi + done + ;; esac # vim: ft=sh diff --git a/hm/soispha/conf/yambar/scripts/old/amixer-monitor.sh b/hm/soispha/conf/yambar/scripts/old/amixer-monitor.sh deleted file mode 100755 index 9e75acfa..00000000 --- a/hm/soispha/conf/yambar/scripts/old/amixer-monitor.sh +++ /dev/null @@ -1,24 +0,0 @@ -#!/bin/sh -# An improved amixer script that actually detects volume beyond 100% - - -SLEEPTIME=1 - - -while true; do - - volume=$(pactl get-sink-volume 0 | awk 'BEGIN { FS="/"} {print $2 }' | tr -d "%" | tr -d ' ') - - if [ "$volume" -eq 0 ]; then - echo "muted|bool|true" - - else - # Read sink volume in percentages - echo "volume|string|$volume" - echo "muted|bool|false" - fi - - echo "" - sleep "$SLEEPTIME" - -done diff --git a/hm/soispha/conf/yambar/scripts/old/cpu.sh b/hm/soispha/conf/yambar/scripts/old/cpu.sh deleted file mode 100755 index bae820d0..00000000 --- a/hm/soispha/conf/yambar/scripts/old/cpu.sh +++ /dev/null @@ -1,126 +0,0 @@ -#!/bin/bash -# I didn't write this script; this is almost directly copied from the dnkl/yambar github. - - -# cpu.sh - measures CPU usage at a configurable sample interval -# -# Usage: cpu.sh INTERVAL_IN_SECONDS -# -# This script will emit the following tags on stdout (N is the number -# of logical CPUs): -# -# Name Type -# -------------------- -# cpu range 0-100 -# cpu0 range 0-100 -# cpu1 range 0-100 -# ... -# cpuN-1 range 0-100 -# -# I.e. ‘cpu’ is the average (or aggregated) CPU usage, while cpuX is a -# specific CPU’s usage. -# -# Example configuration (update every second): -# -# - script: -# path: /path/to/cpu.sh -# args: [1] -# content: {string: {text: "{cpu}%"}} -# - -interval=2 - -case ${interval} in - ''|*[!0-9]*) - echo "interval must be an integer" - exit 1 - ;; - *) - ;; -esac - -# Get number of CPUs, by reading /proc/stat -# The output looks like: -# -# cpu A B C D ... -# cpu0 A B C D ... -# cpu1 A B C D ... -# cpuN A B C D ... -# -# The first line is a summary line, accounting *all* CPUs -IFS=$'\n' readarray -t all_cpu_stats < <(grep -e "^cpu" /proc/stat) -cpu_count=$((${#all_cpu_stats[@]} - 1)) - -# Arrays of ‘previous’ idle and total stats, needed to calculate the -# difference between each sample. -prev_idle=() -prev_total=() -for i in $(seq ${cpu_count}); do - prev_idle+=(0) - prev_total+=(0) -done - -prev_average_idle=0 -prev_average_total=0 - -while true; do - IFS=$'\n' readarray -t all_cpu_stats < <(grep -e "^cpu" /proc/stat) - - usage=() # CPU usage in percent, 0 <= x <= 100 - - average_idle=0 # All CPUs idle time since boot - average_total=0 # All CPUs total time since boot - - for i in $(seq 0 $((cpu_count - 1))); do - # Split this CPUs stats into an array - stats=($(echo "${all_cpu_stats[$((i + 1))]}")) - - # man procfs(5) - user=${stats[1]} - nice=${stats[2]} - system=${stats[3]} - idle=${stats[4]} - iowait=${stats[5]} - irq=${stats[6]} - softirq=${stats[7]} - steal=${stats[8]} - guest=${stats[9]} - guestnice=${stats[10]} - - # Guest time already accounted for in user - user=$((user - guest)) - nice=$((nice - guestnice)) - - idle=$((idle + iowait)) - - total=$((user + nice + system + irq + softirq + idle + steal + guest + guestnice)) - - average_idle=$((average_idle + idle)) - average_total=$((average_total + total)) - - # Diff since last sample - diff_idle=$((idle - prev_idle[i])) - diff_total=$((total - prev_total[i])) - - usage[i]=$((100 * (diff_total - diff_idle) / diff_total)) - - prev_idle[i]=${idle} - prev_total[i]=${total} - done - - diff_average_idle=$((average_idle - prev_average_idle)) - diff_average_total=$((average_total - prev_average_total)) - - average_usage=$((100 * (diff_average_total - diff_average_idle) / diff_average_total)) - - prev_average_idle=${average_idle} - prev_average_total=${average_total} - - echo "cpu|range:0-100|${average_usage}" - for i in $(seq 0 $((cpu_count - 1))); do - echo "cpu${i}|range:0-100|${usage[i]}" - done - - echo "" - sleep "${interval}" -done diff --git a/hm/soispha/conf/yambar/scripts/old/dfspace.sh b/hm/soispha/conf/yambar/scripts/old/dfspace.sh deleted file mode 100755 index 0b262481..00000000 --- a/hm/soispha/conf/yambar/scripts/old/dfspace.sh +++ /dev/null @@ -1,23 +0,0 @@ -#!/bin/sh - -# Sleep seconds -timer="60" - -# Main loop -while true; do - - # vars - used_space=$(btrfs filesystem usage / 2> /dev/null | awk '{if ( /Used:/ ) { print $2 } } ' | head -n1) - all_space=$(btrfs filesystem usage / 2> /dev/null | awk '{if ( /Device size:/ ) { print $3 } } ' | head -n1 | tr -d "GiB") - - - # Check space available (4) and percentage used (5) - spaceperc=$(echo "$(echo "$used_space" | tr -d "GiB" )" "$all_space" | awk '{div=$1/$2;div *= 100; printf"%2d%%\n",div }') - - echo "diskspace|string|$used_space" - echo "diskperc|string|$spaceperc" - echo "" - sleep $timer - -done - diff --git a/hm/soispha/conf/yambar/scripts/old/grades-average.sh b/hm/soispha/conf/yambar/scripts/old/grades-average.sh deleted file mode 100755 index a04b958c..00000000 --- a/hm/soispha/conf/yambar/scripts/old/grades-average.sh +++ /dev/null @@ -1,12 +0,0 @@ -#!/bin/sh -# shellcheck disable=SC2086 -# shellcheck source=/dev/null -. ~/.local/lib/shell/lib - -grade=$(grades list average | awk '{print $2}'); - -echo "grade|string|$grade"; -echo ""; - - -if [ -d /tmp/LIB_FILE_TEMP_DIR/ ];then rm -r /tmp/LIB_FILE_TEMP_DIR/; fi diff --git a/hm/soispha/conf/yambar/scripts/old/meminfo.sh b/hm/soispha/conf/yambar/scripts/old/meminfo.sh deleted file mode 100755 index 0156e94c..00000000 --- a/hm/soispha/conf/yambar/scripts/old/meminfo.sh +++ /dev/null @@ -1,37 +0,0 @@ -#!/bin/sh -# Checks memory usage - -# Number of seconds to retest -timer=5 - -# Main loop -while true; do - - mem_total=$(LANG=C free -b|awk '/^Mem:/{print $2}') - mem_used=$(LANG=C free -b|awk '/^Mem:/{print $3}') - swap_total=$(LANG=C free -b|awk '/^Swap:/{print $2}') - swap_used=$(LANG=C free -b|awk '/^Swap:/{print $3}') - - - memperc=$(echo "$mem_used" "$mem_total" | awk '{ div = 100 * ($1 / $2)} { printf "%.0f ", div }' | tr -d ' ' ) - swapperc=$(echo "$swap_used" "$swap_total" | awk '{ - if ( $1 == 0 || $2 == 0 ) { - print "%" - } else { - div = 100 * ($1 / $2); - printf "%.0f ", div -} -}' | tr -d ' ' ) - - -echo "memperc|string|$memperc" -if [ "$swapperc" = "%" ];then - echo "swapstate|bool|false" -else - echo "swapperc|string|$swapperc" - echo "swapstate|bool|true" -fi -echo "" -sleep "$timer" - -done diff --git a/hm/soispha/conf/yambar/scripts/old/nmclitest.sh b/hm/soispha/conf/yambar/scripts/old/nmclitest.sh deleted file mode 100755 index 3e8bc73a..00000000 --- a/hm/soispha/conf/yambar/scripts/old/nmclitest.sh +++ /dev/null @@ -1,23 +0,0 @@ -#!/bin/sh -# Test for connectivity with nmcli - -Timer=${1:-120} # Number of seconds to retest -Timer2=${2:-10} # Number of seconds to retest if connection fails - -# Main loop -while true; do - - CONN=$(nmcli networking connectivity) - - if [[ "$CONN" == "full" ]]; then - echo "internet|string|Connected" - echo "" - sleep $Timer - else - echo "internet|string|Disconnected" - echo "" - sleep $Timer2 - fi - -done - diff --git a/hm/soispha/conf/yambar/scripts/old/pingtest.sh b/hm/soispha/conf/yambar/scripts/old/pingtest.sh deleted file mode 100755 index 2b5f9998..00000000 --- a/hm/soispha/conf/yambar/scripts/old/pingtest.sh +++ /dev/null @@ -1,28 +0,0 @@ -#!/bin/sh -# Test for connectivity with ping - -Timer=${1:-120} # Number of seconds to retest -Timer2=${2:-10} # Number of seconds to retest if connection fails -IP=${3:-'8.8.8.8'} # IP address to test, defaults to Google -PCount=${4:-3} # Number of pings to send - -# Main loop -while true; do - - # Pings the IP address for five times - PINGSTR=$(ping $IP -c $PCount -q) - # Use text formatting to get min/max ms delays - MED=$(echo $PINGSTR | sed 's/min\/avg\/max\/mdev = /\n/g' | tail -n 1 | sed 's/\//\t/g' | cut -f2) - - if [[ "$MED" == "" ]]; then - echo "med|string|No connection" - echo "" - sleep $Timer2 - else - echo "med|string|$MED ms" - echo "" - sleep $Timer - fi - -done - diff --git a/hm/soispha/conf/yambar/scripts/old/yambar-tray-width.sh b/hm/soispha/conf/yambar/scripts/old/yambar-tray-width.sh deleted file mode 100755 index 00544e70..00000000 --- a/hm/soispha/conf/yambar/scripts/old/yambar-tray-width.sh +++ /dev/null @@ -1,28 +0,0 @@ -#!/bin/sh -# shellcheck disable=SC2086 -# shellcheck source=/dev/null -. ~/.local/lib/shell/lib - - -CHARWIDTH=8 # i guess? - -tray_width_px() { - xwininfo -name panel | # trayer names its window "panel" - grep -i width: | - awk '{print $2}' -} - -px_to_spaces() { - spaces="$((1 + ${1:-0} / $CHARWIDTH))" - printf "% *s\n" $spaces -} - -sleep 0.2 # be sure trayer is already up - -output="$(px_to_spaces `tray_width_px`)" -echo "padding|string|$output" -echo "" - - - -if [ -d /tmp/LIB_FILE_TEMP_DIR/ ];then rm -r /tmp/LIB_FILE_TEMP_DIR/; fi diff --git a/hm/soispha/conf/yambar/scripts/old/yambar-tray.sh b/hm/soispha/conf/yambar/scripts/old/yambar-tray.sh deleted file mode 100755 index 1704c6dd..00000000 --- a/hm/soispha/conf/yambar/scripts/old/yambar-tray.sh +++ /dev/null @@ -1,27 +0,0 @@ -#!/bin/sh - - -pkill stalonetray -pkill trayer - -# launch a tray. -echo - -sleep 0.1 # make sure yambar starts first so we can draw on tpo of it - -# trayer-srg fork! -trayer \ - --edge top \ - --tint 0x24242400 \ - --align right \ - --height 20 \ - --expand false \ - --transparent true \ - --alpha 0 \ - --width 20 \ - --monitor primary \ - --widthtype request - # &>/dev/null - - - diff --git a/hm/soispha/conf/yambar/scripts/sound-volume.sh b/hm/soispha/conf/yambar/scripts/sound-volume.sh index 721d51bf..f887b4de 100755 --- a/hm/soispha/conf/yambar/scripts/sound-volume.sh +++ b/hm/soispha/conf/yambar/scripts/sound-volume.sh @@ -14,7 +14,7 @@ while true; do fi echo "" - sleep 3; + sleep 3 done # vim: ft=sh diff --git a/hm/soispha/pkgs/scripts/apps/aumo.sh b/hm/soispha/pkgs/scripts/apps/aumo.sh index b5840fc3..7426115a 100755 --- a/hm/soispha/pkgs/scripts/apps/aumo.sh +++ b/hm/soispha/pkgs/scripts/apps/aumo.sh @@ -3,52 +3,23 @@ # shellcheck source=/dev/null SHELL_LIBRARY_VERSION="2.0.13" . %SHELL_LIBRARY_PATH -# TODO: rewrite this - -if [ "$1" = "-u" ];then udisksctl unmount -b "$(cat "$HOME/.cache/aumo/mnt_disk")"; exit 0; fi -all_available_disks=$(mktemp) -awk '{print $4}' /proc/partitions | sed '1 s|.*||' > "$all_available_disks" - -mounted_disk=$(mktemp) -awk '{print $1}' /proc/mounts > "$mounted_disk" - -unmounted_disks=$(mktemp) - -for i in $(cat $all_available_disks);do - if ! grep -qw "/dev/$i" $mounted_disk && ! ls /sys/block/$i/*/partition > /dev/null 2> /dev/null;then echo $i >> $unmounted_disks;fi -done - - -u=1 -disk=-1 -while [ $disk -lt 0 ] || [ $disk -gt $(wc -l $unmounted_disks | awk '{print $1}') ];do - - [ "$1" = "-v" ] && for i in $(cat $unmounted_disks);do - sudo fdisk -l "/dev/$i" - done - - for i in $(cat $unmounted_disks);do - printf "%4s) %s\n" "$u" "$i" - u=$(( u + 1 )) - done - - printf "%4s) Exit\n" "0" - printf "Input number: " - read -r disk - - [ $disk -lt 0 ] || [ $disk -gt $(wc -l $unmounted_disks | awk '{print $1}') ] && printf "Wrong number. Please retry\n" - [ $disk -eq 0 ] && exit 0 -done - -mnt_disk="/dev/$(awk -v n=$disk 'NR==n' $unmounted_disks)" - -if ! [ "$1" = "-v" ] && [ -n "$1" ];then sudo mount "$mnt_disk" "$1" && exit 0;fi -[ -n "$2" ] && sudo mount "$mnt_disk" "$1" && exit 0 -if mount | grep -q ~/mnt ;then dien "Something is mounted at ~/mnt";else udisksctl mount -b "$mnt_disk";fi - -[ -e $HOME/.cache/aumo/mnt_disk ] || mkdir -p $HOME/.cache/aumo -echo $mnt_disk >> $HOME/.cache/aumo/mnt_disk -rm $all_available_disks -rm $mounted_disk -rm $unmounted_disks -[ -d /tmp/LIB_FILE_TEMP_DIR/ ] && rm -r /tmp/LIB_FILE_TEMP_DIR/ +unmounting() { + disk_name="$(find /dev/disk/by-label -type l -printf "%P|" | rofi -sep "|" -dmenu -p "Select disk to mount")" + + udisksctl unmount --block-device "/dev/disk/by-label/$disk_name" +} + +mounting() { + disk_name="$(find /dev/disk/by-label -type l -printf "%P|" | rofi -sep "|" -dmenu -p "Select disk to mount")" + + udisksctl mount --block-device "/dev/disk/by-label/$disk_name" +} + +case "$1" in +"mount") + mounting + ;; +"unmount" | "umount") + unmounting + ;; +esac diff --git a/hm/soispha/pkgs/scripts/apps/con2pdf.sh b/hm/soispha/pkgs/scripts/apps/con2pdf.sh index be8810bb..620a299a 100755 --- a/hm/soispha/pkgs/scripts/apps/con2pdf.sh +++ b/hm/soispha/pkgs/scripts/apps/con2pdf.sh @@ -3,17 +3,19 @@ # shellcheck source=/dev/null SHELL_LIBRARY_VERSION="2.0.13" . %SHELL_LIBRARY_PATH - # needed for help() and version # shellcheck disable=2034 -AUTHORS="Soispha"; +AUTHORS="Soispha" # shellcheck disable=2034 -YEARS="2023"; +YEARS="2023" # shellcheck disable=2034 -VERSION="1.0.0"; +VERSION="1.0.0" +# NAME is from the wrapper +# shellcheck disable=SC2269 +NAME="$NAME" help() { -cat << EOF + cat <<EOF Scan images and turn them into a pdf. Usage: @@ -60,98 +62,97 @@ EOF } scan_adf() { - device="$1"; - sides_per_page="$2"; - method="ADF"; - for i in $(seq "$sides_per_page");do + device="$1" + sides_per_page="$2" + method="ADF" + for i in $(seq "$sides_per_page"); do do_until_success \ "scanimage --format=tiff --progress --source='$method' --device='$device' --batch=%d.tif --batch-increment='$sides_per_page' --batch-start='$i'" \ "warn 'Retrying scan, as we assume a network error!'" - - if [ "$sides_per_page" -ne 1 ];then - msg "Finished turn, please change side!"; + if [ "$sides_per_page" -ne 1 ]; then + msg "Finished turn, please change side!" readp "Press enter to continue" noop fi done } process_images_adf() { - tiff_temp_path="$1"; - output_directory="$2"; - name="$3"; + tiff_temp_path="$1" + output_directory="$2" + name="$3" - counter=0; - pdf_counter=0; + counter=0 + pdf_counter=0 image_cache="$(mktmp)" while read -r scanned_image; do - dbg "$scanned_image (scanned_image) at $counter (counter)"; - echo "$scanned_image" >> "$image_cache" + dbg "$scanned_image (scanned_image) at $counter (counter)" + echo "$scanned_image" >>"$image_cache" : $((counter += 1)) if [ "$counter" = "$number_of_pages" ]; then dbg "$counter == $number_of_pages" - counter=0; + counter=0 convert_images "$image_cache" "${name}_$pdf_counter" "$output_directory" : $((pdf_counter += 1)) - printf "" > "$image_cache" + printf "" >"$image_cache" fi - done < "$(tmp_pipe fd . "$tiff_temp_path" "|" sort -V)" + done <"$(tmp_pipe fd . "$tiff_temp_path" "|" sort -V)" } scan_flatbed() { - device="$1"; - number_of_pages"$2"; - method="Flatbed"; + device="$1" + number_of_pages"$2" + method="Flatbed" for i in $(seq "$number_of_pages"); do do_until_success \ "scanimage --format=tiff --progress --source='$method' --device='$device' --output-file=$i.tiff" \ "warn 'Retrying scan, as we assume a network error!'" - if [ "$number_of_pages" -ne 1 ];then - msg "Finished turn, please change side!"; + if [ "$number_of_pages" -ne 1 ]; then + msg "Finished turn, please change side!" readp "Press enter to continue" noop fi done } process_images_flatbed() { - tiff_temp_path="$1"; - output_directory="$2"; - name="$3"; + tiff_temp_path="$1" + output_directory="$2" + name="$3" - counter=0; + counter=0 image_cache="$(mktmp)" while read -r scanned_image; do - echo "$scanned_image" >> "$image_cache" + echo "$scanned_image" >>"$image_cache" : $((counter += 1)) if [ "$counter" = "$number_of_pages" ]; then - counter=0; + counter=0 convert_images "$image_cache" "$name" "$output_directory" - printf "" > "$image_cache" + printf "" >"$image_cache" fi - done < "$(tmp_pipe fd . "$tiff_temp_path" "|" sort -V)" + done <"$(tmp_pipe fd . "$tiff_temp_path" "|" sort -V)" } convert_images() { - image_cache="$1"; - pdf_name="$2"; - output_dir="$3"; + image_cache="$1" + pdf_name="$2" + output_dir="$3" set -- while read -r image; do - dbg "setting image: $image"; + dbg "setting image: $image" set -- "$@" "$image" - done < "$image_cache" + done <"$image_cache" while [ -e "$output_dir/${pdf_name}.pdf" ]; do pdf_name="${pdf_name}_$(tr -dc 'A-Za-z0-9' </dev/urandom | head -c 25)" done - dbg "using pdf_name: $pdf_name"; + dbg "using pdf_name: $pdf_name" convert "$@" -compress jpeg -quality 100 "$output_dir/${pdf_name}.pdf" } scan() { - number_of_pages="$1"; - device="$2"; - output_directory="$(readlink -f "$3")"; - name="$4"; - method="$5"; + number_of_pages="$1" + device="$2" + output_directory="$(readlink -f "$3")" + name="$4" + method="$5" [ -z "$number_of_pages" ] && die "Parameter 'number_of_pages' is not set!" [ -z "$device" ] && die "Parameter 'device' is not set!" @@ -159,21 +160,21 @@ scan() { [ -z "$name" ] && die "Parameter 'name' is not set!" [ -z "$method" ] && die "Parameter 'method' is not set!" - tiff_temp_path="$(mktmp -d)"; + tiff_temp_path="$(mktmp -d)" cd "$tiff_temp_path" || die "Bug" - msg "Started scanning..."; + msg "Started scanning..." if [ "$method" = "Flatbed" ]; then scan_flatbed "$device" "$number_of_pages" else scan_adf "$device" "$number_of_pages" fi - msg "Creating output directory..."; - mkdir "$output_directory"; + msg "Creating output directory..." + mkdir "$output_directory" cd "$output_directory" || die "Bug" - msg "Converting images to pdfs..."; + msg "Converting images to pdfs..." if [ "$method" = "Flatbed" ]; then process_images_flatbed "$tiff_temp_path" "$output_directory" "$name" else @@ -181,57 +182,53 @@ scan() { fi } - for input in "$@"; do case "$input" in - "--help" | "-h") - help; - exit 0; - ;; - "--version" | "-v") - version; - exit 0; - ;; + "--help" | "-h") + help + exit 0 + ;; + "--version" | "-v") + version + exit 0 + ;; esac done -number_of_pages="1"; -unset device; -output_directory="$(pwd)/pdf"; -unset name; -method="ADF"; +number_of_pages="1" +unset device +output_directory="$(pwd)/pdf" +unset name +method="ADF" while [ "$#" -ne 0 ]; do case "$1" in - "--help" | "-h") - ;; - "--version" | "-v") - ;; - "--out-dir" | "-o") - shift 1; - output_directory="$1"; - ;; - "--name" | "-n") - shift 1; - name="$1"; - ;; - "--num-pages" | "-p") - shift 1; - number_of_pages="$1"; - ;; - "--device" | "-d") - shift 1; - device="$1"; - ;; - "--method" | "-m") - shift 1; - method="$1"; - ;; - *) - die "Command line arg $1 does not exist. See --help for a list."; - ;; + "--help" | "-h") ;; + "--version" | "-v") ;; + "--out-dir" | "-o") + shift 1 + output_directory="$1" + ;; + "--name" | "-n") + shift 1 + name="$1" + ;; + "--num-pages" | "-p") + shift 1 + number_of_pages="$1" + ;; + "--device" | "-d") + shift 1 + device="$1" + ;; + "--method" | "-m") + shift 1 + method="$1" + ;; + *) + die "Command line arg $1 does not exist. See --help for a list." + ;; esac - shift 1; + shift 1 done -scan "$number_of_pages" "$device" "$output_directory" "$name" "$method"; - +scan "$number_of_pages" "$device" "$output_directory" "$name" "$method" diff --git a/hm/soispha/pkgs/scripts/apps/fupdate.1.md b/hm/soispha/pkgs/scripts/apps/fupdate.1.md index b2b7bf4f..710e8fb7 100644 --- a/hm/soispha/pkgs/scripts/apps/fupdate.1.md +++ b/hm/soispha/pkgs/scripts/apps/fupdate.1.md @@ -3,29 +3,34 @@ % May 2023 # NAME + fupdate - updates your flake, while checking for common mistakes # SYNOPSIS -**fupdate** list of [*flake*|*<some word>*|*--help*|*-h*] + +**fupdate** list of \[*flake*|*\<some word>*|*--help*|*-h*\] # DESCRIPTION + Argument can be stacked, this makes it possible to specify multiple targets to be updated in succession. See the Examples section for further details. No argument or *flake* : **fupdate**, when executed without arguments or with *flake*, will update your *flake.lock*, check for duplicate flake inputs, i.e., an input has an input declared, which you have also declared as input, and will run a script called *update.sh*, if you allow it. The allowance for the script is asked, when you run **fupdate** and the found script is not yet allowed. Furthermore, the allowance is based on the concrete sha256 hash of the script, so any changes will require another allowance. -**<some word>** as argument -: If the executable **update-<some word>** is reachable thought the PATH variable, than this is run. Otherwise, the program will exit. +**\<some word>** as argument +: If the executable **update-\<some word>** is reachable thought the PATH variable, than this is run. Otherwise, the program will exit. # OPTIONS -**\-\-help**, **-h** + +**--help**, **-h** : Displays a help message and exit. -**\-\-version**, **-v** +**--version**, **-v** : Displays the software version and exit. # EXAMPLES + **fupdate** or **fupdate flake** : Updates your *flake.lock*. See the Description section for further details. @@ -36,6 +41,7 @@ The allowance for the script is asked, when you run **fupdate** and the found sc : First updates your flake, then, if the command succeeded, runs **update-sys**, afterweich **update-docs** is run. # FILES + *update.sh* : This is supposed to be a shell script located in your flake base directory, i.e., the directory which contains both a *flake.nix* and a *flake.lock* file. @@ -43,9 +49,11 @@ The allowance for the script is asked, when you run **fupdate** and the found sc : **fupdate** will store the hashes to the allowed *update.sh* files here. # BUGS + Report bugs to <https://codeberg.org/soispha/flake_update/issues>. # COPYRIGHT + Copyright (C) 2023 Soispha This program is free software: you can redistribute it and/or modify diff --git a/hm/soispha/pkgs/scripts/apps/fupdate.sh b/hm/soispha/pkgs/scripts/apps/fupdate.sh index 7722c070..c038fa69 100755 --- a/hm/soispha/pkgs/scripts/apps/fupdate.sh +++ b/hm/soispha/pkgs/scripts/apps/fupdate.sh @@ -3,11 +3,13 @@ # shellcheck source=/dev/null SHELL_LIBRARY_VERSION="2.0.13" . %SHELL_LIBRARY_PATH +UPDATE_SCRIPT_NAME="update.sh" +CONFIG_DIRECTORY_PATH="$HOME/.local/share/flake-update" -UPDATE_SCRIPT_NAME="update.sh"; -CONFIG_DIRECTORY_PATH="$HOME/.local/share/flake-update"; - +# Both are used in version() +# shellcheck disable=SC2034 AUTHORS="Soispha" +# shellcheck disable=SC2034 YEARS="2023" # Searches upward for a `UPDATE_SCRIPT_NAME` script @@ -22,68 +24,68 @@ check_for_update_script() { # Checks if a given path to the update script is allowed. # Takes the path as input # Return 0, if allowed, 1 if not. -check_for_allowed_update_script(){ - update_script="$1"; - config_path="${CONFIG_DIRECTORY_PATH}${update_script}"; - update_script_hash="$(sha256sum "$update_script")"; +check_for_allowed_update_script() { + update_script="$1" + config_path="${CONFIG_DIRECTORY_PATH}${update_script}" + update_script_hash="$(sha256sum "$update_script")" if [ -f "$config_path" ]; then - if [ "$(cat "$config_path")" = "$update_script_hash" ];then - dbg "Recorded hash matches"; - return 0; + if [ "$(cat "$config_path")" = "$update_script_hash" ]; then + dbg "Recorded hash matches" + return 0 else - dbg "Recorded hash \'$(cat "$config_path")\' does not match real hash \'$update_script_hash\', assuming not allowed"; - return 1; + dbg "Recorded hash \'$(cat "$config_path")\' does not match real hash \'$update_script_hash\', assuming not allowed" + return 1 fi else - dbg "Path \'$config_path\' does not exist, assuming not allowed"; - return 1; + dbg "Path \'$config_path\' does not exist, assuming not allowed" + return 1 fi } - # Asks the user if they want to allow a given script. # Takes the path as input -ask_to_allow_update_script(){ - update_script="$1"; - config_path="${CONFIG_DIRECTORY_PATH}${update_script}"; - update_script_hash="$(sha256sum "$update_script")"; - println "\033[2J"; # clear the screen - cat "$update_script"; - readp "Do you want to allow this script?[N/y]: " allow; - dbg "allow is: $allow"; +ask_to_allow_update_script() { + update_script="$1" + config_path="${CONFIG_DIRECTORY_PATH}${update_script}" + update_script_hash="$(sha256sum "$update_script")" + println "\033[2J" # clear the screen + cat "$update_script" + readp "Do you want to allow this script?[N/y]: " allow + # shellcheck disable=SC2154 + dbg "allow is: $allow" case "$allow" in - [yY]) - dbg "allowed script"; - dbg "storing contents in: $config_path"; - mkdir --parents "$(dirname "$config_path")"; - print "$update_script_hash" > "$config_path"; - ;; - *) - UPDATE_SCRIPT_NOT_ALLOWED=true; - ;; + [yY]) + dbg "allowed script" + dbg "storing contents in: $config_path" + mkdir --parents "$(dirname "$config_path")" + print "$update_script_hash" >"$config_path" + ;; + *) + UPDATE_SCRIPT_NOT_ALLOWED=true + ;; esac } # Runs the provided script and continues to update the nix flake # Takes the path to the script and the directory to the flake as arguments # If the path to the update script is empty, it will be ignored -update(){ - update_script="$1"; - flake_base_dir="$2"; +update() { + update_script="$1" + flake_base_dir="$2" - [ "$update_script" = "" ] || "$update_script"; - dbg "changed directory to: $flake_base_dir"; - cd "$flake_base_dir" || die "Provided dir \'$flake_base_dir\' can not be accessed"; + [ "$update_script" = "" ] || "$update_script" + dbg "changed directory to: $flake_base_dir" + cd "$flake_base_dir" || die "Provided dir \'$flake_base_dir\' can not be accessed" nix flake update - if grep '[^0-9]_[0-9]' flake.lock > /dev/null; then - batgrep '[^0-9]_[0-9]' flake.lock; - die "Your flake.nix contains duplicate inputs!"; + if grep '[^0-9]_[0-9]' flake.lock >/dev/null; then + batgrep '[^0-9]_[0-9]' flake.lock + die "Your flake.nix contains duplicate inputs!" fi } help() { -cat << EOF + cat <<EOF This is a Nix flake update manager. Usage: @@ -105,63 +107,63 @@ EOF main() { if ! [ "$UPDATE_SCRIPT_NOT_ALLOWED" = true ]; then - update_script="$(check_for_update_script)"; - flake_base_dir="$(search_flake_base_dir)"; # Assume, that the update script is in the base dir - dbg "update_script is: $update_script"; - dbg "flake_base_dir is: $flake_base_dir"; + update_script="$(check_for_update_script)" + flake_base_dir="$(search_flake_base_dir)" # Assume, that the update script is in the base dir + dbg "update_script is: $update_script" + dbg "flake_base_dir is: $flake_base_dir" if [ "$update_script" = "" ]; then - update "" "$flake_base_dir"; + update "" "$flake_base_dir" elif check_for_allowed_update_script "$update_script" && ! [ "$update_script" = "" ]; then - update "$update_script" "$flake_base_dir"; + update "$update_script" "$flake_base_dir" else - ask_to_allow_update_script "$update_script"; - main; + ask_to_allow_update_script "$update_script" + main fi fi } if [ "$#" -eq 0 ]; then - main; + main fi for input in "$@"; do case "$input" in - "--help" | "-h") - help; - exit 0; - ;; - "--version" | "-v") - version; - exit 0; - ;; - "--") - end_of_cli_options=true; - ;; + "--help" | "-h") + help + exit 0 + ;; + "--version" | "-v") + version + exit 0 + ;; + "--") + end_of_cli_options=true + ;; esac [ "$end_of_cli_options" = "true" ] && break done while [ "$#" -ne 0 ]; do case "$1" in - "flake") - main; - shift 1; - ;; - *) - command="$1"; - shift 1; - [ "$1" = "--" ] && shift 1 - if which update-"$command" > /dev/null 2>&1;then - if [ "$end_of_cli_options" = "true" ]; then - update-"$command" "$@"; - else - update-"$command"; - fi + "flake") + main + shift 1 + ;; + *) + command="$1" + shift 1 + [ "$1" = "--" ] && shift 1 + if which update-"$command" >/dev/null 2>&1; then + if [ "$end_of_cli_options" = "true" ]; then + update-"$command" "$@" else - die "command \"update-$command\" is not executable, or does not exist"; + update-"$command" fi - ;; + else + die "command \"update-$command\" is not executable, or does not exist" + fi + ;; esac [ "$end_of_cli_options" = "true" ] && break done diff --git a/hm/soispha/pkgs/scripts/small_functions/screenshot_persistent.sh b/hm/soispha/pkgs/scripts/small_functions/screenshot_persistent.sh index 9e73bed3..5992e02f 100755 --- a/hm/soispha/pkgs/scripts/small_functions/screenshot_persistent.sh +++ b/hm/soispha/pkgs/scripts/small_functions/screenshot_persistent.sh @@ -6,20 +6,17 @@ SHELL_LIBRARY_VERSION="2.0.13" . %SHELL_LIBRARY_PATH # only generate a path (this could lead to a time-of-check/time-of-use bug) tmp="$(mktmp --dry-run)" -if grim -g "$(slurp)" "$tmp" -then - name="$(rofi -dmenu -p "Name of screenshot: " -l 0)"; - screen_shot_path="$HOME/media/pictures/screenshots/$name.png"; - while [ -f "$screen_shot_path" ] - do +if grim -g "$(slurp)" "$tmp"; then + name="$(rofi -dmenu -p "Name of screenshot: " -l 0)" + screen_shot_path="$HOME/media/pictures/screenshots/$name.png" + while [ -f "$screen_shot_path" ]; do notify-send "Warning" 'Screenshot name already in use!' - name="$(rofi -dmenu -p "New name of screenshot: " -l 0)"; - screen_shot_path="$HOME/media/pictures/screenshots/$name.png"; + name="$(rofi -dmenu -p "New name of screenshot: " -l 0)" + screen_shot_path="$HOME/media/pictures/screenshots/$name.png" done - mv "$tmp" "$screen_shot_path"; - alacritty -e lf -command ":{{ set sortby atime; set reverse!; }}"; + mv "$tmp" "$screen_shot_path" + alacritty -e lf -command ":{{ set sortby atime; set reverse!; }}" fi - # vim: ft=sh diff --git a/hm/soispha/pkgs/scripts/small_functions/update-sys.sh b/hm/soispha/pkgs/scripts/small_functions/update-sys.sh index 20e38841..68fb342d 100755 --- a/hm/soispha/pkgs/scripts/small_functions/update-sys.sh +++ b/hm/soispha/pkgs/scripts/small_functions/update-sys.sh @@ -4,7 +4,7 @@ SHELL_LIBRARY_VERSION="2.0.13" . %SHELL_LIBRARY_PATH help() { - cat << EOF + cat <<EOF This is a NixOS System flake update manager. Usage: @@ -18,61 +18,60 @@ Options: --help | -h output this help. EOF - exit "$1"; + exit "$1" } -default_branch=$(mktmp); -BRANCH=""; +default_branch=$(mktmp) +BRANCH="" -while [ "$#" -gt 0 ];do +while [ "$#" -gt 0 ]; do case "$1" in - "--help" | "-h") - help 0; - ;; - "--branch" | "-b") - if [ -n "$2" ];then - BRANCH="$2"; - else - error "$1 requires an argument"; - help 1; - fi - shift 2; - ;; - "--mode" | "-m") - if [ -n "$2" ];then - MODE="$2"; - else - error "$1 requires an argument"; - help 1; - fi - shift 2; - ;; - *) - error "the option $1 does not exist!"; - help 1; - ;; + "--help" | "-h") + help 0 + ;; + "--branch" | "-b") + if [ -n "$2" ]; then + BRANCH="$2" + else + error "$1 requires an argument" + help 1 + fi + shift 2 + ;; + "--mode" | "-m") + if [ -n "$2" ]; then + MODE="$2" + else + error "$1 requires an argument" + help 1 + fi + shift 2 + ;; + *) + error "the option $1 does not exist!" + help 1 + ;; esac done - -cd /etc/nixos || die "No /etc/nixos"; -msg "Starting system update..."; -git remote update origin --prune > /dev/null 2>&1; -if ! [ "$BRANCH" = "" ];then - git switch "$BRANCH" > /dev/null 2>&1 && msg2 "Switched to branch '$BRANCH'"; +cd /etc/nixos || die "No /etc/nixos" +msg "Starting system update..." +git remote update origin --prune >/dev/null 2>&1 +if ! [ "$BRANCH" = "" ]; then + git switch "$BRANCH" >/dev/null 2>&1 && msg2 "Switched to branch '$BRANCH'" fi -msg2 "Updating git repository..."; -git pull --rebase; +msg2 "Updating git repository..." +git pull --rebase -git remote show origin | grep 'HEAD' | cut -d':' -f2 | sed -e 's/^ *//g' -e 's/ *$//g' > "$default_branch" & +git remote show origin | grep 'HEAD' | cut -d':' -f2 | sed -e 's/^ *//g' -e 's/ *$//g' >"$default_branch" & -msg2 "Updating system..."; +msg2 "Updating system..." if [ -n "$MODE" ]; then - nixos-rebuild "$MODE"; + nixos-rebuild "$MODE" else - nixos-rebuild switch; + nixos-rebuild switch fi -git switch "$(cat "$default_branch")" > /dev/null 2>&1 && msg2 "Switched to branch '$(cat "$default_branch")'"; -msg "Finished Update!"; +git switch "$(cat "$default_branch")" >/dev/null 2>&1 && msg2 "Switched to branch '$(cat "$default_branch")'" +msg "Finished Update!" # vim: ft=sh diff --git a/hm/soispha/pkgs/scripts/specific/neorg/neorg_id_function.sh b/hm/soispha/pkgs/scripts/specific/neorg/neorg_id_function.sh index 413a18de..7c3fb2a3 100755 --- a/hm/soispha/pkgs/scripts/specific/neorg/neorg_id_function.sh +++ b/hm/soispha/pkgs/scripts/specific/neorg/neorg_id_function.sh @@ -1,12 +1,12 @@ #! /bin/sh -context="$(task _get rc.context)"; +context="$(task _get rc.context)" if [ "$context" ]; then - filter="project:$context"; + filter="project:$context" else - filter="0-10000"; + filter="0-10000" fi -tasks="$(task "$filter" _ids)"; +tasks="$(task "$filter" _ids)" if [ "$tasks" ]; then - echo "$tasks" | xargs task _zshids | awk -F: -v q="'" '{gsub(/'\''/, q "\\" q q ); print $1 ":" q $2 q}'; + echo "$tasks" | xargs task _zshids | awk -F: -v q="'" '{gsub(/'\''/, q "\\" q q ); print $1 ":" q $2 q}' fi diff --git a/hm/soispha/pkgs/scripts/specific/neorg/sh/functions/add.sh b/hm/soispha/pkgs/scripts/specific/neorg/sh/functions/add.sh index bd700775..5a830a10 100755 --- a/hm/soispha/pkgs/scripts/specific/neorg/sh/functions/add.sh +++ b/hm/soispha/pkgs/scripts/specific/neorg/sh/functions/add.sh @@ -1,23 +1,23 @@ #!/usr/bin/env dash add0open_taskwarrior_project_file() { - task_project_file="%TASK_PROJECT_FILE"; + task_project_file="%TASK_PROJECT_FILE" cd "$(dirname $task_project_file)" || die "BUG: task_project_file ('$task_project_file') can't be accessed" - git_dir="$(search_flake_base_dir)"; + git_dir="$(search_flake_base_dir)" [ "$git_dir" ] || die "(BUG): No git directory?" cd "$git_dir" || die "Unreachable, this MUST exists" - nvim "$task_project_file"; - git add "$task_project_file"; + nvim "$task_project_file" + git add "$task_project_file" base_task_project_file_path="$(awk "{ gsub(\"$git_dir/\", \"\", \$0); print }" "$(ptmp "$task_project_file")")" - git add $task_project_file; + git add $task_project_file # Check that only the project file has been added (and that our file is actually # modified) if git status --porcelain=v2 | awk -v path="$base_task_project_file_path" 'BEGIN { hit = 0 } { if ($2 ~ /A./ || $2 ~ /M./) { if ($NF ~ path) { hit = 1 } else { hit = 0; exit 1 } } } END { if (hit == 1) { exit 0 } else { exit 1 } }'; then - git commit --verbose --message="chore($(dirname "$base_task_project_file_path")): Update" + git commit --verbose --message="chore($(dirname "$base_task_project_file_path")): Update" fi } diff --git a/hm/soispha/pkgs/scripts/specific/neorg/sh/functions/context.sh b/hm/soispha/pkgs/scripts/specific/neorg/sh/functions/context.sh index b9ae4463..7095847d 100755 --- a/hm/soispha/pkgs/scripts/specific/neorg/sh/functions/context.sh +++ b/hm/soispha/pkgs/scripts/specific/neorg/sh/functions/context.sh @@ -4,40 +4,40 @@ context0open_current_task_context() { current_context="$(utils0get_current_context)" if [ "$current_context" ]; then - context_path="$(utils0get_current_context_path "$current_context")"; + context_path="$(utils0get_current_context_path "$current_context")" - extended_neorg_project_dir="$(utils0get_neorg_project_dir)"; - cd "$extended_neorg_project_dir" || die "(BUG?): Can not access the project dir: $extended_neorg_project_dir"; + extended_neorg_project_dir="$(utils0get_neorg_project_dir)" + cd "$extended_neorg_project_dir" || die "(BUG?): Can not access the project dir: $extended_neorg_project_dir" - nvim "$extended_neorg_project_dir/$context_path"; + nvim "$extended_neorg_project_dir/$context_path" - git add .; + git add . git commit --message="chore($(dirname "$context_path")): Update" --no-gpg-sign else - warn "No context active"; + warn "No context active" fi } context0open_current_task_context_at_task_id() { - task_id="$1"; + task_id="$1" current_context="$(utils0get_current_context)" if [ "$current_context" ]; then - context_path="$(utils0get_current_context_path "$current_context")"; - extended_neorg_project_dir="$(utils0get_neorg_project_dir)"; + context_path="$(utils0get_current_context_path "$current_context")" + extended_neorg_project_dir="$(utils0get_neorg_project_dir)" task_uuid="$(task "$task_id" uuids)" - cd "$extended_neorg_project_dir" || die "(BUG?): Can not access the project dir: $extended_neorg_project_dir"; + cd "$extended_neorg_project_dir" || die "(BUG?): Can not access the project dir: $extended_neorg_project_dir" if ! grep -q "% $task_uuid" "$extended_neorg_project_dir/$context_path"; then - echo "* TITLE (% $task_uuid)" >> "$extended_neorg_project_dir/$context_path" + echo "* TITLE (% $task_uuid)" >>"$extended_neorg_project_dir/$context_path" fi - nvim "$extended_neorg_project_dir/$context_path" -c "/% $task_uuid"; + nvim "$extended_neorg_project_dir/$context_path" -c "/% $task_uuid" - git add .; + git add . git commit --message="chore($(dirname "$context_path")): Update" --no-gpg-sign else - warn "No context active"; + warn "No context active" fi } diff --git a/hm/soispha/pkgs/scripts/specific/neorg/sh/functions/dmenu.sh b/hm/soispha/pkgs/scripts/specific/neorg/sh/functions/dmenu.sh index 36133004..73e9460a 100755 --- a/hm/soispha/pkgs/scripts/specific/neorg/sh/functions/dmenu.sh +++ b/hm/soispha/pkgs/scripts/specific/neorg/sh/functions/dmenu.sh @@ -1,12 +1,12 @@ #!/usr/bin/env dash dmenu0open_context_in_browser() { - project="$(echo "%ALL_PROJECTS_PIPE" | rofi -sep "|" -dmenu)"; + project="$(echo "%ALL_PROJECTS_PIPE" | rofi -sep "|" -dmenu)" if [ "$project" ]; then - project0open_project_in_browser "$project"; + project0open_project_in_browser "$project" else - notify-send "(neorg/dmenu) No project selected"; + notify-send "(neorg/dmenu) No project selected" exit 1 fi } diff --git a/hm/soispha/pkgs/scripts/specific/neorg/sh/functions/f_start.sh b/hm/soispha/pkgs/scripts/specific/neorg/sh/functions/f_start.sh index c75986a7..2423dd44 100755 --- a/hm/soispha/pkgs/scripts/specific/neorg/sh/functions/f_start.sh +++ b/hm/soispha/pkgs/scripts/specific/neorg/sh/functions/f_start.sh @@ -1,7 +1,7 @@ #!/usr/bin/env dash fstart0start_new_task() { - task_id="$1"; - fstop0stop_current_task; + task_id="$1" + fstop0stop_current_task task start "$task_id" } diff --git a/hm/soispha/pkgs/scripts/specific/neorg/sh/functions/f_stop.sh b/hm/soispha/pkgs/scripts/specific/neorg/sh/functions/f_stop.sh index d60cb46f..e4ff0b94 100755 --- a/hm/soispha/pkgs/scripts/specific/neorg/sh/functions/f_stop.sh +++ b/hm/soispha/pkgs/scripts/specific/neorg/sh/functions/f_stop.sh @@ -2,6 +2,6 @@ fstop0stop_current_task() { # we ensured that only one task may be active - active="$(task +ACTIVE _ids)"; - [ "$active" ] && task stop "$active"; + active="$(task +ACTIVE _ids)" + [ "$active" ] && task stop "$active" } diff --git a/hm/soispha/pkgs/scripts/specific/neorg/sh/functions/project.sh b/hm/soispha/pkgs/scripts/specific/neorg/sh/functions/project.sh index 8def0930..64591850 100755 --- a/hm/soispha/pkgs/scripts/specific/neorg/sh/functions/project.sh +++ b/hm/soispha/pkgs/scripts/specific/neorg/sh/functions/project.sh @@ -1,33 +1,32 @@ #!/usr/bin/env dash project0open_current_context_in_browser() { - current_context="$(utils0get_current_context)"; - [ "$current_context" ] || die "No current context to use"; - project0open_context_in_browser "$(utils0context2project "$current_context")"; + current_context="$(utils0get_current_context)" + [ "$current_context" ] || die "No current context to use" + project0open_context_in_browser "$(utils0context2project "$current_context")" } project0open_project_in_browser() { - project="$1"; + project="$1" [ "$project" ] || die "BUG: No context supplied to project0open_context_in_browser" - old_context="$(utils0get_current_context)"; + old_context="$(utils0get_current_context)" # We have ensured that only one task may be active - old_started_task="$(task +ACTIVE _ids)"; + old_started_task="$(task +ACTIVE _ids)" - tracking="$(mktmp)"; - task "project:$project" _ids | xargs --no-run-if-empty task _zshids > "$tracking"; + tracking="$(mktmp)" + task "project:$project" _ids | xargs --no-run-if-empty task _zshids >"$tracking" task context "$(utils0project2context "$project")" while read -r description; do - desc="$(echo "$description" | awk -F: '{print $2}' )"; + desc="$(echo "$description" | awk -F: '{print $2}')" if [ "$desc" = "tracking" ]; then - task_id="$(echo "$description" | awk -F: '{print $1}' )"; - notify-send "(Neorg)" "Starting task $project -> $desc"; + task_id="$(echo "$description" | awk -F: '{print $1}')" + notify-send "(Neorg)" "Starting task $project -> $desc" task start "$task_id" break fi - done < "$tracking" - + done <"$tracking" firefox -P "$project" diff --git a/hm/soispha/pkgs/scripts/specific/neorg/sh/functions/utils.sh b/hm/soispha/pkgs/scripts/specific/neorg/sh/functions/utils.sh index 91da811a..c3843e8e 100755 --- a/hm/soispha/pkgs/scripts/specific/neorg/sh/functions/utils.sh +++ b/hm/soispha/pkgs/scripts/specific/neorg/sh/functions/utils.sh @@ -3,19 +3,20 @@ # Runs it's first argument and then the second, regardless if the first failed or # succeeded utils0chain() { - eval "$1"; eval "$2" + eval "$1" + eval "$2" } utils0get_current_context() { - current_context="$(task _get rc.context)"; - printf "%s\n" "$current_context"; + current_context="$(task _get rc.context)" + printf "%s\n" "$current_context" } utils0get_current_context_path() { - current_context="$1"; - context_path="$(task _get rc.context."$current_context".rc.neorg_path 2>/dev/null)"; + current_context="$1" + context_path="$(task _get rc.context."$current_context".rc.neorg_path 2>/dev/null)" if ! [ "$context_path" ]; then - context_path="$(grep "context.$current_context.rc.neorg_path" "%HOME_TASKRC" | awk 'BEGIN {FS="="} {print $2}')"; + context_path="$(grep "context.$current_context.rc.neorg_path" "%HOME_TASKRC" | awk 'BEGIN {FS="="} {print $2}')" [ "$context_path" ] || die "All contexts should have a 'neorg_path' set!" fi printf "%s\n" "$context_path" @@ -23,18 +24,17 @@ utils0get_current_context_path() { utils0get_neorg_project_dir() { # Perform shell expansion of Tilde - neorg_project_dir="$(sed "s|^~|$HOME|" "$(ptmp "%DEFAULT_NEORG_PROJECT_DIR")")"; + neorg_project_dir="$(sed "s|^~|$HOME|" "$(ptmp "%DEFAULT_NEORG_PROJECT_DIR")")" printf "%s\n" "$neorg_project_dir" } - utils0project2context() { - project="$1"; - context="$(sed 's|\.|_|g' "$(ptmp "$project")")"; - printf "%s\n" "$context"; + project="$1" + context="$(sed 's|\.|_|g' "$(ptmp "$project")")" + printf "%s\n" "$context" } utils0context2project() { - context="$1"; - project="$(sed 's|_|\.|g' "$(ptmp "$context")")"; - printf "%s\n" "$project"; + context="$1" + project="$(sed 's|_|\.|g' "$(ptmp "$context")")" + printf "%s\n" "$project" } diff --git a/hm/soispha/pkgs/scripts/specific/neorg/sh/main.sh b/hm/soispha/pkgs/scripts/specific/neorg/sh/main.sh index 25b434fc..dc746ef8 100755 --- a/hm/soispha/pkgs/scripts/specific/neorg/sh/main.sh +++ b/hm/soispha/pkgs/scripts/specific/neorg/sh/main.sh @@ -14,7 +14,6 @@ SHELL_LIBRARY_VERSION="2.0.13" . %SHELL_LIBRARY_PATH . ./functions/utils . ./functions/workspace - # these are used in version() # shellcheck disable=2034 AUTHORS="Soispha" @@ -24,7 +23,7 @@ YEARS="2023" NAME="neorg" help() { -cat << EOF + cat <<EOF This is the core interface to the system-integrated task management USAGE: @@ -82,75 +81,75 @@ EOF for arg in "$@"; do case "$arg" in - "--help" | "-h") - help; - exit 0; - ;; - "--version" | "-v") - version; - exit 0; - ;; + "--help" | "-h") + help + exit 0 + ;; + "--version" | "-v") + version + exit 0 + ;; esac done while [ "$#" -ne 0 ]; do case "$1" in - "t"*) # task - shift 1; - task_id="$1"; - [ "$task_id" ] || utils0chain context0open_current_task_context "exit 0" - context0open_current_task_context_at_task_id "$task_id"; - exit 0; - ;; - "w"*) # workspace - shift 1; - workspace_to_open="$1"; - # TODO: Exit with 1 on error, instead of the 0 <2023-10-20> - [ "$workspace_to_open" ] || utils0chain workspace0open_neorg_workspace_prompt "exit 0"; - workspace0open_neorg_workspace "$workspace_to_open"; - exit 0; - ;; - "p"*) # project - shift 1; - project_to_open="$1"; - # TODO: Exit with 1 on error, instead of the 0 <2023-10-20> - [ "$project_to_open" ] || utils0chain project0open_current_context_in_browser "exit 0"; - if ! grep -q "$project_to_open" "$(ptmp "%ALL_PROJECTS_NEWLINE")"; then - die "Your project ('$project_to_open') is not in the list of available projects: -%ALL_PROJECTS_COMMA"; - fi - project0open_project_in_browser "$project_to_open"; - exit 0; - ;; - "l"*) # list - list0list_all_contexts_newline; - exit 0 - ;; - "a"*) # add-project - add0open_taskwarrior_project_file; - exit 0 - ;; - "d"*) # dmenu - dmenu0open_context_in_browser; - exit 0 - ;; - "fsta"*) # fstart - shift 1; - task_id="$1"; - [ "$task_id" ] || die "No task id provided to fstart"; - fstart0start_new_task "$task_id"; - exit 0 - ;; - "fsto"*) # fstop - fstop0stop_current_task; - exit 0 - ;; - *) - die "Command '$1' does not exist! Please look at:\n $NAME --help"; - exit 0; - ;; + "t"*) # task + shift 1 + task_id="$1" + [ "$task_id" ] || utils0chain context0open_current_task_context "exit 0" + context0open_current_task_context_at_task_id "$task_id" + exit 0 + ;; + "w"*) # workspace + shift 1 + workspace_to_open="$1" + # TODO: Exit with 1 on error, instead of the 0 <2023-10-20> + [ "$workspace_to_open" ] || utils0chain workspace0open_neorg_workspace_prompt "exit 0" + workspace0open_neorg_workspace "$workspace_to_open" + exit 0 + ;; + "p"*) # project + shift 1 + project_to_open="$1" + # TODO: Exit with 1 on error, instead of the 0 <2023-10-20> + [ "$project_to_open" ] || utils0chain project0open_current_context_in_browser "exit 0" + if ! grep -q "$project_to_open" "$(ptmp "%ALL_PROJECTS_NEWLINE")"; then + die "Your project ('$project_to_open') is not in the list of available projects: +%ALL_PROJECTS_COMMA" + fi + project0open_project_in_browser "$project_to_open" + exit 0 + ;; + "l"*) # list + list0list_all_contexts_newline + exit 0 + ;; + "a"*) # add-project + add0open_taskwarrior_project_file + exit 0 + ;; + "d"*) # dmenu + dmenu0open_context_in_browser + exit 0 + ;; + "fsta"*) # fstart + shift 1 + task_id="$1" + [ "$task_id" ] || die "No task id provided to fstart" + fstart0start_new_task "$task_id" + exit 0 + ;; + "fsto"*) # fstop + fstop0stop_current_task + exit 0 + ;; + *) + die "Command '$1' does not exist! Please look at:\n $NAME --help" + exit 0 + ;; esac done -context0open_current_task_context; +context0open_current_task_context # vim: ft=sh diff --git a/hm/soispha/pkgs/scripts/wrappers/hibernate.sh b/hm/soispha/pkgs/scripts/wrappers/hibernate.sh index 96170bcb..f3e74732 100755 --- a/hm/soispha/pkgs/scripts/wrappers/hibernate.sh +++ b/hm/soispha/pkgs/scripts/wrappers/hibernate.sh @@ -3,14 +3,13 @@ # shellcheck source=/dev/null SHELL_LIBRARY_VERSION="2.0.13" . %SHELL_LIBRARY_PATH -context="$(task _get rc.context)"; +context="$(task _get rc.context)" [ "$context" ] && task context none # We have ensured that only one task is active -active="$(task +ACTIVE _ids)"; +active="$(task +ACTIVE _ids)" [ "$active" ] && task stop "$active" systemctl hibernate "$@" - # vim: ft=sh diff --git a/hm/soispha/pkgs/scripts/wrappers/lock.sh b/hm/soispha/pkgs/scripts/wrappers/lock.sh index 376773c6..f1c5c711 100755 --- a/hm/soispha/pkgs/scripts/wrappers/lock.sh +++ b/hm/soispha/pkgs/scripts/wrappers/lock.sh @@ -3,12 +3,11 @@ # shellcheck source=/dev/null SHELL_LIBRARY_VERSION="2.0.13" . %SHELL_LIBRARY_PATH - -context="$(task _get rc.context)"; +context="$(task _get rc.context)" [ "$context" ] && task context none # We have ensured that only one task is active -active="$(task +ACTIVE _ids)"; +active="$(task +ACTIVE _ids)" [ "$active" ] && task stop "$active" swaylock diff --git a/hm/soispha/pkgs/scripts/wrappers/mpc-fav.sh b/hm/soispha/pkgs/scripts/wrappers/mpc-fav.sh index f9107ff6..7385ce43 100755 --- a/hm/soispha/pkgs/scripts/wrappers/mpc-fav.sh +++ b/hm/soispha/pkgs/scripts/wrappers/mpc-fav.sh @@ -3,13 +3,12 @@ # shellcheck source=/dev/null SHELL_LIBRARY_VERSION="2.0.13" . %SHELL_LIBRARY_PATH -FAV_DIR="$XDG_MUSIC_DIR/playlists/favourites"; +FAV_DIR="$XDG_MUSIC_DIR/playlists/favourites" -cd "$XDG_MUSIC_DIR" || die "No music dir!"; +cd "$XDG_MUSIC_DIR" || die "No music dir!" -[ -d "$FAV_DIR" ] || mkdir --parents "$FAV_DIR"; - -ln -sr "$(mpc --format '%file%' current)" "$FAV_DIR/" || die "Link failed!"; +[ -d "$FAV_DIR" ] || mkdir --parents "$FAV_DIR" +ln -sr "$(mpc --format '%file%' current)" "$FAV_DIR/" || die "Link failed!" # vim: ft=sh diff --git a/hm/soispha/pkgs/scripts/wrappers/mpc-rm.sh b/hm/soispha/pkgs/scripts/wrappers/mpc-rm.sh index cc01c322..03673dbe 100755 --- a/hm/soispha/pkgs/scripts/wrappers/mpc-rm.sh +++ b/hm/soispha/pkgs/scripts/wrappers/mpc-rm.sh @@ -3,12 +3,8 @@ # shellcheck source=/dev/null SHELL_LIBRARY_VERSION="2.0.13" . %SHELL_LIBRARY_PATH - cd "$XDG_MUSIC_DIR" || die "No music dir!" -trash-put "$(mpc --format '%file%' current)"; -mpc del 0; - - - +trash-put "$(mpc --format '%file%' current)" +mpc del 0 # vim: ft=sh diff --git a/hm/soispha/pkgs/scripts/wrappers/sort_song.sh b/hm/soispha/pkgs/scripts/wrappers/sort_song.sh index f539cf15..8195cfcf 100755 --- a/hm/soispha/pkgs/scripts/wrappers/sort_song.sh +++ b/hm/soispha/pkgs/scripts/wrappers/sort_song.sh @@ -3,31 +3,32 @@ # shellcheck source=/dev/null SHELL_LIBRARY_VERSION="2.0.13" . %SHELL_LIBRARY_PATH -case "$("$1" | tr '[:upper:]' '[:lower:]')" in - "lyrics") - filter="LYRICS"; - directory="lyrics"; - ;; - "instrumental") - filter="INSTRUMENTAL"; - directory="instrumental"; - ;; - *) - die "Expected 'instrumental|lyrics' but got '$1'"; +case "$("$1" | tr '[:upper:]' '[:lower:]')" in +"lyrics") + filter="LYRICS" + directory="lyrics" + ;; +"instrumental") + filter="INSTRUMENTAL" + directory="instrumental" + ;; +*) + die "Expected 'instrumental|lyrics' but got '$1'" + ;; esac process() { mediainfo --Output=JSON "$1" | jq '.media.track | map(.Lyrics) | join("")' -}; +} -mkdir "../$directory"; +mkdir "../$directory" fd . --extension=opus | while read -r file; do if [ "$(process "$file")" = '""' ] || [ "$(process "$file")" = '"Instrumental"' ] || [ "$(process "$file")" = '"instrumental"' ]; then - echo "INSTRUMENTAL::$file"; + echo "INSTRUMENTAL::$file" else - echo "LYRICS::$file"; - fi; - done | grep "$filter" | awk 'BEGIN {FS="::"}{print $2}' | while read -r file; do ln -s "../all/$file" "../$directory/$file"; done + echo "LYRICS::$file" + fi +done | grep "$filter" | awk 'BEGIN {FS="::"}{print $2}' | while read -r file; do ln -s "../all/$file" "../$directory/$file"; done # vim: ft=sh diff --git a/hm/soispha/pkgs/scripts/wrappers/spodi.sh b/hm/soispha/pkgs/scripts/wrappers/spodi.sh index f8bc5337..8b4188b0 100755 --- a/hm/soispha/pkgs/scripts/wrappers/spodi.sh +++ b/hm/soispha/pkgs/scripts/wrappers/spodi.sh @@ -4,17 +4,15 @@ SHELL_LIBRARY_VERSION="2.0.13" . %SHELL_LIBRARY_PATH # This path must not contain spaces -DOWN_DIR="/home/soispha/media/music/down/spotify"; - -download_url="$1"; - +DOWN_DIR="/home/soispha/media/music/down/spotify" +download_url="$1" already_downloaded_files="$(mktmp)" -fd . "$DOWN_DIR" --exclude spotdl.log --exclude spotdl-errors.log > "$already_downloaded_files"; +fd . "$DOWN_DIR" --exclude spotdl.log --exclude spotdl-errors.log >"$already_downloaded_files" config="$(mktmp)" -cat << EOF | clean > "$config" +cat <<EOF | clean >"$config" # Main options --audio slider-kz bandcamp youtube-music piped youtube soundcloud --lyrics genius musixmatch azlyrics synced @@ -41,7 +39,7 @@ cat << EOF | clean > "$config" --log-level INFO EOF -if [ -z "$NO_CHECK" ] && [ "$(wc -l < "$already_downloaded_files" )" -ne 0 ];then +if [ -z "$NO_CHECK" ] && [ "$(wc -l <"$already_downloaded_files")" -ne 0 ]; then die "something is already downloaded" fi @@ -49,7 +47,6 @@ rm "$DOWN_DIR/spotdl.log" cd "$DOWN_DIR" || die "BUG: no $DOWN_DIR" touch "$DOWN_DIR/spotdl-errors.log" - # The sub shell needs to be unquoted, as the arguments may not be treated as one. # shellcheck disable=2046 unbuffer spotdl $(cat "$config") download "$download_url" | tee "$DOWN_DIR/spotdl.log" diff --git a/hm/soispha/pkgs/scripts/wrappers/yti.sh b/hm/soispha/pkgs/scripts/wrappers/yti.sh index c07f6665..caa5f443 100755 --- a/hm/soispha/pkgs/scripts/wrappers/yti.sh +++ b/hm/soispha/pkgs/scripts/wrappers/yti.sh @@ -8,10 +8,10 @@ DOWN_DIR=/home/soispha/media/music/down/youtube tmp=$(mktmp) config=$(mktmp) -for e in "$DOWN_DIR"/*.opus;do echo "$e" >> "$tmp";done +for e in "$DOWN_DIR"/*.opus; do echo "$e" >>"$tmp"; done [ "$(wc -l "$tmp" | awk '{print $1}')" -gt 2 ] && die "something is already downloaded" -cat << EO > "$config" +cat <<EO >"$config" --paths home:"$DOWN_DIR" #--output %(fulltitle) --restrict-filenames @@ -25,7 +25,6 @@ cat << EO > "$config" --audio-format best EO - rm "$DOWN_DIR/yt-dlp.log" cd "$DOWN_DIR" || die "BUG: no $DOWN_DIR" diff --git a/hm/soispha/wms/river/init.sh b/hm/soispha/wms/river/init.sh index 07b30732..9ec48d41 100755 --- a/hm/soispha/wms/river/init.sh +++ b/hm/soispha/wms/river/init.sh @@ -4,15 +4,15 @@ SHELL_LIBRARY_VERSION="2.0.13" . %SHELL_LIBRARY_PATH err_fail() { - if ! "$@";then - warning "\"$*\" failed!\n" >> ~/river_log + if ! "$@"; then + warning "\"$*\" failed!\n" >>~/river_log # msg "Executing the safe init!" # exec ~/.config/river/res/safe_init.sh fi } err_fail rm ~/river_log -exec 1>> "$HOME"/river_log -exec 2>> "$HOME"/river_log +exec 1>>"$HOME"/river_log +exec 2>>"$HOME"/river_log #trap err_fail ERR @@ -69,8 +69,6 @@ err_fail swayidle & err_fail alacritty & # }}} - - # Setup of layout [acts as exec!] {{{ err_fail riverctl default-layout rivertile @env_vars@ rivertile -main-ratio 0.5 -view-padding 1 -outer-padding 0 diff --git a/hm/soispha/wms/river/res/safe_init.sh b/hm/soispha/wms/river/res/safe_init.sh deleted file mode 100755 index 8e80026a..00000000 --- a/hm/soispha/wms/river/res/safe_init.sh +++ /dev/null @@ -1,160 +0,0 @@ -#!/bin/sh - -# This is the example configuration file for river. -# -# If you wish to edit this, you will probably want to copy it to -# $XDG_CONFIG_HOME/river/init or $HOME/.config/river/init first. -# -# See the river(1), riverctl(1), and rivertile(1) man pages for complete -# documentation. - -# Note: the "Super" modifier is also known as Logo, GUI, Windows, Mod4, etc. - -# Super+Shift+Return to start an instance of foot (https://codeberg.org/dnkl/foot) -riverctl map normal Super Return spawn alacritty - -# Super+Q to close the focused view -riverctl map normal Super Q close - -# Super+Shift+E to exit river -riverctl map normal Super+Shift Q exit - -# Super+J and Super+K to focus the next/previous view in the layout stack -riverctl map normal Super J focus-view next -riverctl map normal Super K focus-view previous - -# Super+Shift+J and Super+Shift+K to swap the focused view with the next/previous -# view in the layout stack -riverctl map normal Super+Shift J swap next -riverctl map normal Super+Shift K swap previous - -# Super+Period and Super+Comma to focus the next/previous output -riverctl map normal Super Period focus-output next -riverctl map normal Super Comma focus-output previous - -# Super+Shift+{Period,Comma} to send the focused view to the next/previous output -riverctl map normal Super+Shift Period send-to-output next -riverctl map normal Super+Shift Comma send-to-output previous - -# Super+Return to bump the focused view to the top of the layout stack -riverctl map normal Super Return zoom - -# Super+H and Super+L to decrease/increase the main ratio of rivertile(1) -riverctl map normal Super H send-layout-cmd rivertile "main-ratio -0.05" -riverctl map normal Super L send-layout-cmd rivertile "main-ratio +0.05" - -# Super+Shift+H and Super+Shift+L to increment/decrement the main count of rivertile(1) -riverctl map normal Super+Shift H send-layout-cmd rivertile "main-count +1" -riverctl map normal Super+Shift L send-layout-cmd rivertile "main-count -1" - -# Super+Alt+{H,J,K,L} to move views -riverctl map normal Super+Alt H move left 100 -riverctl map normal Super+Alt J move down 100 -riverctl map normal Super+Alt K move up 100 -riverctl map normal Super+Alt L move right 100 - -# Super+Alt+Control+{H,J,K,L} to snap views to screen edges -riverctl map normal Super+Alt+Control H snap left -riverctl map normal Super+Alt+Control J snap down -riverctl map normal Super+Alt+Control K snap up -riverctl map normal Super+Alt+Control L snap right - -# Super+Alt+Shift+{H,J,K,L} to resize views -riverctl map normal Super+Alt+Shift H resize horizontal -100 -riverctl map normal Super+Alt+Shift J resize vertical 100 -riverctl map normal Super+Alt+Shift K resize vertical -100 -riverctl map normal Super+Alt+Shift L resize horizontal 100 - -# Super + Left Mouse Button to move views -riverctl map-pointer normal Super BTN_LEFT move-view - -# Super + Right Mouse Button to resize views -riverctl map-pointer normal Super BTN_RIGHT resize-view - -for i in $(seq 1 9) -do - tags=$((1 << ($i - 1))) - - # Super+[1-9] to focus tag [0-8] - riverctl map normal Super $i set-focused-tags $tags - - # Super+Shift+[1-9] to tag focused view with tag [0-8] - riverctl map normal Super+Shift $i set-view-tags $tags - - # Super+Ctrl+[1-9] to toggle focus of tag [0-8] - riverctl map normal Super+Control $i toggle-focused-tags $tags - - # Super+Shift+Ctrl+[1-9] to toggle tag [0-8] of focused view - riverctl map normal Super+Shift+Control $i toggle-view-tags $tags -done - -# Super+0 to focus all tags -# Super+Shift+0 to tag focused view with all tags -all_tags=$(((1 << 32) - 1)) -riverctl map normal Super 0 set-focused-tags $all_tags -riverctl map normal Super+Shift 0 set-view-tags $all_tags - -# Super+Space to toggle float -riverctl map normal Super Space toggle-float - -# Super+F to toggle fullscreen -riverctl map normal Super F toggle-fullscreen - -# Super+{Up,Right,Down,Left} to change layout orientation -riverctl map normal Super Up send-layout-cmd rivertile "main-location top" -riverctl map normal Super Right send-layout-cmd rivertile "main-location right" -riverctl map normal Super Down send-layout-cmd rivertile "main-location bottom" -riverctl map normal Super Left send-layout-cmd rivertile "main-location left" - -# Declare a passthrough mode. This mode has only a single mapping to return to -# normal mode. This makes it useful for testing a nested wayland compositor -riverctl declare-mode passthrough - -# Super+F11 to enter passthrough mode -riverctl map normal Super F11 enter-mode passthrough - -# Super+F11 to return to normal mode -riverctl map passthrough Super F11 enter-mode normal - -# Various media key mapping examples for both normal and locked mode which do -# not have a modifier -for mode in normal locked -do - # Eject the optical drive (well if you still have one that is) - riverctl map $mode None XF86Eject spawn 'eject -T' - - # Control pulse audio volume with pamixer (https://github.com/cdemoulins/pamixer) - riverctl map $mode None XF86AudioRaiseVolume spawn 'pamixer -i 5' - riverctl map $mode None XF86AudioLowerVolume spawn 'pamixer -d 5' - riverctl map $mode None XF86AudioMute spawn 'pamixer --toggle-mute' - - # Control MPRIS aware media players with playerctl (https://github.com/altdesktop/playerctl) - riverctl map $mode None XF86AudioMedia spawn 'playerctl play-pause' - riverctl map $mode None XF86AudioPlay spawn 'playerctl play-pause' - riverctl map $mode None XF86AudioPrev spawn 'playerctl previous' - riverctl map $mode None XF86AudioNext spawn 'playerctl next' - - # Control screen backlight brightness with light (https://github.com/haikarainen/light) - riverctl map $mode None XF86MonBrightnessUp spawn 'light -A 5' - riverctl map $mode None XF86MonBrightnessDown spawn 'light -U 5' -done - -# Set background and border color -riverctl background-color 0x002b36 -riverctl border-color-focused 0x93a1a1 -riverctl border-color-unfocused 0x586e75 - -# Set keyboard repeat rate -riverctl set-repeat 50 300 - -# Make certain views start floating -riverctl float-filter-add app-id float -riverctl float-filter-add title "popup title with spaces" - -# Set app-ids and titles of views which should use client side decorations -riverctl csd-filter-add app-id "gedit" - -# Set the default layout generator to be rivertile and start it. -# River will send the process group of the init executable SIGTERM on exit. -riverctl default-layout rivertile -rivertile -view-padding 6 -outer-padding 6 |