From cc09b607330385d6d81b9c47cf64a2442432e93f Mon Sep 17 00:00:00 2001 From: Soispha Date: Tue, 20 Feb 2024 16:35:15 +0100 Subject: refactor(treewide): Add a `.sh` extension to shell scripts --- hm/soispha/conf/firefox/scripts/update_extensions | 22 ---- .../conf/firefox/scripts/update_extensions.sh | 22 ++++ hm/soispha/conf/git/default.nix | 2 +- hm/soispha/conf/git/scripts/commit | 19 ---- hm/soispha/conf/git/scripts/commit.sh | 19 ++++ hm/soispha/conf/gpg/agent-program | 2 - hm/soispha/conf/gpg/agent-program.sh | 2 + hm/soispha/conf/gpg/default.nix | 2 +- hm/soispha/conf/lf/commands/default.nix | 73 ++++++------ hm/soispha/conf/lf/commands/scripts/archive | 54 --------- hm/soispha/conf/lf/commands/scripts/archive.sh | 54 +++++++++ hm/soispha/conf/lf/commands/scripts/broot_jump | 16 --- hm/soispha/conf/lf/commands/scripts/broot_jump.sh | 16 +++ hm/soispha/conf/lf/commands/scripts/chmod | 13 --- hm/soispha/conf/lf/commands/scripts/chmod.sh | 13 +++ hm/soispha/conf/lf/commands/scripts/clear_trash | 8 -- hm/soispha/conf/lf/commands/scripts/clear_trash.sh | 8 ++ hm/soispha/conf/lf/commands/scripts/cow_cp | 96 ---------------- hm/soispha/conf/lf/commands/scripts/cow_cp.sh | 96 ++++++++++++++++ hm/soispha/conf/lf/commands/scripts/dl_file | 33 ------ hm/soispha/conf/lf/commands/scripts/dl_file.sh | 33 ++++++ hm/soispha/conf/lf/commands/scripts/dragon | 11 -- hm/soispha/conf/lf/commands/scripts/dragon.sh | 11 ++ .../conf/lf/commands/scripts/dragon_individual | 11 -- .../conf/lf/commands/scripts/dragon_individual.sh | 11 ++ hm/soispha/conf/lf/commands/scripts/dragon_stay | 11 -- hm/soispha/conf/lf/commands/scripts/dragon_stay.sh | 11 ++ hm/soispha/conf/lf/commands/scripts/fzf_jump | 16 --- hm/soispha/conf/lf/commands/scripts/fzf_jump.sh | 16 +++ .../conf/lf/commands/scripts/go_project_root | 13 --- .../conf/lf/commands/scripts/go_project_root.sh | 13 +++ hm/soispha/conf/lf/commands/scripts/mk_dir | 24 ---- hm/soispha/conf/lf/commands/scripts/mk_dir.sh | 24 ++++ hm/soispha/conf/lf/commands/scripts/mk_file | 24 ---- hm/soispha/conf/lf/commands/scripts/mk_file.sh | 24 ++++ .../conf/lf/commands/scripts/mk_file_and_edit | 25 ---- .../conf/lf/commands/scripts/mk_file_and_edit.sh | 25 ++++ hm/soispha/conf/lf/commands/scripts/mk_ln | 36 ------ hm/soispha/conf/lf/commands/scripts/mk_ln.sh | 36 ++++++ hm/soispha/conf/lf/commands/scripts/mk_scr_default | 31 ----- .../conf/lf/commands/scripts/mk_scr_default.sh | 31 +++++ hm/soispha/conf/lf/commands/scripts/mk_scr_temp | 32 ------ hm/soispha/conf/lf/commands/scripts/mk_scr_temp.sh | 32 ++++++ hm/soispha/conf/lf/commands/scripts/open | 11 -- hm/soispha/conf/lf/commands/scripts/open.sh | 11 ++ hm/soispha/conf/lf/commands/scripts/open_config | 7 -- hm/soispha/conf/lf/commands/scripts/open_config.sh | 7 ++ hm/soispha/conf/lf/commands/scripts/restore_trash | 7 -- .../conf/lf/commands/scripts/restore_trash.sh | 7 ++ hm/soispha/conf/lf/commands/scripts/set_wall_paper | 10 -- .../conf/lf/commands/scripts/set_wall_paper.sh | 10 ++ hm/soispha/conf/lf/commands/scripts/stripspace | 31 ----- hm/soispha/conf/lf/commands/scripts/stripspace.sh | 31 +++++ hm/soispha/conf/lf/commands/scripts/trash | 28 ----- hm/soispha/conf/lf/commands/scripts/trash.sh | 28 +++++ hm/soispha/conf/lf/commands/scripts/unarchive | 22 ---- hm/soispha/conf/lf/commands/scripts/unarchive.sh | 22 ++++ hm/soispha/conf/xdg/default.nix | 2 +- hm/soispha/conf/xdg/url_handler | 20 ---- hm/soispha/conf/xdg/url_handler.sh | 20 ++++ hm/soispha/conf/yambar/default.nix | 16 +-- hm/soispha/conf/yambar/scripts/disk | 22 ---- hm/soispha/conf/yambar/scripts/disk.sh | 22 ++++ hm/soispha/conf/yambar/scripts/grades-average | 15 --- hm/soispha/conf/yambar/scripts/grades-average.sh | 15 +++ hm/soispha/conf/yambar/scripts/mpd_song_name | 22 ---- hm/soispha/conf/yambar/scripts/mpd_song_name.sh | 22 ++++ hm/soispha/conf/yambar/scripts/network | 47 -------- hm/soispha/conf/yambar/scripts/network.sh | 47 ++++++++ hm/soispha/conf/yambar/scripts/old/amixer-monitor | 24 ---- .../conf/yambar/scripts/old/amixer-monitor.sh | 24 ++++ hm/soispha/conf/yambar/scripts/old/cpu | 126 --------------------- hm/soispha/conf/yambar/scripts/old/cpu.sh | 126 +++++++++++++++++++++ hm/soispha/conf/yambar/scripts/old/dfspace | 23 ---- hm/soispha/conf/yambar/scripts/old/dfspace.sh | 23 ++++ hm/soispha/conf/yambar/scripts/old/grades-average | 12 -- .../conf/yambar/scripts/old/grades-average.sh | 12 ++ hm/soispha/conf/yambar/scripts/old/meminfo | 37 ------ hm/soispha/conf/yambar/scripts/old/meminfo.sh | 37 ++++++ hm/soispha/conf/yambar/scripts/old/nmclitest | 23 ---- hm/soispha/conf/yambar/scripts/old/nmclitest.sh | 23 ++++ hm/soispha/conf/yambar/scripts/old/pingtest | 28 ----- hm/soispha/conf/yambar/scripts/old/pingtest.sh | 28 +++++ hm/soispha/conf/yambar/scripts/old/yambar-tray | 27 ----- .../conf/yambar/scripts/old/yambar-tray-width | 28 ----- .../conf/yambar/scripts/old/yambar-tray-width.sh | 28 +++++ hm/soispha/conf/yambar/scripts/old/yambar-tray.sh | 27 +++++ hm/soispha/conf/yambar/scripts/sound-volume | 20 ---- hm/soispha/conf/yambar/scripts/sound-volume.sh | 20 ++++ hm/soispha/conf/zsh/default.nix | 6 +- 90 files changed, 1137 insertions(+), 1138 deletions(-) delete mode 100755 hm/soispha/conf/firefox/scripts/update_extensions create mode 100755 hm/soispha/conf/firefox/scripts/update_extensions.sh delete mode 100755 hm/soispha/conf/git/scripts/commit create mode 100755 hm/soispha/conf/git/scripts/commit.sh delete mode 100755 hm/soispha/conf/gpg/agent-program create mode 100755 hm/soispha/conf/gpg/agent-program.sh delete mode 100755 hm/soispha/conf/lf/commands/scripts/archive create mode 100755 hm/soispha/conf/lf/commands/scripts/archive.sh delete mode 100755 hm/soispha/conf/lf/commands/scripts/broot_jump create mode 100755 hm/soispha/conf/lf/commands/scripts/broot_jump.sh delete mode 100755 hm/soispha/conf/lf/commands/scripts/chmod create mode 100755 hm/soispha/conf/lf/commands/scripts/chmod.sh delete mode 100755 hm/soispha/conf/lf/commands/scripts/clear_trash create mode 100755 hm/soispha/conf/lf/commands/scripts/clear_trash.sh delete mode 100755 hm/soispha/conf/lf/commands/scripts/cow_cp create mode 100755 hm/soispha/conf/lf/commands/scripts/cow_cp.sh delete mode 100755 hm/soispha/conf/lf/commands/scripts/dl_file create mode 100755 hm/soispha/conf/lf/commands/scripts/dl_file.sh delete mode 100755 hm/soispha/conf/lf/commands/scripts/dragon create mode 100755 hm/soispha/conf/lf/commands/scripts/dragon.sh delete mode 100755 hm/soispha/conf/lf/commands/scripts/dragon_individual create mode 100755 hm/soispha/conf/lf/commands/scripts/dragon_individual.sh delete mode 100755 hm/soispha/conf/lf/commands/scripts/dragon_stay create mode 100755 hm/soispha/conf/lf/commands/scripts/dragon_stay.sh delete mode 100755 hm/soispha/conf/lf/commands/scripts/fzf_jump create mode 100755 hm/soispha/conf/lf/commands/scripts/fzf_jump.sh delete mode 100755 hm/soispha/conf/lf/commands/scripts/go_project_root create mode 100755 hm/soispha/conf/lf/commands/scripts/go_project_root.sh delete mode 100755 hm/soispha/conf/lf/commands/scripts/mk_dir create mode 100755 hm/soispha/conf/lf/commands/scripts/mk_dir.sh delete mode 100755 hm/soispha/conf/lf/commands/scripts/mk_file create mode 100755 hm/soispha/conf/lf/commands/scripts/mk_file.sh delete mode 100755 hm/soispha/conf/lf/commands/scripts/mk_file_and_edit create mode 100755 hm/soispha/conf/lf/commands/scripts/mk_file_and_edit.sh delete mode 100755 hm/soispha/conf/lf/commands/scripts/mk_ln create mode 100755 hm/soispha/conf/lf/commands/scripts/mk_ln.sh delete mode 100755 hm/soispha/conf/lf/commands/scripts/mk_scr_default create mode 100755 hm/soispha/conf/lf/commands/scripts/mk_scr_default.sh delete mode 100755 hm/soispha/conf/lf/commands/scripts/mk_scr_temp create mode 100755 hm/soispha/conf/lf/commands/scripts/mk_scr_temp.sh delete mode 100755 hm/soispha/conf/lf/commands/scripts/open create mode 100755 hm/soispha/conf/lf/commands/scripts/open.sh delete mode 100755 hm/soispha/conf/lf/commands/scripts/open_config create mode 100755 hm/soispha/conf/lf/commands/scripts/open_config.sh delete mode 100755 hm/soispha/conf/lf/commands/scripts/restore_trash create mode 100755 hm/soispha/conf/lf/commands/scripts/restore_trash.sh delete mode 100755 hm/soispha/conf/lf/commands/scripts/set_wall_paper create mode 100755 hm/soispha/conf/lf/commands/scripts/set_wall_paper.sh delete mode 100755 hm/soispha/conf/lf/commands/scripts/stripspace create mode 100755 hm/soispha/conf/lf/commands/scripts/stripspace.sh delete mode 100755 hm/soispha/conf/lf/commands/scripts/trash create mode 100755 hm/soispha/conf/lf/commands/scripts/trash.sh delete mode 100755 hm/soispha/conf/lf/commands/scripts/unarchive create mode 100755 hm/soispha/conf/lf/commands/scripts/unarchive.sh delete mode 100755 hm/soispha/conf/xdg/url_handler create mode 100755 hm/soispha/conf/xdg/url_handler.sh delete mode 100755 hm/soispha/conf/yambar/scripts/disk create mode 100755 hm/soispha/conf/yambar/scripts/disk.sh delete mode 100755 hm/soispha/conf/yambar/scripts/grades-average create mode 100755 hm/soispha/conf/yambar/scripts/grades-average.sh delete mode 100755 hm/soispha/conf/yambar/scripts/mpd_song_name create mode 100755 hm/soispha/conf/yambar/scripts/mpd_song_name.sh delete mode 100755 hm/soispha/conf/yambar/scripts/network create mode 100755 hm/soispha/conf/yambar/scripts/network.sh delete mode 100755 hm/soispha/conf/yambar/scripts/old/amixer-monitor create mode 100755 hm/soispha/conf/yambar/scripts/old/amixer-monitor.sh delete mode 100755 hm/soispha/conf/yambar/scripts/old/cpu create mode 100755 hm/soispha/conf/yambar/scripts/old/cpu.sh delete mode 100755 hm/soispha/conf/yambar/scripts/old/dfspace create mode 100755 hm/soispha/conf/yambar/scripts/old/dfspace.sh delete mode 100755 hm/soispha/conf/yambar/scripts/old/grades-average create mode 100755 hm/soispha/conf/yambar/scripts/old/grades-average.sh delete mode 100755 hm/soispha/conf/yambar/scripts/old/meminfo create mode 100755 hm/soispha/conf/yambar/scripts/old/meminfo.sh delete mode 100755 hm/soispha/conf/yambar/scripts/old/nmclitest create mode 100755 hm/soispha/conf/yambar/scripts/old/nmclitest.sh delete mode 100755 hm/soispha/conf/yambar/scripts/old/pingtest create mode 100755 hm/soispha/conf/yambar/scripts/old/pingtest.sh delete mode 100755 hm/soispha/conf/yambar/scripts/old/yambar-tray delete mode 100755 hm/soispha/conf/yambar/scripts/old/yambar-tray-width create mode 100755 hm/soispha/conf/yambar/scripts/old/yambar-tray-width.sh create mode 100755 hm/soispha/conf/yambar/scripts/old/yambar-tray.sh delete mode 100755 hm/soispha/conf/yambar/scripts/sound-volume create mode 100755 hm/soispha/conf/yambar/scripts/sound-volume.sh (limited to 'hm/soispha/conf') diff --git a/hm/soispha/conf/firefox/scripts/update_extensions b/hm/soispha/conf/firefox/scripts/update_extensions deleted file mode 100755 index f8ed3a9a..00000000 --- a/hm/soispha/conf/firefox/scripts/update_extensions +++ /dev/null @@ -1,22 +0,0 @@ -#!/bin/sh - - -tmp=$(mktemp) -cat << EOF > "$tmp" - darkreader:navbar - keepassxc-browser:navbar - vhack-libredirect:navbar - torproject-snowflake:navbar - tridactyl-vim:menupanel - ublock-origin:menupanel - video-pause:menupanel -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 - - - -rm "$tmp"; diff --git a/hm/soispha/conf/firefox/scripts/update_extensions.sh b/hm/soispha/conf/firefox/scripts/update_extensions.sh new file mode 100755 index 00000000..f8ed3a9a --- /dev/null +++ b/hm/soispha/conf/firefox/scripts/update_extensions.sh @@ -0,0 +1,22 @@ +#!/bin/sh + + +tmp=$(mktemp) +cat << EOF > "$tmp" + darkreader:navbar + keepassxc-browser:navbar + vhack-libredirect:navbar + torproject-snowflake:navbar + tridactyl-vim:menupanel + ublock-origin:menupanel + video-pause:menupanel +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 + + + +rm "$tmp"; diff --git a/hm/soispha/conf/git/default.nix b/hm/soispha/conf/git/default.nix index 098f38f5..d7b78fec 100644 --- a/hm/soispha/conf/git/default.nix +++ b/hm/soispha/conf/git/default.nix @@ -10,7 +10,7 @@ gitTemplateFile = ./git_template.git; commit = sysLib.writeShellScript { name = "commit"; - src = ./scripts/commit; + src = ./scripts/commit.sh; keepPath = true; dependencies = with pkgs; [ git diff --git a/hm/soispha/conf/git/scripts/commit b/hm/soispha/conf/git/scripts/commit deleted file mode 100755 index 9baf93bb..00000000 --- a/hm/soispha/conf/git/scripts/commit +++ /dev/null @@ -1,19 +0,0 @@ -#!/usr/bin/env dash - -# shellcheck source=/dev/null -SHELL_LIBRARY_VERSION="2.0.13" . %SHELL_LIBRARY_PATH - -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" -else - printf "\n" > "$ROOT/.git/COMMIT_TEMPLATE" -fi -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/git/scripts/commit.sh b/hm/soispha/conf/git/scripts/commit.sh new file mode 100755 index 00000000..9baf93bb --- /dev/null +++ b/hm/soispha/conf/git/scripts/commit.sh @@ -0,0 +1,19 @@ +#!/usr/bin/env dash + +# shellcheck source=/dev/null +SHELL_LIBRARY_VERSION="2.0.13" . %SHELL_LIBRARY_PATH + +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" +else + printf "\n" > "$ROOT/.git/COMMIT_TEMPLATE" +fi +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/gpg/agent-program b/hm/soispha/conf/gpg/agent-program deleted file mode 100755 index e6917db0..00000000 --- a/hm/soispha/conf/gpg/agent-program +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/sh -onlykey-gpg-agent -v --skey-slot=ECC32 --dkey-slot=ECC32 "$@" diff --git a/hm/soispha/conf/gpg/agent-program.sh b/hm/soispha/conf/gpg/agent-program.sh new file mode 100755 index 00000000..e6917db0 --- /dev/null +++ b/hm/soispha/conf/gpg/agent-program.sh @@ -0,0 +1,2 @@ +#!/bin/sh +onlykey-gpg-agent -v --skey-slot=ECC32 --dkey-slot=ECC32 "$@" diff --git a/hm/soispha/conf/gpg/default.nix b/hm/soispha/conf/gpg/default.nix index ab1440c5..d0cc33a2 100644 --- a/hm/soispha/conf/gpg/default.nix +++ b/hm/soispha/conf/gpg/default.nix @@ -7,7 +7,7 @@ }: let agent-program = sysLib.writeShellScript { name = "onlykey-gpg-agent"; - src = ./agent-program; + src = ./agent-program.sh; dependencies = with pkgs; [ python3 onlykey-agent diff --git a/hm/soispha/conf/lf/commands/default.nix b/hm/soispha/conf/lf/commands/default.nix index 14a160c6..1cb6996a 100644 --- a/hm/soispha/conf/lf/commands/default.nix +++ b/hm/soispha/conf/lf/commands/default.nix @@ -3,67 +3,66 @@ sysLib, shell_library, system, - lf_rename, ... }: let functionCall = { - file, + name, dependencies, replacementStrings, ... }: sysLib.writeShellScript { - name = "${builtins.baseNameOf file}"; - src = file; + inherit name; + src = ./scripts/${name}.sh; keepPath = true; dependencies = dependencies ++ (builtins.attrValues {inherit (pkgs) dash coreutils;}); inherit replacementStrings; } - + "/bin/${builtins.baseNameOf file}"; + + "/bin/${name}.sh"; shell = { - file, + name, dependencies, replacementStrings ? null, ... }: '' ''${{ - ${functionCall {inherit file dependencies replacementStrings;}} + ${functionCall {inherit name dependencies replacementStrings;}} }} ''; # closes the lf tui pipe = { - file, + name, dependencies, replacementStrings ? null, ... }: '' %{{ - ${functionCall {inherit file dependencies replacementStrings;}} + ${functionCall {inherit name dependencies replacementStrings;}} }} ''; # runs the command in the ui/term bar async = { - file, + name, dependencies, replacementStrings ? null, ... }: '' &{{ - ${functionCall {inherit file dependencies replacementStrings;}} + ${functionCall {inherit name dependencies replacementStrings;}} }} ''; # runs the command in the background wait = { - file, + name, dependencies, replacementStrings ? null, ... }: '' !{{ - ${functionCall {inherit file dependencies replacementStrings;}} + ${functionCall {inherit name dependencies replacementStrings;}} }} ''; # adds a prompt after the command has run in { archive = shell { - file = ./scripts/archive; + name = "archive"; dependencies = builtins.attrValues { inherit (pkgs) @@ -76,17 +75,17 @@ in { }; }; broot_jump = shell { - file = ./scripts/broot_jump; + name = "broot_jump"; dependencies = builtins.attrValues { inherit (pkgs) broot; }; }; chmod = pipe { - file = ./scripts/chmod; + name = "chmod"; dependencies = []; }; clear_trash = shell { - file = ./scripts/clear_trash; + name = "clear_trash"; dependencies = builtins.attrValues { inherit (pkgs) @@ -96,7 +95,7 @@ in { }; }; dl_file = pipe { - file = ./scripts/dl_file; + name = "dl_file"; dependencies = builtins.attrValues { inherit (pkgs) @@ -106,7 +105,7 @@ in { }; }; dragon = pipe { - file = ./scripts/dragon; + name = "dragon"; dependencies = builtins.attrValues { inherit (pkgs) @@ -115,7 +114,7 @@ in { }; }; dragon_individual = pipe { - file = ./scripts/dragon_individual; + name = "dragon_individual"; dependencies = builtins.attrValues { inherit (pkgs) @@ -124,7 +123,7 @@ in { }; }; dragon_stay = pipe { - file = ./scripts/dragon_stay; + name = "dragon_stay"; dependencies = builtins.attrValues { inherit (pkgs) @@ -133,36 +132,36 @@ in { }; }; fzf_jump = shell { - file = ./scripts/fzf_jump; + name = "fzf_jump"; dependencies = builtins.attrValues { inherit (pkgs) fzf lf gnused; }; }; mk_dir = pipe { - file = ./scripts/mk_dir; + name = "mk_dir"; dependencies = []; }; mk_file = shell { - file = ./scripts/mk_file; + name = "mk_file"; dependencies = []; }; mk_file_and_edit = shell { - file = ./scripts/mk_file_and_edit; + name = "mk_file_and_edit"; dependencies = []; }; mk_ln = pipe { - file = ./scripts/mk_ln; + name = "mk_ln"; dependencies = []; }; mk_scr_default = shell { - file = ./scripts/mk_scr_default; + name = "mk_scr_default"; dependencies = builtins.attrValues {}; replacementStrings = { SHELL_LIBRARY_TEMPLATE = "${shell_library.rawTemplate."${system}"}"; }; }; mk_scr_temp = shell { - file = ./scripts/mk_scr_temp; + name = "mk_scr_temp"; dependencies = builtins.attrValues {}; replacementStrings = { SHELL_LIBRARY_TEMPLATE = "${shell_library.rawTemplate."${system}"}"; @@ -170,15 +169,15 @@ in { }; }; open = shell { - file = ./scripts/open; + name = "open"; dependencies = builtins.attrValues {inherit (pkgs) file xdg-utils;}; }; go_project_base_directory = async { - file = ./scripts/go_project_root; + name = "go_project_root"; dependencies = []; }; open_config = shell { - file = ./scripts/open_config; + name = "open_config"; dependencies = builtins.attrValues { #inherit #(pkgs) @@ -189,7 +188,7 @@ in { }; }; restore_trash = shell { - file = ./scripts/restore_trash; + name = "restore_trash"; dependencies = builtins.attrValues { inherit (pkgs) @@ -199,7 +198,7 @@ in { }; }; set_wall_paper = pipe { - file = ./scripts/set_wall_paper; + name = "set_wall_paper"; dependencies = []; }; /* @@ -212,11 +211,11 @@ in { ''; */ stripspace = pipe { - file = ./scripts/stripspace; + name = "stripspace"; dependencies = []; }; trash = pipe { - file = ./scripts/trash; + name = "trash"; dependencies = builtins.attrValues { inherit (pkgs) @@ -227,14 +226,14 @@ in { }; }; unarchive = pipe { - file = ./scripts/unarchive; + name = "unarchive"; dependencies = builtins.attrValues { inherit (pkgs) gnutar unzip # TODO: this is unfree! unrar - + p7zip ; }; diff --git a/hm/soispha/conf/lf/commands/scripts/archive b/hm/soispha/conf/lf/commands/scripts/archive deleted file mode 100755 index 5f4e3792..00000000 --- a/hm/soispha/conf/lf/commands/scripts/archive +++ /dev/null @@ -1,54 +0,0 @@ -#! /usr/bin/env dash - -# shellcheck source=/dev/null -SHELL_LIBRARY_VERSION="2.0.13" . %SHELL_LIBRARY_PATH - -# Option '-f' disables pathname expansion which can be useful when $f, $fs, and -# $fx variables contain names with '*' or '?' characters. However, this option -# is used selectively within individual commands as it can be limiting at -# times. -set -f - -archivers="$(tmp echo gzip xz 7z zip)"; - -prompt "Archive name: " -name="" -while [ -z "$name" ] || [ -e "$name" ] -do - read -r name - if [ -e "$name" ]; then - prompt "Archive already exists, overwrite [y|N]: " - read -r ans - - if [ "$ans" = "y" ]; then - break - else - prompt "Archive name: " - fi - fi -done - -root="$(if [ "$(pwd)" = "/" ]; then pwd; else echo "$(pwd)/";fi)"; - -# fx contains all selected file name separated by a newline -while read -r raw_file; do - file="$(echo "$raw_file" | sed "s|$root||")"; - set -- "$@" "$file"; -done < "$(tmp echo "$fx")"; - -case "$(awk '{for (i=1; i<=NF; i++) print $i}' "$archivers" | fzf)" in - "gzip") - tar -czf "$name".tar.gz "$@" - ;; - "xz") - tar -cf "$name".tar "$@" - xz -z -9 -e -T0 "$name".tar - ;; - "7z") - 7z a "$name".7z "$@" - ;; - "zip") - zip --symlinks -r "$name".zip "$@" - ;; -esac -# vim: ft=sh diff --git a/hm/soispha/conf/lf/commands/scripts/archive.sh b/hm/soispha/conf/lf/commands/scripts/archive.sh new file mode 100755 index 00000000..5f4e3792 --- /dev/null +++ b/hm/soispha/conf/lf/commands/scripts/archive.sh @@ -0,0 +1,54 @@ +#! /usr/bin/env dash + +# shellcheck source=/dev/null +SHELL_LIBRARY_VERSION="2.0.13" . %SHELL_LIBRARY_PATH + +# Option '-f' disables pathname expansion which can be useful when $f, $fs, and +# $fx variables contain names with '*' or '?' characters. However, this option +# is used selectively within individual commands as it can be limiting at +# times. +set -f + +archivers="$(tmp echo gzip xz 7z zip)"; + +prompt "Archive name: " +name="" +while [ -z "$name" ] || [ -e "$name" ] +do + read -r name + if [ -e "$name" ]; then + prompt "Archive already exists, overwrite [y|N]: " + read -r ans + + if [ "$ans" = "y" ]; then + break + else + prompt "Archive name: " + fi + fi +done + +root="$(if [ "$(pwd)" = "/" ]; then pwd; else echo "$(pwd)/";fi)"; + +# fx contains all selected file name separated by a newline +while read -r raw_file; do + file="$(echo "$raw_file" | sed "s|$root||")"; + set -- "$@" "$file"; +done < "$(tmp echo "$fx")"; + +case "$(awk '{for (i=1; i<=NF; i++) print $i}' "$archivers" | fzf)" in + "gzip") + tar -czf "$name".tar.gz "$@" + ;; + "xz") + tar -cf "$name".tar "$@" + xz -z -9 -e -T0 "$name".tar + ;; + "7z") + 7z a "$name".7z "$@" + ;; + "zip") + zip --symlinks -r "$name".zip "$@" + ;; +esac +# vim: ft=sh diff --git a/hm/soispha/conf/lf/commands/scripts/broot_jump b/hm/soispha/conf/lf/commands/scripts/broot_jump deleted file mode 100755 index 0feb5daf..00000000 --- a/hm/soispha/conf/lf/commands/scripts/broot_jump +++ /dev/null @@ -1,16 +0,0 @@ -#! /usr/bin/env dash - -# shellcheck source=/dev/null -SHELL_LIBRARY_VERSION="2.0.13" . %SHELL_LIBRARY_PATH - -tmp=$(mktmp) -res="$(broot --outcmd "$tmp" && sed 's/cd //' "$tmp")" - -if [ -f "$res" ]; then - cmd="select" -elif [ -d "$res" ]; then - cmd="cd" -fi - -lf -remote "send '$id' '$cmd' '$res'" -# vim: ft=sh diff --git a/hm/soispha/conf/lf/commands/scripts/broot_jump.sh b/hm/soispha/conf/lf/commands/scripts/broot_jump.sh new file mode 100755 index 00000000..0feb5daf --- /dev/null +++ b/hm/soispha/conf/lf/commands/scripts/broot_jump.sh @@ -0,0 +1,16 @@ +#! /usr/bin/env dash + +# shellcheck source=/dev/null +SHELL_LIBRARY_VERSION="2.0.13" . %SHELL_LIBRARY_PATH + +tmp=$(mktmp) +res="$(broot --outcmd "$tmp" && sed 's/cd //' "$tmp")" + +if [ -f "$res" ]; then + cmd="select" +elif [ -d "$res" ]; then + cmd="cd" +fi + +lf -remote "send '$id' '$cmd' '$res'" +# vim: ft=sh diff --git a/hm/soispha/conf/lf/commands/scripts/chmod b/hm/soispha/conf/lf/commands/scripts/chmod deleted file mode 100755 index f2cc0dc8..00000000 --- a/hm/soispha/conf/lf/commands/scripts/chmod +++ /dev/null @@ -1,13 +0,0 @@ -#! /usr/bin/env dash - -# shellcheck source=/dev/null -SHELL_LIBRARY_VERSION="2.0.13" . %SHELL_LIBRARY_PATH - -readp "Mode bits: " bits - -while read -r file; do - chmod "$bits" "$file" -done < "$(tmp echo "$fx")" - -lf -remote 'send reload' -# vim: ft=sh diff --git a/hm/soispha/conf/lf/commands/scripts/chmod.sh b/hm/soispha/conf/lf/commands/scripts/chmod.sh new file mode 100755 index 00000000..f2cc0dc8 --- /dev/null +++ b/hm/soispha/conf/lf/commands/scripts/chmod.sh @@ -0,0 +1,13 @@ +#! /usr/bin/env dash + +# shellcheck source=/dev/null +SHELL_LIBRARY_VERSION="2.0.13" . %SHELL_LIBRARY_PATH + +readp "Mode bits: " bits + +while read -r file; do + chmod "$bits" "$file" +done < "$(tmp echo "$fx")" + +lf -remote 'send reload' +# vim: ft=sh diff --git a/hm/soispha/conf/lf/commands/scripts/clear_trash b/hm/soispha/conf/lf/commands/scripts/clear_trash deleted file mode 100755 index f2ec5c5e..00000000 --- a/hm/soispha/conf/lf/commands/scripts/clear_trash +++ /dev/null @@ -1,8 +0,0 @@ -#! /usr/bin/env dash - -# shellcheck source=/dev/null -SHELL_LIBRARY_VERSION="2.0.13" . %SHELL_LIBRARY_PATH - -# could also use --force, for instand removal -trash list | fzf --multi | awk '{print $NF}' | xargs trash empty --match=exact -# vim: ft=sh diff --git a/hm/soispha/conf/lf/commands/scripts/clear_trash.sh b/hm/soispha/conf/lf/commands/scripts/clear_trash.sh new file mode 100755 index 00000000..f2ec5c5e --- /dev/null +++ b/hm/soispha/conf/lf/commands/scripts/clear_trash.sh @@ -0,0 +1,8 @@ +#! /usr/bin/env dash + +# shellcheck source=/dev/null +SHELL_LIBRARY_VERSION="2.0.13" . %SHELL_LIBRARY_PATH + +# could also use --force, for instand removal +trash list | fzf --multi | awk '{print $NF}' | xargs trash empty --match=exact +# vim: ft=sh diff --git a/hm/soispha/conf/lf/commands/scripts/cow_cp b/hm/soispha/conf/lf/commands/scripts/cow_cp deleted file mode 100755 index 85fd3431..00000000 --- a/hm/soispha/conf/lf/commands/scripts/cow_cp +++ /dev/null @@ -1,96 +0,0 @@ -#!/usr/bin/env dash - -# shellcheck source=/dev/null -SHELL_LIBRARY_VERSION="2.0.13" . %SHELL_LIBRARY_PATH - -# 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 -# backtrack <2023-08-29> - -# # This was very helpful for debugging: -# log_file="$HOME/lf-reflink-log-$(date +'%Y-%m-%d_%H-%M-%S')" -# [ -f "$log_file" ] || touch "$log_file" -# exec 1>> $log_file 2>&1 -# set -x - -# In theory, this may fail, -# but I tested it on selection with 10k files - everything worked (bash) -# FIXME: This will very likely fail on dash, when the file number > 255 <2023-08-29> -set -- "$(cat ~/.local/share/lf/files)" - -mode="$1" -shift - -if [ "$mode" = 'copy' ]; then - # Reflink if all items of selection and the destination are on the - # same mount point and it is CoW fs. - # (to make sure reflink never fails in first place, so we don't have to - # clean up) - - 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 )) && \ - [[ "$(df --output=fstype -- "$PWD" | tail -n 1)" =~ ^(btrfs|xfs|zfs)$ ]]; then - - echo 'selected copy and cp reflink paste' - - start=$(date '+%s') - - # Handle same names in dst - # TODO parallelism, idk - but exit/return/break won't stop the loop from subshell... - for i in "$@"; do - name="${i##*/}" - original="$name" - - count=0 - while [ -w "$PWD/$name" ]; do - count=$((count+1)) - name="$original.~$count~" - done - - set +e - cp_out="$(cp -rn --reflink=always -- "$i" "$PWD/$name" 2>&1)" - set -e - - if [ ! -z "$cp_out" ]; then - lf -remote "send $id echoerr $cp_out" - exit 0 - fi - done - - finish=$(( $(date '+%s') - $start )) - t='' - if (( $finish > 2 )); then - t="${finish}s" - fi - - # Or just skip a file when names are the same. - # (A LOT faster if you e.g. pasting selection of 10k files) - # cp -rn --reflink=always -- "$@" . - - lf -remote "send clear" - - green=$'\u001b[32m' - reset=$'\u001b[0m' - lf -remote "send $id echo ${green}reflinked!${reset} $t" - else - 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 - -# # for debug -# set +x - -lf -remote "send load" - -# 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 new file mode 100755 index 00000000..85fd3431 --- /dev/null +++ b/hm/soispha/conf/lf/commands/scripts/cow_cp.sh @@ -0,0 +1,96 @@ +#!/usr/bin/env dash + +# shellcheck source=/dev/null +SHELL_LIBRARY_VERSION="2.0.13" . %SHELL_LIBRARY_PATH + +# 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 +# backtrack <2023-08-29> + +# # This was very helpful for debugging: +# log_file="$HOME/lf-reflink-log-$(date +'%Y-%m-%d_%H-%M-%S')" +# [ -f "$log_file" ] || touch "$log_file" +# exec 1>> $log_file 2>&1 +# set -x + +# In theory, this may fail, +# but I tested it on selection with 10k files - everything worked (bash) +# FIXME: This will very likely fail on dash, when the file number > 255 <2023-08-29> +set -- "$(cat ~/.local/share/lf/files)" + +mode="$1" +shift + +if [ "$mode" = 'copy' ]; then + # Reflink if all items of selection and the destination are on the + # same mount point and it is CoW fs. + # (to make sure reflink never fails in first place, so we don't have to + # clean up) + + 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 )) && \ + [[ "$(df --output=fstype -- "$PWD" | tail -n 1)" =~ ^(btrfs|xfs|zfs)$ ]]; then + + echo 'selected copy and cp reflink paste' + + start=$(date '+%s') + + # Handle same names in dst + # TODO parallelism, idk - but exit/return/break won't stop the loop from subshell... + for i in "$@"; do + name="${i##*/}" + original="$name" + + count=0 + while [ -w "$PWD/$name" ]; do + count=$((count+1)) + name="$original.~$count~" + done + + set +e + cp_out="$(cp -rn --reflink=always -- "$i" "$PWD/$name" 2>&1)" + set -e + + if [ ! -z "$cp_out" ]; then + lf -remote "send $id echoerr $cp_out" + exit 0 + fi + done + + finish=$(( $(date '+%s') - $start )) + t='' + if (( $finish > 2 )); then + t="${finish}s" + fi + + # Or just skip a file when names are the same. + # (A LOT faster if you e.g. pasting selection of 10k files) + # cp -rn --reflink=always -- "$@" . + + lf -remote "send clear" + + green=$'\u001b[32m' + reset=$'\u001b[0m' + lf -remote "send $id echo ${green}reflinked!${reset} $t" + else + 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 + +# # for debug +# set +x + +lf -remote "send load" + +# vim: ft=sh diff --git a/hm/soispha/conf/lf/commands/scripts/dl_file b/hm/soispha/conf/lf/commands/scripts/dl_file deleted file mode 100755 index 5092174f..00000000 --- a/hm/soispha/conf/lf/commands/scripts/dl_file +++ /dev/null @@ -1,33 +0,0 @@ -#! /usr/bin/env dash - -# shellcheck source=/dev/null -SHELL_LIBRARY_VERSION="2.0.13" . %SHELL_LIBRARY_PATH - -# Provides the ability to download a file by dropping it into a window - -url="$(dragon -t -x)" - -if [ -n "$url" ]; then - prompt "File Name: " - name="" - while [ -z "$name" ] || [ -e "$name" ] - do - read -r name - if [ -e "$name" ]; then - prompt "File already exists, overwrite [y|N]: " - read -r ans - - if [ "$ans" = "y" ]; then - break - else - prompt "File Name: " - fi - fi - done - - # Download the file with curl - [ -n "$name" ] && curl -o "$name" "$url" || die "curl failed" -else - die "URL is null!" -fi -# vim: ft=sh diff --git a/hm/soispha/conf/lf/commands/scripts/dl_file.sh b/hm/soispha/conf/lf/commands/scripts/dl_file.sh new file mode 100755 index 00000000..5092174f --- /dev/null +++ b/hm/soispha/conf/lf/commands/scripts/dl_file.sh @@ -0,0 +1,33 @@ +#! /usr/bin/env dash + +# shellcheck source=/dev/null +SHELL_LIBRARY_VERSION="2.0.13" . %SHELL_LIBRARY_PATH + +# Provides the ability to download a file by dropping it into a window + +url="$(dragon -t -x)" + +if [ -n "$url" ]; then + prompt "File Name: " + name="" + while [ -z "$name" ] || [ -e "$name" ] + do + read -r name + if [ -e "$name" ]; then + prompt "File already exists, overwrite [y|N]: " + read -r ans + + if [ "$ans" = "y" ]; then + break + else + prompt "File Name: " + fi + fi + done + + # Download the file with curl + [ -n "$name" ] && curl -o "$name" "$url" || die "curl failed" +else + die "URL is null!" +fi +# vim: ft=sh diff --git a/hm/soispha/conf/lf/commands/scripts/dragon b/hm/soispha/conf/lf/commands/scripts/dragon deleted file mode 100755 index 59a50920..00000000 --- a/hm/soispha/conf/lf/commands/scripts/dragon +++ /dev/null @@ -1,11 +0,0 @@ -#! /usr/bin/env dash - -# shellcheck source=/dev/null -SHELL_LIBRARY_VERSION="2.0.13" . %SHELL_LIBRARY_PATH - -while read -r file; do - set -- "$@" "$file" -done < "$(tmp echo "$fx")" - -dragon -a -x "$@" -# vim: ft=sh diff --git a/hm/soispha/conf/lf/commands/scripts/dragon.sh b/hm/soispha/conf/lf/commands/scripts/dragon.sh new file mode 100755 index 00000000..59a50920 --- /dev/null +++ b/hm/soispha/conf/lf/commands/scripts/dragon.sh @@ -0,0 +1,11 @@ +#! /usr/bin/env dash + +# shellcheck source=/dev/null +SHELL_LIBRARY_VERSION="2.0.13" . %SHELL_LIBRARY_PATH + +while read -r file; do + set -- "$@" "$file" +done < "$(tmp echo "$fx")" + +dragon -a -x "$@" +# vim: ft=sh diff --git a/hm/soispha/conf/lf/commands/scripts/dragon_individual b/hm/soispha/conf/lf/commands/scripts/dragon_individual deleted file mode 100755 index 051537f9..00000000 --- a/hm/soispha/conf/lf/commands/scripts/dragon_individual +++ /dev/null @@ -1,11 +0,0 @@ -#! /usr/bin/env dash - -# shellcheck source=/dev/null -SHELL_LIBRARY_VERSION="2.0.13" . %SHELL_LIBRARY_PATH - -while read -r file; do - set -- "$@" "$file" -done < "$(tmp echo "$fx")" - -dragon "$@" -# 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 new file mode 100755 index 00000000..051537f9 --- /dev/null +++ b/hm/soispha/conf/lf/commands/scripts/dragon_individual.sh @@ -0,0 +1,11 @@ +#! /usr/bin/env dash + +# shellcheck source=/dev/null +SHELL_LIBRARY_VERSION="2.0.13" . %SHELL_LIBRARY_PATH + +while read -r file; do + set -- "$@" "$file" +done < "$(tmp echo "$fx")" + +dragon "$@" +# vim: ft=sh diff --git a/hm/soispha/conf/lf/commands/scripts/dragon_stay b/hm/soispha/conf/lf/commands/scripts/dragon_stay deleted file mode 100755 index 8f880848..00000000 --- a/hm/soispha/conf/lf/commands/scripts/dragon_stay +++ /dev/null @@ -1,11 +0,0 @@ -#! /usr/bin/env dash - -# shellcheck source=/dev/null -SHELL_LIBRARY_VERSION="2.0.13" . %SHELL_LIBRARY_PATH - -while read -r file; do - set -- "$@" "$file"; -done < "$(tmp echo "$fx")" - -dragon -a "$@" -# 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 new file mode 100755 index 00000000..8f880848 --- /dev/null +++ b/hm/soispha/conf/lf/commands/scripts/dragon_stay.sh @@ -0,0 +1,11 @@ +#! /usr/bin/env dash + +# shellcheck source=/dev/null +SHELL_LIBRARY_VERSION="2.0.13" . %SHELL_LIBRARY_PATH + +while read -r file; do + set -- "$@" "$file"; +done < "$(tmp echo "$fx")" + +dragon -a "$@" +# vim: ft=sh diff --git a/hm/soispha/conf/lf/commands/scripts/fzf_jump b/hm/soispha/conf/lf/commands/scripts/fzf_jump deleted file mode 100755 index 172c44d3..00000000 --- a/hm/soispha/conf/lf/commands/scripts/fzf_jump +++ /dev/null @@ -1,16 +0,0 @@ -#! /usr/bin/env dash - -# shellcheck source=/dev/null -SHELL_LIBRARY_VERSION="2.0.13" . %SHELL_LIBRARY_PATH - -res="$(fd . --maxdepth 3 | fzf --header='Jump to location')" - -if [ -f "$res" ]; then - cmd="select" -elif [ -d "$res" ]; then - cmd="cd" -fi - - -lf -remote "send $id $cmd \"$res\"" -# vim: ft=sh diff --git a/hm/soispha/conf/lf/commands/scripts/fzf_jump.sh b/hm/soispha/conf/lf/commands/scripts/fzf_jump.sh new file mode 100755 index 00000000..172c44d3 --- /dev/null +++ b/hm/soispha/conf/lf/commands/scripts/fzf_jump.sh @@ -0,0 +1,16 @@ +#! /usr/bin/env dash + +# shellcheck source=/dev/null +SHELL_LIBRARY_VERSION="2.0.13" . %SHELL_LIBRARY_PATH + +res="$(fd . --maxdepth 3 | fzf --header='Jump to location')" + +if [ -f "$res" ]; then + cmd="select" +elif [ -d "$res" ]; then + cmd="cd" +fi + + +lf -remote "send $id $cmd \"$res\"" +# vim: ft=sh diff --git a/hm/soispha/conf/lf/commands/scripts/go_project_root b/hm/soispha/conf/lf/commands/scripts/go_project_root deleted file mode 100755 index 9ed9f7ad..00000000 --- a/hm/soispha/conf/lf/commands/scripts/go_project_root +++ /dev/null @@ -1,13 +0,0 @@ -#!/usr/bin/env dash - -# shellcheck source=/dev/null -SHELL_LIBRARY_VERSION="2.0.13" . %SHELL_LIBRARY_PATH - -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"; -fi - -# 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 new file mode 100755 index 00000000..9ed9f7ad --- /dev/null +++ b/hm/soispha/conf/lf/commands/scripts/go_project_root.sh @@ -0,0 +1,13 @@ +#!/usr/bin/env dash + +# shellcheck source=/dev/null +SHELL_LIBRARY_VERSION="2.0.13" . %SHELL_LIBRARY_PATH + +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"; +fi + +# vim: ft=sh diff --git a/hm/soispha/conf/lf/commands/scripts/mk_dir b/hm/soispha/conf/lf/commands/scripts/mk_dir deleted file mode 100755 index adf60d99..00000000 --- a/hm/soispha/conf/lf/commands/scripts/mk_dir +++ /dev/null @@ -1,24 +0,0 @@ -#! /usr/bin/env dash - -# shellcheck source=/dev/null -SHELL_LIBRARY_VERSION="2.0.13" . %SHELL_LIBRARY_PATH - -prompt "Directory Name: " -name="" -while [ -z "$name" ] || [ -e "$name" ] -do - read -r name - if [ -e "$name" ]; then - prompt "Directory already exists, overwrite [y|N]: " - read -r ans - - if [ "$ans" = "y" ]; then - break - else - prompt "Directory Name: " - fi - fi -done - -mkdir "$name" -# vim: ft=sh diff --git a/hm/soispha/conf/lf/commands/scripts/mk_dir.sh b/hm/soispha/conf/lf/commands/scripts/mk_dir.sh new file mode 100755 index 00000000..adf60d99 --- /dev/null +++ b/hm/soispha/conf/lf/commands/scripts/mk_dir.sh @@ -0,0 +1,24 @@ +#! /usr/bin/env dash + +# shellcheck source=/dev/null +SHELL_LIBRARY_VERSION="2.0.13" . %SHELL_LIBRARY_PATH + +prompt "Directory Name: " +name="" +while [ -z "$name" ] || [ -e "$name" ] +do + read -r name + if [ -e "$name" ]; then + prompt "Directory already exists, overwrite [y|N]: " + read -r ans + + if [ "$ans" = "y" ]; then + break + else + prompt "Directory Name: " + fi + fi +done + +mkdir "$name" +# vim: ft=sh diff --git a/hm/soispha/conf/lf/commands/scripts/mk_file b/hm/soispha/conf/lf/commands/scripts/mk_file deleted file mode 100755 index cdef38a0..00000000 --- a/hm/soispha/conf/lf/commands/scripts/mk_file +++ /dev/null @@ -1,24 +0,0 @@ -#! /usr/bin/env dash - -# shellcheck source=/dev/null -SHELL_LIBRARY_VERSION="2.0.13" . %SHELL_LIBRARY_PATH - -prompt "File name: " -name="" -while [ -z "$name" ] || [ -e "$name" ] -do - read -r name - if [ -e "$name" ]; then - prompt "File already exists, overwrite [y|N]: " - read -r ans - - if [ "$ans" = "y" ]; then - break - else - prompt "File name: " - fi - fi -done - -touch "$name" -# vim: ft=sh diff --git a/hm/soispha/conf/lf/commands/scripts/mk_file.sh b/hm/soispha/conf/lf/commands/scripts/mk_file.sh new file mode 100755 index 00000000..cdef38a0 --- /dev/null +++ b/hm/soispha/conf/lf/commands/scripts/mk_file.sh @@ -0,0 +1,24 @@ +#! /usr/bin/env dash + +# shellcheck source=/dev/null +SHELL_LIBRARY_VERSION="2.0.13" . %SHELL_LIBRARY_PATH + +prompt "File name: " +name="" +while [ -z "$name" ] || [ -e "$name" ] +do + read -r name + if [ -e "$name" ]; then + prompt "File already exists, overwrite [y|N]: " + read -r ans + + if [ "$ans" = "y" ]; then + break + else + prompt "File name: " + fi + fi +done + +touch "$name" +# vim: ft=sh diff --git a/hm/soispha/conf/lf/commands/scripts/mk_file_and_edit b/hm/soispha/conf/lf/commands/scripts/mk_file_and_edit deleted file mode 100755 index 662b29ac..00000000 --- a/hm/soispha/conf/lf/commands/scripts/mk_file_and_edit +++ /dev/null @@ -1,25 +0,0 @@ -#! /usr/bin/env dash - -# shellcheck source=/dev/null -SHELL_LIBRARY_VERSION="2.0.13" . %SHELL_LIBRARY_PATH - -prompt "File name: " -name="" -while [ -z "$name" ] || [ -e "$name" ] -do - read -r name - if [ -e "$name" ]; then - prompt "File already exists, overwrite [y|N]: " - read -r ans - - if [ "$ans" = "y" ]; then - break - else - prompt "File name: " - fi - fi -done - -touch "$name" -"$EDITOR" "$name" -# vim: ft=sh diff --git a/hm/soispha/conf/lf/commands/scripts/mk_file_and_edit.sh b/hm/soispha/conf/lf/commands/scripts/mk_file_and_edit.sh new file mode 100755 index 00000000..662b29ac --- /dev/null +++ b/hm/soispha/conf/lf/commands/scripts/mk_file_and_edit.sh @@ -0,0 +1,25 @@ +#! /usr/bin/env dash + +# shellcheck source=/dev/null +SHELL_LIBRARY_VERSION="2.0.13" . %SHELL_LIBRARY_PATH + +prompt "File name: " +name="" +while [ -z "$name" ] || [ -e "$name" ] +do + read -r name + if [ -e "$name" ]; then + prompt "File already exists, overwrite [y|N]: " + read -r ans + + if [ "$ans" = "y" ]; then + break + else + prompt "File name: " + fi + fi +done + +touch "$name" +"$EDITOR" "$name" +# vim: ft=sh diff --git a/hm/soispha/conf/lf/commands/scripts/mk_ln b/hm/soispha/conf/lf/commands/scripts/mk_ln deleted file mode 100755 index f5dcd395..00000000 --- a/hm/soispha/conf/lf/commands/scripts/mk_ln +++ /dev/null @@ -1,36 +0,0 @@ -#! /usr/bin/env dash - -# shellcheck source=/dev/null -SHELL_LIBRARY_VERSION="2.0.13" . %SHELL_LIBRARY_PATH - -while IFS= read -r i;do - set -- "$@" "$i" -done < "$HOME"/.local/share/lf/files - -mode="$1" -shift - -if [ "$#" -eq 0 ]; then - msg "no files to link" - exit 0 -fi - -case "$mode" in - copy) - while [ "$#" -gt 0 ]; do - file="$1" - ans="$(basename "$file")" - - while [ -e "$ans" ];do - prompt "$ans already exists, new name for link: " - read -r ans - done - - ln -s "$file" "$(pwd)/$ans" - shift - done - ;; -esac -rm ~/.local/share/lf/files -# lf -remote "send clear" -# vim: ft=sh diff --git a/hm/soispha/conf/lf/commands/scripts/mk_ln.sh b/hm/soispha/conf/lf/commands/scripts/mk_ln.sh new file mode 100755 index 00000000..f5dcd395 --- /dev/null +++ b/hm/soispha/conf/lf/commands/scripts/mk_ln.sh @@ -0,0 +1,36 @@ +#! /usr/bin/env dash + +# shellcheck source=/dev/null +SHELL_LIBRARY_VERSION="2.0.13" . %SHELL_LIBRARY_PATH + +while IFS= read -r i;do + set -- "$@" "$i" +done < "$HOME"/.local/share/lf/files + +mode="$1" +shift + +if [ "$#" -eq 0 ]; then + msg "no files to link" + exit 0 +fi + +case "$mode" in + copy) + while [ "$#" -gt 0 ]; do + file="$1" + ans="$(basename "$file")" + + while [ -e "$ans" ];do + prompt "$ans already exists, new name for link: " + read -r ans + done + + ln -s "$file" "$(pwd)/$ans" + shift + done + ;; +esac +rm ~/.local/share/lf/files +# lf -remote "send clear" +# vim: ft=sh diff --git a/hm/soispha/conf/lf/commands/scripts/mk_scr_default b/hm/soispha/conf/lf/commands/scripts/mk_scr_default deleted file mode 100755 index 6e69fc4f..00000000 --- a/hm/soispha/conf/lf/commands/scripts/mk_scr_default +++ /dev/null @@ -1,31 +0,0 @@ -#! /usr/bin/env dash - -# shellcheck source=/dev/null -SHELL_LIBRARY_VERSION="2.0.13" . %SHELL_LIBRARY_PATH - - -prompt "Script name: " -name="" -while [ -z "$name" ] || [ -e "$name" ] -do - read -r name - if [ -e "$name" ]; then - prompt "Script already exists, overwrite [y|N]: " - read -r ans - - if [ "$ans" = "y" ]; then - break - else - prompt "Script Name: " - fi - fi -done - -script="$(pwd)"/"$name" - -cat "%SHELL_LIBRARY_TEMPLATE" > "$script" -chmod +x "$script" -"$VISUAL" "$script" - - -# vim: ft=sh diff --git a/hm/soispha/conf/lf/commands/scripts/mk_scr_default.sh b/hm/soispha/conf/lf/commands/scripts/mk_scr_default.sh new file mode 100755 index 00000000..6e69fc4f --- /dev/null +++ b/hm/soispha/conf/lf/commands/scripts/mk_scr_default.sh @@ -0,0 +1,31 @@ +#! /usr/bin/env dash + +# shellcheck source=/dev/null +SHELL_LIBRARY_VERSION="2.0.13" . %SHELL_LIBRARY_PATH + + +prompt "Script name: " +name="" +while [ -z "$name" ] || [ -e "$name" ] +do + read -r name + if [ -e "$name" ]; then + prompt "Script already exists, overwrite [y|N]: " + read -r ans + + if [ "$ans" = "y" ]; then + break + else + prompt "Script Name: " + fi + fi +done + +script="$(pwd)"/"$name" + +cat "%SHELL_LIBRARY_TEMPLATE" > "$script" +chmod +x "$script" +"$VISUAL" "$script" + + +# vim: ft=sh diff --git a/hm/soispha/conf/lf/commands/scripts/mk_scr_temp b/hm/soispha/conf/lf/commands/scripts/mk_scr_temp deleted file mode 100755 index 612ff19d..00000000 --- a/hm/soispha/conf/lf/commands/scripts/mk_scr_temp +++ /dev/null @@ -1,32 +0,0 @@ -#! /usr/bin/env dash - -# shellcheck source=/dev/null -SHELL_LIBRARY_VERSION="2.0.13" . %SHELL_LIBRARY_PATH - - -prompt "Script name: " -name="" -while [ -z "$name" ] || [ -e "$name" ] -do - read -r name - if [ -e "$name" ]; then - prompt "Script already exists, overwrite [y|N]: " - read -r ans - - if [ "$ans" = "y" ]; then - break - else - prompt "Script Name: " - fi - fi -done - -script="$(pwd)"/"$name" - -sed 's|%TO_BE_SHELL_LIBRARY_PATH|%SHELL_LIBRARY_PATH|' "%SHELL_LIBRARY_TEMPLATE" > "$script" -sed -i 's|dash|sh|' "$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 new file mode 100755 index 00000000..612ff19d --- /dev/null +++ b/hm/soispha/conf/lf/commands/scripts/mk_scr_temp.sh @@ -0,0 +1,32 @@ +#! /usr/bin/env dash + +# shellcheck source=/dev/null +SHELL_LIBRARY_VERSION="2.0.13" . %SHELL_LIBRARY_PATH + + +prompt "Script name: " +name="" +while [ -z "$name" ] || [ -e "$name" ] +do + read -r name + if [ -e "$name" ]; then + prompt "Script already exists, overwrite [y|N]: " + read -r ans + + if [ "$ans" = "y" ]; then + break + else + prompt "Script Name: " + fi + fi +done + +script="$(pwd)"/"$name" + +sed 's|%TO_BE_SHELL_LIBRARY_PATH|%SHELL_LIBRARY_PATH|' "%SHELL_LIBRARY_TEMPLATE" > "$script" +sed -i 's|dash|sh|' "$script" +chmod +x "$script" +"$VISUAL" "$script" + + +# vim: ft=sh diff --git a/hm/soispha/conf/lf/commands/scripts/open b/hm/soispha/conf/lf/commands/scripts/open deleted file mode 100755 index 3dd8f485..00000000 --- a/hm/soispha/conf/lf/commands/scripts/open +++ /dev/null @@ -1,11 +0,0 @@ -#! /usr/bin/env dash - -# shellcheck source=/dev/null -SHELL_LIBRARY_VERSION="2.0.13" . %SHELL_LIBRARY_PATH - -case $(file --mime-type "$f" -bL) in - text/*|application/json|application/vnd.hp-HPGL) "$EDITOR" "$f";; - image/*) "$IVIEWER" "$f";; - *) xdg-open "$f";; -esac -# vim: ft=sh diff --git a/hm/soispha/conf/lf/commands/scripts/open.sh b/hm/soispha/conf/lf/commands/scripts/open.sh new file mode 100755 index 00000000..3dd8f485 --- /dev/null +++ b/hm/soispha/conf/lf/commands/scripts/open.sh @@ -0,0 +1,11 @@ +#! /usr/bin/env dash + +# shellcheck source=/dev/null +SHELL_LIBRARY_VERSION="2.0.13" . %SHELL_LIBRARY_PATH + +case $(file --mime-type "$f" -bL) in + text/*|application/json|application/vnd.hp-HPGL) "$EDITOR" "$f";; + image/*) "$IVIEWER" "$f";; + *) xdg-open "$f";; +esac +# vim: ft=sh diff --git a/hm/soispha/conf/lf/commands/scripts/open_config b/hm/soispha/conf/lf/commands/scripts/open_config deleted file mode 100755 index 4054abdd..00000000 --- a/hm/soispha/conf/lf/commands/scripts/open_config +++ /dev/null @@ -1,7 +0,0 @@ -#! /usr/bin/env dash - -# shellcheck source=/dev/null -SHELL_LIBRARY_VERSION="2.0.13" . %SHELL_LIBRARY_PATH - -"$EDITOR" "$(bookmenu -b ~/.config/bookmenu/configs -f fzf -o)" # TODO: implement this -# 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 new file mode 100755 index 00000000..4054abdd --- /dev/null +++ b/hm/soispha/conf/lf/commands/scripts/open_config.sh @@ -0,0 +1,7 @@ +#! /usr/bin/env dash + +# shellcheck source=/dev/null +SHELL_LIBRARY_VERSION="2.0.13" . %SHELL_LIBRARY_PATH + +"$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 b/hm/soispha/conf/lf/commands/scripts/restore_trash deleted file mode 100755 index 94d26a26..00000000 --- a/hm/soispha/conf/lf/commands/scripts/restore_trash +++ /dev/null @@ -1,7 +0,0 @@ -#! /usr/bin/env dash - -# shellcheck source=/dev/null -SHELL_LIBRARY_VERSION="2.0.13" . %SHELL_LIBRARY_PATH - -trash list | fzf --multi | awk '{print $NF}' | xargs trash restore --match=exact -# 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 new file mode 100755 index 00000000..94d26a26 --- /dev/null +++ b/hm/soispha/conf/lf/commands/scripts/restore_trash.sh @@ -0,0 +1,7 @@ +#! /usr/bin/env dash + +# shellcheck source=/dev/null +SHELL_LIBRARY_VERSION="2.0.13" . %SHELL_LIBRARY_PATH + +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 b/hm/soispha/conf/lf/commands/scripts/set_wall_paper deleted file mode 100755 index f7714880..00000000 --- a/hm/soispha/conf/lf/commands/scripts/set_wall_paper +++ /dev/null @@ -1,10 +0,0 @@ -#! /usr/bin/env dash - -# shellcheck source=/dev/null -SHELL_LIBRARY_VERSION="2.0.13" . %SHELL_LIBRARY_PATH - -die "No yet implemented" # TODO: do what the 'die' says -#sed -i "s,export AWMWALLPAPER='.*',export AWMWALLPAPER='${f}'," ${ZDOTDIR}/.zshenv -#nohub swaybg -i "$f" -#feh --bg-max --no-fehbg "$f" -# vim: ft=sh diff --git a/hm/soispha/conf/lf/commands/scripts/set_wall_paper.sh b/hm/soispha/conf/lf/commands/scripts/set_wall_paper.sh new file mode 100755 index 00000000..f7714880 --- /dev/null +++ b/hm/soispha/conf/lf/commands/scripts/set_wall_paper.sh @@ -0,0 +1,10 @@ +#! /usr/bin/env dash + +# shellcheck source=/dev/null +SHELL_LIBRARY_VERSION="2.0.13" . %SHELL_LIBRARY_PATH + +die "No yet implemented" # TODO: do what the 'die' says +#sed -i "s,export AWMWALLPAPER='.*',export AWMWALLPAPER='${f}'," ${ZDOTDIR}/.zshenv +#nohub swaybg -i "$f" +#feh --bg-max --no-fehbg "$f" +# vim: ft=sh diff --git a/hm/soispha/conf/lf/commands/scripts/stripspace b/hm/soispha/conf/lf/commands/scripts/stripspace deleted file mode 100755 index c8781a60..00000000 --- a/hm/soispha/conf/lf/commands/scripts/stripspace +++ /dev/null @@ -1,31 +0,0 @@ -#! /usr/bin/env dash - -# shellcheck source=/dev/null -SHELL_LIBRARY_VERSION="2.0.13" . %SHELL_LIBRARY_PATH - -files=$(mktmp); -echo "$fx" > "$files"; - -awk_source=$(mktmp); -cat << OFT > "$awk_source" -BEGIN {FS=" "} -{for (i=1; i != NF + 1; i++) - if (i == NF) { - parts[i]=tolower(\$i); - } else { - parts[i]=tolower(\$i"_"); - } -} -END {for (i in parts) printf parts[i]} -OFT - -while read -r file; do - dirty_name=$(mktmp) - basename "$file" > "$dirty_name"; - clean_name=$(awk -f "$awk_source" "$dirty_name"); - - [ -e "$clean_name" ] && die "file \"$clean_name\" already exists!"; - mv "$(cat "$dirty_name")" "$clean_name" || die "Move failed"; - lf -remote 'send reload' -done < "$files"; -# vim: ft=sh diff --git a/hm/soispha/conf/lf/commands/scripts/stripspace.sh b/hm/soispha/conf/lf/commands/scripts/stripspace.sh new file mode 100755 index 00000000..c8781a60 --- /dev/null +++ b/hm/soispha/conf/lf/commands/scripts/stripspace.sh @@ -0,0 +1,31 @@ +#! /usr/bin/env dash + +# shellcheck source=/dev/null +SHELL_LIBRARY_VERSION="2.0.13" . %SHELL_LIBRARY_PATH + +files=$(mktmp); +echo "$fx" > "$files"; + +awk_source=$(mktmp); +cat << OFT > "$awk_source" +BEGIN {FS=" "} +{for (i=1; i != NF + 1; i++) + if (i == NF) { + parts[i]=tolower(\$i); + } else { + parts[i]=tolower(\$i"_"); + } +} +END {for (i in parts) printf parts[i]} +OFT + +while read -r file; do + dirty_name=$(mktmp) + basename "$file" > "$dirty_name"; + clean_name=$(awk -f "$awk_source" "$dirty_name"); + + [ -e "$clean_name" ] && die "file \"$clean_name\" already exists!"; + mv "$(cat "$dirty_name")" "$clean_name" || die "Move failed"; + lf -remote 'send reload' +done < "$files"; +# vim: ft=sh diff --git a/hm/soispha/conf/lf/commands/scripts/trash b/hm/soispha/conf/lf/commands/scripts/trash deleted file mode 100755 index 4da188e5..00000000 --- a/hm/soispha/conf/lf/commands/scripts/trash +++ /dev/null @@ -1,28 +0,0 @@ -#! /usr/bin/env dash - -# shellcheck source=/dev/null -SHELL_LIBRARY_VERSION="2.0.13" . %SHELL_LIBRARY_PATH - -trash_output=$(mktmp); -expected_error_output=$(mktmp); - -while read -r file; do - set -- "$@" "$file" -done < "$(tmp echo "$fx")" - -# TODO: why are we using trashy at all, when trash-cli can do everything? -# -# try trashy first, through nix because both trashy and trash-cli provide a trash command, which conflicts -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"; -error: Error during a \`trash\` operation: Unknown { description: "Path: '\"/.Trash-1000\"'. Message: Permission denied (os error 13)" } -EOF - -if [ "$(cat "$expected_error_output")" = "$(cat "$trash_output")" ];then - warning "Deleting with trash-cli to the /.Trash folder"; - # this file could not be trashed because it is on the tempfs volume, trash-cli can do this this - trash-put "$@"; -fi -# vim: ft=sh diff --git a/hm/soispha/conf/lf/commands/scripts/trash.sh b/hm/soispha/conf/lf/commands/scripts/trash.sh new file mode 100755 index 00000000..4da188e5 --- /dev/null +++ b/hm/soispha/conf/lf/commands/scripts/trash.sh @@ -0,0 +1,28 @@ +#! /usr/bin/env dash + +# shellcheck source=/dev/null +SHELL_LIBRARY_VERSION="2.0.13" . %SHELL_LIBRARY_PATH + +trash_output=$(mktmp); +expected_error_output=$(mktmp); + +while read -r file; do + set -- "$@" "$file" +done < "$(tmp echo "$fx")" + +# TODO: why are we using trashy at all, when trash-cli can do everything? +# +# try trashy first, through nix because both trashy and trash-cli provide a trash command, which conflicts +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"; +error: Error during a \`trash\` operation: Unknown { description: "Path: '\"/.Trash-1000\"'. Message: Permission denied (os error 13)" } +EOF + +if [ "$(cat "$expected_error_output")" = "$(cat "$trash_output")" ];then + warning "Deleting with trash-cli to the /.Trash folder"; + # this file could not be trashed because it is on the tempfs volume, trash-cli can do this this + trash-put "$@"; +fi +# vim: ft=sh diff --git a/hm/soispha/conf/lf/commands/scripts/unarchive b/hm/soispha/conf/lf/commands/scripts/unarchive deleted file mode 100755 index 1ecc702b..00000000 --- a/hm/soispha/conf/lf/commands/scripts/unarchive +++ /dev/null @@ -1,22 +0,0 @@ -#! /usr/bin/env dash - -# shellcheck source=/dev/null -SHELL_LIBRARY_VERSION="2.0.13" . %SHELL_LIBRARY_PATH - -# extract the current file with the right command -# (xkcd link: https://xkcd.com/1168/) -set -f -# TODO: add support for multiple files at once -case "$f" in - *.tar.bz|*.tar.bz2|*.tbz|*.tbz2) tar xjvf "$f";; - *.tar.gz|*.tgz) tar xzvf "$f";; - *.tar.xz|*.txz) tar xJvf "$f";; - *.zip) unzip "$f";; - *.rar) - die "rar is a unfree format!" - #unrar x $f - ;; - *.7z) 7z x "$f";; - *) die "Unsupported format" ;; -esac -# vim: ft=sh diff --git a/hm/soispha/conf/lf/commands/scripts/unarchive.sh b/hm/soispha/conf/lf/commands/scripts/unarchive.sh new file mode 100755 index 00000000..1ecc702b --- /dev/null +++ b/hm/soispha/conf/lf/commands/scripts/unarchive.sh @@ -0,0 +1,22 @@ +#! /usr/bin/env dash + +# shellcheck source=/dev/null +SHELL_LIBRARY_VERSION="2.0.13" . %SHELL_LIBRARY_PATH + +# extract the current file with the right command +# (xkcd link: https://xkcd.com/1168/) +set -f +# TODO: add support for multiple files at once +case "$f" in + *.tar.bz|*.tar.bz2|*.tbz|*.tbz2) tar xjvf "$f";; + *.tar.gz|*.tgz) tar xzvf "$f";; + *.tar.xz|*.txz) tar xJvf "$f";; + *.zip) unzip "$f";; + *.rar) + die "rar is a unfree format!" + #unrar x $f + ;; + *.7z) 7z x "$f";; + *) die "Unsupported format" ;; +esac +# vim: ft=sh diff --git a/hm/soispha/conf/xdg/default.nix b/hm/soispha/conf/xdg/default.nix index be85f330..8327ea6e 100644 --- a/hm/soispha/conf/xdg/default.nix +++ b/hm/soispha/conf/xdg/default.nix @@ -6,7 +6,7 @@ }: let url_handler = sysLib.writeShellScript { name = "url_handler"; - src = ./url_handler; + src = ./url_handler.sh; keepPath = true; # Naming dependencies for this will be difficult, as it depend on overridden packages. dependencies = with pkgs; [ diff --git a/hm/soispha/conf/xdg/url_handler b/hm/soispha/conf/xdg/url_handler deleted file mode 100755 index 9cca2fc0..00000000 --- a/hm/soispha/conf/xdg/url_handler +++ /dev/null @@ -1,20 +0,0 @@ -#!/usr/bin/env dash - -# shellcheck source=/dev/null -SHELL_LIBRARY_VERSION="2.0.13" . %SHELL_LIBRARY_PATH - - -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"; -else - notify-send "(URL HANDLER) No project selected" && exit 1 -fi - - -# vim: ft=sh diff --git a/hm/soispha/conf/xdg/url_handler.sh b/hm/soispha/conf/xdg/url_handler.sh new file mode 100755 index 00000000..9cca2fc0 --- /dev/null +++ b/hm/soispha/conf/xdg/url_handler.sh @@ -0,0 +1,20 @@ +#!/usr/bin/env dash + +# shellcheck source=/dev/null +SHELL_LIBRARY_VERSION="2.0.13" . %SHELL_LIBRARY_PATH + + +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"; +else + notify-send "(URL HANDLER) No project selected" && exit 1 +fi + + +# vim: ft=sh diff --git a/hm/soispha/conf/yambar/default.nix b/hm/soispha/conf/yambar/default.nix index abc0c85e..f732e1d8 100644 --- a/hm/soispha/conf/yambar/default.nix +++ b/hm/soispha/conf/yambar/default.nix @@ -8,16 +8,16 @@ ... }: let makeScript = { - file, + name, dependencies, ... }: sysLib.writeShellScript { - name = "${builtins.baseNameOf file}"; - src = file; + inherit name; + src = ./scripts/${name}.sh; dependencies = dependencies ++ (builtins.attrValues {inherit (pkgs) dash;}); } - + "/bin/${builtins.baseNameOf file}"; + + "/bin/${name}"; in { xdg.configFile."yambar/config.yml".source = pkgs.substituteAll { src = @@ -32,12 +32,12 @@ in { mpd_song_name_script = makeScript { dependencies = builtins.attrValues {inherit (pkgs) mpc-cli;}; - file = ./scripts/mpd_song_name; + name = "mpd_song_name"; }; volume_script = makeScript { dependencies = builtins.attrValues {inherit (pkgs) pulseaudio gawk coreutils;}; - file = ./scripts/sound-volume; + name = "sound-volume"; }; # grade_average_script = makeScript { @@ -46,7 +46,7 @@ in { # grades.outputs.packages.${system}.default # ] # ++ (builtins.attrValues {inherit (pkgs) coreutils gawk;}); - # file = ./scripts/grades-average; + # name = "grades-average"; # }; cpu_script = yambar_cpu.app.${system}.default.program; @@ -55,7 +55,7 @@ in { disk_script = makeScript { dependencies = builtins.attrValues {inherit (pkgs) gawk btrfs-progs coreutils;}; - file = ./scripts/disk; + name = "disk"; }; }; } diff --git a/hm/soispha/conf/yambar/scripts/disk b/hm/soispha/conf/yambar/scripts/disk deleted file mode 100755 index 003455ab..00000000 --- a/hm/soispha/conf/yambar/scripts/disk +++ /dev/null @@ -1,22 +0,0 @@ -#! /usr/bin/env dash - -# shellcheck source=/dev/null -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") - - - # 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 -done - -# vim: ft=sh diff --git a/hm/soispha/conf/yambar/scripts/disk.sh b/hm/soispha/conf/yambar/scripts/disk.sh new file mode 100755 index 00000000..003455ab --- /dev/null +++ b/hm/soispha/conf/yambar/scripts/disk.sh @@ -0,0 +1,22 @@ +#! /usr/bin/env dash + +# shellcheck source=/dev/null +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") + + + # 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 +done + +# vim: ft=sh diff --git a/hm/soispha/conf/yambar/scripts/grades-average b/hm/soispha/conf/yambar/scripts/grades-average deleted file mode 100755 index 8c1900cf..00000000 --- a/hm/soispha/conf/yambar/scripts/grades-average +++ /dev/null @@ -1,15 +0,0 @@ -#! /usr/bin/env dash - -# shellcheck source=/dev/null -SHELL_LIBRARY_VERSION="2.0.13" . %SHELL_LIBRARY_PATH - -while true; do - grade="$(grades list average | awk '{print $2}')"; - - echo "grade|string|$grade"; - 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 new file mode 100755 index 00000000..8c1900cf --- /dev/null +++ b/hm/soispha/conf/yambar/scripts/grades-average.sh @@ -0,0 +1,15 @@ +#! /usr/bin/env dash + +# shellcheck source=/dev/null +SHELL_LIBRARY_VERSION="2.0.13" . %SHELL_LIBRARY_PATH + +while true; do + grade="$(grades list average | awk '{print $2}')"; + + echo "grade|string|$grade"; + echo ""; + + sleep 1; +done + +# vim: ft=sh diff --git a/hm/soispha/conf/yambar/scripts/mpd_song_name b/hm/soispha/conf/yambar/scripts/mpd_song_name deleted file mode 100755 index b778afbc..00000000 --- a/hm/soispha/conf/yambar/scripts/mpd_song_name +++ /dev/null @@ -1,22 +0,0 @@ -#!/usr/bin/env dash - -# shellcheck source=/dev/null -SHELL_LIBRARY_VERSION="2.0.13" . %SHELL_LIBRARY_PATH - - -while true; do - state="$(mpc status '%state%')"; - - if [ "$state" = "playing" ]; then - song="$(mpc --format '[[%artist% - ]%title%]|[%file%]' current)"; - echo "playing|bool|true" - echo "song|string|$song" - else - echo "playing|bool|false" - fi - echo "" # commit - - sleep 2; -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 new file mode 100755 index 00000000..b778afbc --- /dev/null +++ b/hm/soispha/conf/yambar/scripts/mpd_song_name.sh @@ -0,0 +1,22 @@ +#!/usr/bin/env dash + +# shellcheck source=/dev/null +SHELL_LIBRARY_VERSION="2.0.13" . %SHELL_LIBRARY_PATH + + +while true; do + state="$(mpc status '%state%')"; + + if [ "$state" = "playing" ]; then + song="$(mpc --format '[[%artist% - ]%title%]|[%file%]' current)"; + echo "playing|bool|true" + echo "song|string|$song" + else + echo "playing|bool|false" + fi + echo "" # commit + + sleep 2; +done + +# vim: ft=sh diff --git a/hm/soispha/conf/yambar/scripts/network b/hm/soispha/conf/yambar/scripts/network deleted file mode 100755 index 717ea6be..00000000 --- a/hm/soispha/conf/yambar/scripts/network +++ /dev/null @@ -1,47 +0,0 @@ -#! /usr/bin/env dash - -# shellcheck source=/dev/null -SHELL_LIBRARY_VERSION="2.0.13" . %SHELL_LIBRARY_PATH - -retest=120 -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 - - while true; do - - 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 - ;; -esac - -# vim: ft=sh diff --git a/hm/soispha/conf/yambar/scripts/network.sh b/hm/soispha/conf/yambar/scripts/network.sh new file mode 100755 index 00000000..717ea6be --- /dev/null +++ b/hm/soispha/conf/yambar/scripts/network.sh @@ -0,0 +1,47 @@ +#! /usr/bin/env dash + +# shellcheck source=/dev/null +SHELL_LIBRARY_VERSION="2.0.13" . %SHELL_LIBRARY_PATH + +retest=120 +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 + + while true; do + + 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 + ;; +esac + +# vim: ft=sh diff --git a/hm/soispha/conf/yambar/scripts/old/amixer-monitor b/hm/soispha/conf/yambar/scripts/old/amixer-monitor deleted file mode 100755 index 9e75acfa..00000000 --- a/hm/soispha/conf/yambar/scripts/old/amixer-monitor +++ /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/amixer-monitor.sh b/hm/soispha/conf/yambar/scripts/old/amixer-monitor.sh new file mode 100755 index 00000000..9e75acfa --- /dev/null +++ b/hm/soispha/conf/yambar/scripts/old/amixer-monitor.sh @@ -0,0 +1,24 @@ +#!/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 b/hm/soispha/conf/yambar/scripts/old/cpu deleted file mode 100755 index bae820d0..00000000 --- a/hm/soispha/conf/yambar/scripts/old/cpu +++ /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/cpu.sh b/hm/soispha/conf/yambar/scripts/old/cpu.sh new file mode 100755 index 00000000..bae820d0 --- /dev/null +++ b/hm/soispha/conf/yambar/scripts/old/cpu.sh @@ -0,0 +1,126 @@ +#!/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 b/hm/soispha/conf/yambar/scripts/old/dfspace deleted file mode 100755 index 0b262481..00000000 --- a/hm/soispha/conf/yambar/scripts/old/dfspace +++ /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/dfspace.sh b/hm/soispha/conf/yambar/scripts/old/dfspace.sh new file mode 100755 index 00000000..0b262481 --- /dev/null +++ b/hm/soispha/conf/yambar/scripts/old/dfspace.sh @@ -0,0 +1,23 @@ +#!/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 b/hm/soispha/conf/yambar/scripts/old/grades-average deleted file mode 100755 index a04b958c..00000000 --- a/hm/soispha/conf/yambar/scripts/old/grades-average +++ /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/grades-average.sh b/hm/soispha/conf/yambar/scripts/old/grades-average.sh new file mode 100755 index 00000000..a04b958c --- /dev/null +++ b/hm/soispha/conf/yambar/scripts/old/grades-average.sh @@ -0,0 +1,12 @@ +#!/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 b/hm/soispha/conf/yambar/scripts/old/meminfo deleted file mode 100755 index 0156e94c..00000000 --- a/hm/soispha/conf/yambar/scripts/old/meminfo +++ /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/meminfo.sh b/hm/soispha/conf/yambar/scripts/old/meminfo.sh new file mode 100755 index 00000000..0156e94c --- /dev/null +++ b/hm/soispha/conf/yambar/scripts/old/meminfo.sh @@ -0,0 +1,37 @@ +#!/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 b/hm/soispha/conf/yambar/scripts/old/nmclitest deleted file mode 100755 index 3e8bc73a..00000000 --- a/hm/soispha/conf/yambar/scripts/old/nmclitest +++ /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/nmclitest.sh b/hm/soispha/conf/yambar/scripts/old/nmclitest.sh new file mode 100755 index 00000000..3e8bc73a --- /dev/null +++ b/hm/soispha/conf/yambar/scripts/old/nmclitest.sh @@ -0,0 +1,23 @@ +#!/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 b/hm/soispha/conf/yambar/scripts/old/pingtest deleted file mode 100755 index 2b5f9998..00000000 --- a/hm/soispha/conf/yambar/scripts/old/pingtest +++ /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/pingtest.sh b/hm/soispha/conf/yambar/scripts/old/pingtest.sh new file mode 100755 index 00000000..2b5f9998 --- /dev/null +++ b/hm/soispha/conf/yambar/scripts/old/pingtest.sh @@ -0,0 +1,28 @@ +#!/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 b/hm/soispha/conf/yambar/scripts/old/yambar-tray deleted file mode 100755 index 1704c6dd..00000000 --- a/hm/soispha/conf/yambar/scripts/old/yambar-tray +++ /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/old/yambar-tray-width b/hm/soispha/conf/yambar/scripts/old/yambar-tray-width deleted file mode 100755 index 00544e70..00000000 --- a/hm/soispha/conf/yambar/scripts/old/yambar-tray-width +++ /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-width.sh b/hm/soispha/conf/yambar/scripts/old/yambar-tray-width.sh new file mode 100755 index 00000000..00544e70 --- /dev/null +++ b/hm/soispha/conf/yambar/scripts/old/yambar-tray-width.sh @@ -0,0 +1,28 @@ +#!/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 new file mode 100755 index 00000000..1704c6dd --- /dev/null +++ b/hm/soispha/conf/yambar/scripts/old/yambar-tray.sh @@ -0,0 +1,27 @@ +#!/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 b/hm/soispha/conf/yambar/scripts/sound-volume deleted file mode 100755 index 721d51bf..00000000 --- a/hm/soispha/conf/yambar/scripts/sound-volume +++ /dev/null @@ -1,20 +0,0 @@ -#! /usr/bin/env dash - -# shellcheck source=/dev/null -SHELL_LIBRARY_VERSION="2.0.13" . %SHELL_LIBRARY_PATH - -while true; do - volume="$(pactl get-sink-volume 0 | awk 'BEGIN { FS="/" } {gsub("%","",$2); gsub(" ","",$2)} {printf $2}')" - - if [ "$volume" -eq 0 ]; then - echo "muted|bool|true" - else - echo "volume|string|$volume" - echo "muted|bool|false" - fi - echo "" - - sleep 3; -done - -# vim: ft=sh diff --git a/hm/soispha/conf/yambar/scripts/sound-volume.sh b/hm/soispha/conf/yambar/scripts/sound-volume.sh new file mode 100755 index 00000000..721d51bf --- /dev/null +++ b/hm/soispha/conf/yambar/scripts/sound-volume.sh @@ -0,0 +1,20 @@ +#! /usr/bin/env dash + +# shellcheck source=/dev/null +SHELL_LIBRARY_VERSION="2.0.13" . %SHELL_LIBRARY_PATH + +while true; do + volume="$(pactl get-sink-volume 0 | awk 'BEGIN { FS="/" } {gsub("%","",$2); gsub(" ","",$2)} {printf $2}')" + + if [ "$volume" -eq 0 ]; then + echo "muted|bool|true" + else + echo "volume|string|$volume" + echo "muted|bool|false" + fi + echo "" + + sleep 3; +done + +# vim: ft=sh diff --git a/hm/soispha/conf/zsh/default.nix b/hm/soispha/conf/zsh/default.nix index 715c0f87..f7493e5e 100644 --- a/hm/soispha/conf/zsh/default.nix +++ b/hm/soispha/conf/zsh/default.nix @@ -66,10 +66,10 @@ ]; initExtraFirst = - builtins.readFile ./config/zsh-init.sh + builtins.readFile ./config/zsh-init.zsh # + builtins.readFile ./config/zsh-prompt.sh - + builtins.readFile ./config/command_not_found_insult.zsh - + builtins.readFile ./config/custom_cursor.sh + + builtins.readFile ./config/command_not_found_insult.sh + + builtins.readFile ./config/custom_cursor.zsh + builtins.readFile "${pkgs.fzf}/share/fzf/key-bindings.zsh" + ''SHELL_LIBRARY_VERSION="2.0.13" source ${shell_library.rawLib.${system}}''; -- cgit 1.4.1