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 --- bootstrap/01_activate | 19 - bootstrap/01_activate.sh | 19 + bootstrap/01_install | 81 ---- bootstrap/01_install.sh | 81 ++++ bootstrap/02_setup | 23 - bootstrap/02_setup.sh | 23 + bootstrap/03_config_setup | 11 - bootstrap/03_config_setup.sh | 11 + bootstrap/99_ensure_config_variables | 122 ----- bootstrap/99_ensure_config_variables.sh | 122 +++++ bootstrap/default.nix | 10 +- 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 +- hm/soispha/pkgs/scripts.nix | 8 +- hm/soispha/pkgs/scripts/apps/aumo | 54 --- hm/soispha/pkgs/scripts/apps/aumo.sh | 54 +++ hm/soispha/pkgs/scripts/apps/con2pdf | 237 --------- hm/soispha/pkgs/scripts/apps/con2pdf.sh | 237 +++++++++ hm/soispha/pkgs/scripts/apps/fupdate | 167 ------- hm/soispha/pkgs/scripts/apps/fupdate.sh | 167 +++++++ hm/soispha/pkgs/scripts/small_functions/nato | 106 ----- hm/soispha/pkgs/scripts/small_functions/nato.py | 106 +++++ .../scripts/small_functions/screenshot_persistent | 25 - .../small_functions/screenshot_persistent.sh | 25 + .../scripts/small_functions/screenshot_temporary | 8 - .../small_functions/screenshot_temporary.sh | 8 + hm/soispha/pkgs/scripts/small_functions/update-sys | 78 --- .../pkgs/scripts/small_functions/update-sys.sh | 78 +++ .../pkgs/scripts/specific/neorg/sh/functions/add | 23 - .../scripts/specific/neorg/sh/functions/add.sh | 23 + .../scripts/specific/neorg/sh/functions/context | 43 -- .../scripts/specific/neorg/sh/functions/context.sh | 43 ++ .../pkgs/scripts/specific/neorg/sh/functions/dmenu | 12 - .../scripts/specific/neorg/sh/functions/dmenu.sh | 12 + .../scripts/specific/neorg/sh/functions/f_start | 7 - .../scripts/specific/neorg/sh/functions/f_start.sh | 7 + .../scripts/specific/neorg/sh/functions/f_stop | 7 - .../scripts/specific/neorg/sh/functions/f_stop.sh | 7 + .../pkgs/scripts/specific/neorg/sh/functions/list | 8 - .../scripts/specific/neorg/sh/functions/list.sh | 8 + .../scripts/specific/neorg/sh/functions/project | 42 -- .../scripts/specific/neorg/sh/functions/project.sh | 42 ++ .../pkgs/scripts/specific/neorg/sh/functions/utils | 40 -- .../scripts/specific/neorg/sh/functions/utils.sh | 40 ++ .../scripts/specific/neorg/sh/functions/workspace | 9 - .../specific/neorg/sh/functions/workspace.sh | 9 + hm/soispha/pkgs/scripts/specific/neorg/sh/main | 156 ------ hm/soispha/pkgs/scripts/specific/neorg/sh/main.sh | 156 ++++++ hm/soispha/pkgs/scripts/specific/ytcc/description | 8 - .../pkgs/scripts/specific/ytcc/description.sh | 8 + hm/soispha/pkgs/scripts/wrappers/hibernate | 16 - hm/soispha/pkgs/scripts/wrappers/hibernate.sh | 16 + hm/soispha/pkgs/scripts/wrappers/ll | 14 - hm/soispha/pkgs/scripts/wrappers/ll.sh | 14 + hm/soispha/pkgs/scripts/wrappers/lock | 19 - hm/soispha/pkgs/scripts/wrappers/lock.sh | 19 + hm/soispha/pkgs/scripts/wrappers/lyrics | 11 - hm/soispha/pkgs/scripts/wrappers/lyrics.sh | 11 + hm/soispha/pkgs/scripts/wrappers/mpc-fav | 15 - hm/soispha/pkgs/scripts/wrappers/mpc-fav.sh | 15 + hm/soispha/pkgs/scripts/wrappers/mpc-rm | 14 - hm/soispha/pkgs/scripts/wrappers/mpc-rm.sh | 14 + hm/soispha/pkgs/scripts/wrappers/show | 9 - hm/soispha/pkgs/scripts/wrappers/show.sh | 9 + hm/soispha/pkgs/scripts/wrappers/sort_song | 33 -- hm/soispha/pkgs/scripts/wrappers/sort_song.sh | 33 ++ hm/soispha/pkgs/scripts/wrappers/spodi | 58 --- hm/soispha/pkgs/scripts/wrappers/spodi.sh | 58 +++ hm/soispha/pkgs/scripts/wrappers/virsh-del | 10 - hm/soispha/pkgs/scripts/wrappers/virsh-del.sh | 10 + hm/soispha/pkgs/scripts/wrappers/yti | 34 -- hm/soispha/pkgs/scripts/wrappers/yti.sh | 34 ++ hm/soispha/wms/river/default.nix | 2 +- hm/soispha/wms/river/init | 81 ---- hm/soispha/wms/river/init.sh | 81 ++++ hm/soispha/wms/river/res/safe_init | 160 ------- hm/soispha/wms/river/res/safe_init.sh | 160 +++++++ sys/nixpkgs/pkgs/snap-sync-forked/default.nix | 2 +- sys/nixpkgs/pkgs/snap-sync-forked/snap-sync-forked | 529 --------------------- .../pkgs/snap-sync-forked/snap-sync-forked.sh | 529 +++++++++++++++++++++ sys/nixpkgs/pkgs/update_pkgs | 27 -- sys/nixpkgs/pkgs/update_pkgs.sh | 27 ++ sys/svcs/xdg/default.nix | 2 +- sys/svcs/xdg/scripts/lf_wrapper | 76 --- sys/svcs/xdg/scripts/lf_wrapper.sh | 76 +++ update.sh | 4 +- 174 files changed, 3543 insertions(+), 3544 deletions(-) delete mode 100755 bootstrap/01_activate create mode 100755 bootstrap/01_activate.sh delete mode 100755 bootstrap/01_install create mode 100755 bootstrap/01_install.sh delete mode 100755 bootstrap/02_setup create mode 100755 bootstrap/02_setup.sh delete mode 100755 bootstrap/03_config_setup create mode 100755 bootstrap/03_config_setup.sh delete mode 100755 bootstrap/99_ensure_config_variables create mode 100755 bootstrap/99_ensure_config_variables.sh 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 delete mode 100755 hm/soispha/pkgs/scripts/apps/aumo create mode 100755 hm/soispha/pkgs/scripts/apps/aumo.sh delete mode 100644 hm/soispha/pkgs/scripts/apps/con2pdf create mode 100755 hm/soispha/pkgs/scripts/apps/con2pdf.sh delete mode 100644 hm/soispha/pkgs/scripts/apps/fupdate create mode 100755 hm/soispha/pkgs/scripts/apps/fupdate.sh delete mode 100755 hm/soispha/pkgs/scripts/small_functions/nato create mode 100755 hm/soispha/pkgs/scripts/small_functions/nato.py delete mode 100755 hm/soispha/pkgs/scripts/small_functions/screenshot_persistent create mode 100755 hm/soispha/pkgs/scripts/small_functions/screenshot_persistent.sh delete mode 100755 hm/soispha/pkgs/scripts/small_functions/screenshot_temporary create mode 100755 hm/soispha/pkgs/scripts/small_functions/screenshot_temporary.sh delete mode 100755 hm/soispha/pkgs/scripts/small_functions/update-sys create mode 100755 hm/soispha/pkgs/scripts/small_functions/update-sys.sh delete mode 100755 hm/soispha/pkgs/scripts/specific/neorg/sh/functions/add create mode 100755 hm/soispha/pkgs/scripts/specific/neorg/sh/functions/add.sh delete mode 100755 hm/soispha/pkgs/scripts/specific/neorg/sh/functions/context create mode 100755 hm/soispha/pkgs/scripts/specific/neorg/sh/functions/context.sh delete mode 100755 hm/soispha/pkgs/scripts/specific/neorg/sh/functions/dmenu create mode 100755 hm/soispha/pkgs/scripts/specific/neorg/sh/functions/dmenu.sh delete mode 100755 hm/soispha/pkgs/scripts/specific/neorg/sh/functions/f_start create mode 100755 hm/soispha/pkgs/scripts/specific/neorg/sh/functions/f_start.sh delete mode 100755 hm/soispha/pkgs/scripts/specific/neorg/sh/functions/f_stop create mode 100755 hm/soispha/pkgs/scripts/specific/neorg/sh/functions/f_stop.sh delete mode 100755 hm/soispha/pkgs/scripts/specific/neorg/sh/functions/list create mode 100755 hm/soispha/pkgs/scripts/specific/neorg/sh/functions/list.sh delete mode 100755 hm/soispha/pkgs/scripts/specific/neorg/sh/functions/project create mode 100755 hm/soispha/pkgs/scripts/specific/neorg/sh/functions/project.sh delete mode 100755 hm/soispha/pkgs/scripts/specific/neorg/sh/functions/utils create mode 100755 hm/soispha/pkgs/scripts/specific/neorg/sh/functions/utils.sh delete mode 100755 hm/soispha/pkgs/scripts/specific/neorg/sh/functions/workspace create mode 100755 hm/soispha/pkgs/scripts/specific/neorg/sh/functions/workspace.sh delete mode 100755 hm/soispha/pkgs/scripts/specific/neorg/sh/main create mode 100755 hm/soispha/pkgs/scripts/specific/neorg/sh/main.sh delete mode 100755 hm/soispha/pkgs/scripts/specific/ytcc/description create mode 100755 hm/soispha/pkgs/scripts/specific/ytcc/description.sh delete mode 100755 hm/soispha/pkgs/scripts/wrappers/hibernate create mode 100755 hm/soispha/pkgs/scripts/wrappers/hibernate.sh delete mode 100755 hm/soispha/pkgs/scripts/wrappers/ll create mode 100755 hm/soispha/pkgs/scripts/wrappers/ll.sh delete mode 100755 hm/soispha/pkgs/scripts/wrappers/lock create mode 100755 hm/soispha/pkgs/scripts/wrappers/lock.sh delete mode 100755 hm/soispha/pkgs/scripts/wrappers/lyrics create mode 100755 hm/soispha/pkgs/scripts/wrappers/lyrics.sh delete mode 100755 hm/soispha/pkgs/scripts/wrappers/mpc-fav create mode 100755 hm/soispha/pkgs/scripts/wrappers/mpc-fav.sh delete mode 100755 hm/soispha/pkgs/scripts/wrappers/mpc-rm create mode 100755 hm/soispha/pkgs/scripts/wrappers/mpc-rm.sh delete mode 100755 hm/soispha/pkgs/scripts/wrappers/show create mode 100755 hm/soispha/pkgs/scripts/wrappers/show.sh delete mode 100755 hm/soispha/pkgs/scripts/wrappers/sort_song create mode 100755 hm/soispha/pkgs/scripts/wrappers/sort_song.sh delete mode 100755 hm/soispha/pkgs/scripts/wrappers/spodi create mode 100755 hm/soispha/pkgs/scripts/wrappers/spodi.sh delete mode 100755 hm/soispha/pkgs/scripts/wrappers/virsh-del create mode 100755 hm/soispha/pkgs/scripts/wrappers/virsh-del.sh delete mode 100755 hm/soispha/pkgs/scripts/wrappers/yti create mode 100755 hm/soispha/pkgs/scripts/wrappers/yti.sh delete mode 100755 hm/soispha/wms/river/init create mode 100755 hm/soispha/wms/river/init.sh delete mode 100755 hm/soispha/wms/river/res/safe_init create mode 100755 hm/soispha/wms/river/res/safe_init.sh delete mode 100755 sys/nixpkgs/pkgs/snap-sync-forked/snap-sync-forked create mode 100755 sys/nixpkgs/pkgs/snap-sync-forked/snap-sync-forked.sh delete mode 100755 sys/nixpkgs/pkgs/update_pkgs create mode 100755 sys/nixpkgs/pkgs/update_pkgs.sh delete mode 100755 sys/svcs/xdg/scripts/lf_wrapper create mode 100755 sys/svcs/xdg/scripts/lf_wrapper.sh diff --git a/bootstrap/01_activate b/bootstrap/01_activate deleted file mode 100755 index 82e45761..00000000 --- a/bootstrap/01_activate +++ /dev/null @@ -1,19 +0,0 @@ -#! /usr/bin/env dash - -# shellcheck source=/dev/null -SHELL_LIBRARY_VERSION="2.0.13" . %SHELL_LIBRARY_PATH - -. %SCRIPT_ENSURE_CONFIG_VARIABLES - -nix run github:nix-community/disko --experimental-features 'nix-command flakes' -- --flake "git+https://codeberg.org/soispha/nixos-config#$NIX_HOST" --mode mount - -msg "Finished mounting" - -case "$ACTIVATE_TO_SETUP" in - "yes") - nix run "git+https://codeberg.org/soispha/nixos-config#setup" --experimental-features 'nix-command flakes' - ;; - *) ;; -esac - -# vim: ft=sh diff --git a/bootstrap/01_activate.sh b/bootstrap/01_activate.sh new file mode 100755 index 00000000..82e45761 --- /dev/null +++ b/bootstrap/01_activate.sh @@ -0,0 +1,19 @@ +#! /usr/bin/env dash + +# shellcheck source=/dev/null +SHELL_LIBRARY_VERSION="2.0.13" . %SHELL_LIBRARY_PATH + +. %SCRIPT_ENSURE_CONFIG_VARIABLES + +nix run github:nix-community/disko --experimental-features 'nix-command flakes' -- --flake "git+https://codeberg.org/soispha/nixos-config#$NIX_HOST" --mode mount + +msg "Finished mounting" + +case "$ACTIVATE_TO_SETUP" in + "yes") + nix run "git+https://codeberg.org/soispha/nixos-config#setup" --experimental-features 'nix-command flakes' + ;; + *) ;; +esac + +# vim: ft=sh diff --git a/bootstrap/01_install b/bootstrap/01_install deleted file mode 100755 index e4581b6d..00000000 --- a/bootstrap/01_install +++ /dev/null @@ -1,81 +0,0 @@ -#! /usr/bin/env dash - -# shellcheck source=/dev/null -SHELL_LIBRARY_VERSION="2.0.13" . %SHELL_LIBRARY_PATH - -INSTALL=y . %SCRIPT_ENSURE_CONFIG_VARIABLES - -msg "Important information:" -msg2 "Choose disk id is: $NIX_DISK" -warning "This information needs to be entered in the host configuration BEFORE rebuilding it. Otherwise you'll have to wait for a 1 h cooldown!" -info_applied=false -while [ "$info_applied" = false ]; do - readp "Have you updated your chosen host with the choose disk id? [N/y]: " result - case $result in - [Yy]) - info_applied=true - ;; - *) - warning "You won't be able to boot, if you don't update it!" - ;; - esac -done - -msg "Started creating filesystem..." -nix run github:nix-community/disko --experimental-features 'nix-command flakes' -- --flake "git+https://codeberg.org/soispha/nixos-config#$NIX_HOST" --mode disko -msg "Finished mounting and generating btrfs subvolumes" - -msg "Creating swapfile..." -msg2 "$(btrfs filesystem mkswapfile --size "$(free -m | awk '{if (NR==2) {printf "%sm\n", $2 + 500}}')" /mnt/swap/swapfile)" -msg "Finished creating swapfile!" - -msg "Important information:" -msg2 "Swapfile UUID is: $(findmnt -no UUID -T /mnt/swap/swapfile)" -msg2 "Swapfile resume offset is: $(btrfs inspect-internal map-swapfile -r /mnt/swap/swapfile)" -warning "This information needs to be entered in the host configuration BEFORE rebuilding it. Otherwise the system won't boot!" - -info_applied=false -while [ "$info_applied" = false ]; do - readp "Have you updated your chosen host with this information? [N/y]: " result - case $result in - [Yy]) - info_applied=true - ;; - *) - warning "You won't be able to boot, if you don't update it!" - ;; - esac -done - -msg "Checking for incompatibilities..." -ssd_or_hdd="$(cat /sys/block/"$(basename "$(readlink -f "/dev/disk/by-id/$NIX_DISK")" | tr -d '\n')"/queue/rotational)" -case "$ssd_or_hdd" in - 0) - msg2 "You seem to use a ssd." - trim_support=$(lsblk --bytes --json --discard | jq --arg name "$(basename "$(readlink -f "/dev/disk/by-id/$NIX_DISK")" | tr -d '\n')" '.blockdevices | .[] | select(.name == $name) | (.["disc-gran"] + .["disc-max"]) != 0') - case $trim_support in - "true") - msg2 "Yay, your ssd supports trim, go on and activate it" - ;; - "false") - msg2 "Nay, your ssd doesn't support trim" - ;; - *) - warning "Your ssd doesn't seem to exists, if this bothers you please open an issue." - ;; - esac - ;; - 1) - msg2 "You seem to use a hdd there is nothing you have to do" - ;; - *) - warning "There is no indicator, which shows, which drive your are using.\n This means, that you have to check yourself, which optimizations you should activate." - ;; -esac - -case "$INSTALL_TO_SETUP" in - "yes") - nix run "git+https://codeberg.org/soispha/nixos-config#setup" --experimental-features 'nix-command flakes' - ;; - *) ;; -esac diff --git a/bootstrap/01_install.sh b/bootstrap/01_install.sh new file mode 100755 index 00000000..e4581b6d --- /dev/null +++ b/bootstrap/01_install.sh @@ -0,0 +1,81 @@ +#! /usr/bin/env dash + +# shellcheck source=/dev/null +SHELL_LIBRARY_VERSION="2.0.13" . %SHELL_LIBRARY_PATH + +INSTALL=y . %SCRIPT_ENSURE_CONFIG_VARIABLES + +msg "Important information:" +msg2 "Choose disk id is: $NIX_DISK" +warning "This information needs to be entered in the host configuration BEFORE rebuilding it. Otherwise you'll have to wait for a 1 h cooldown!" +info_applied=false +while [ "$info_applied" = false ]; do + readp "Have you updated your chosen host with the choose disk id? [N/y]: " result + case $result in + [Yy]) + info_applied=true + ;; + *) + warning "You won't be able to boot, if you don't update it!" + ;; + esac +done + +msg "Started creating filesystem..." +nix run github:nix-community/disko --experimental-features 'nix-command flakes' -- --flake "git+https://codeberg.org/soispha/nixos-config#$NIX_HOST" --mode disko +msg "Finished mounting and generating btrfs subvolumes" + +msg "Creating swapfile..." +msg2 "$(btrfs filesystem mkswapfile --size "$(free -m | awk '{if (NR==2) {printf "%sm\n", $2 + 500}}')" /mnt/swap/swapfile)" +msg "Finished creating swapfile!" + +msg "Important information:" +msg2 "Swapfile UUID is: $(findmnt -no UUID -T /mnt/swap/swapfile)" +msg2 "Swapfile resume offset is: $(btrfs inspect-internal map-swapfile -r /mnt/swap/swapfile)" +warning "This information needs to be entered in the host configuration BEFORE rebuilding it. Otherwise the system won't boot!" + +info_applied=false +while [ "$info_applied" = false ]; do + readp "Have you updated your chosen host with this information? [N/y]: " result + case $result in + [Yy]) + info_applied=true + ;; + *) + warning "You won't be able to boot, if you don't update it!" + ;; + esac +done + +msg "Checking for incompatibilities..." +ssd_or_hdd="$(cat /sys/block/"$(basename "$(readlink -f "/dev/disk/by-id/$NIX_DISK")" | tr -d '\n')"/queue/rotational)" +case "$ssd_or_hdd" in + 0) + msg2 "You seem to use a ssd." + trim_support=$(lsblk --bytes --json --discard | jq --arg name "$(basename "$(readlink -f "/dev/disk/by-id/$NIX_DISK")" | tr -d '\n')" '.blockdevices | .[] | select(.name == $name) | (.["disc-gran"] + .["disc-max"]) != 0') + case $trim_support in + "true") + msg2 "Yay, your ssd supports trim, go on and activate it" + ;; + "false") + msg2 "Nay, your ssd doesn't support trim" + ;; + *) + warning "Your ssd doesn't seem to exists, if this bothers you please open an issue." + ;; + esac + ;; + 1) + msg2 "You seem to use a hdd there is nothing you have to do" + ;; + *) + warning "There is no indicator, which shows, which drive your are using.\n This means, that you have to check yourself, which optimizations you should activate." + ;; +esac + +case "$INSTALL_TO_SETUP" in + "yes") + nix run "git+https://codeberg.org/soispha/nixos-config#setup" --experimental-features 'nix-command flakes' + ;; + *) ;; +esac diff --git a/bootstrap/02_setup b/bootstrap/02_setup deleted file mode 100755 index 44368f69..00000000 --- a/bootstrap/02_setup +++ /dev/null @@ -1,23 +0,0 @@ -#! /usr/bin/env dash - -# shellcheck source=/dev/null -SHELL_LIBRARY_VERSION="2.0.13" . %SHELL_LIBRARY_PATH - -. %SCRIPT_ENSURE_CONFIG_VARIABLES - -nixos-install --flake git+https://codeberg.org/soispha/nixos-config#"$NIX_HOST" --no-root-passwd - -# clone the git config -git clone https://codeberg.org/soispha/nixos-config.git /mnt/srv/etc/nixos - -# setup persistent home dir -mkdir --parents /mnt/srv/home -chown 1000:100 --recursive /mnt/srv/home -chmod 700 /mnt/srv/home - -case "$SETUP_TO_CONFIG_SETUP" in - "yes") - nix run "git+https://codeberg.org/soispha/nixos-config#config_setup" --experimental-features 'nix-command flakes' - ;; - *) ;; -esac diff --git a/bootstrap/02_setup.sh b/bootstrap/02_setup.sh new file mode 100755 index 00000000..44368f69 --- /dev/null +++ b/bootstrap/02_setup.sh @@ -0,0 +1,23 @@ +#! /usr/bin/env dash + +# shellcheck source=/dev/null +SHELL_LIBRARY_VERSION="2.0.13" . %SHELL_LIBRARY_PATH + +. %SCRIPT_ENSURE_CONFIG_VARIABLES + +nixos-install --flake git+https://codeberg.org/soispha/nixos-config#"$NIX_HOST" --no-root-passwd + +# clone the git config +git clone https://codeberg.org/soispha/nixos-config.git /mnt/srv/etc/nixos + +# setup persistent home dir +mkdir --parents /mnt/srv/home +chown 1000:100 --recursive /mnt/srv/home +chmod 700 /mnt/srv/home + +case "$SETUP_TO_CONFIG_SETUP" in + "yes") + nix run "git+https://codeberg.org/soispha/nixos-config#config_setup" --experimental-features 'nix-command flakes' + ;; + *) ;; +esac diff --git a/bootstrap/03_config_setup b/bootstrap/03_config_setup deleted file mode 100755 index dc2726d0..00000000 --- a/bootstrap/03_config_setup +++ /dev/null @@ -1,11 +0,0 @@ -#! /usr/bin/env dash - -# shellcheck source=/dev/null -SHELL_LIBRARY_VERSION="2.0.13" . %SHELL_LIBRARY_PATH - -# clone packer.nvim to the needed dir, for the nvim install to work -git clone --depth 1 https://github.com/wbthomason/packer.nvim /mnt/srv/home/soispha/.local/share/nvim/site/pack/packer/start/packer.nvim - -nixos-enter --command 'nvim -c "PackerSync" -c "qall" -u "/mnt/srv/home/soispha/.config/nvim/init.lua" --headless' - -# vim: ft=sh diff --git a/bootstrap/03_config_setup.sh b/bootstrap/03_config_setup.sh new file mode 100755 index 00000000..dc2726d0 --- /dev/null +++ b/bootstrap/03_config_setup.sh @@ -0,0 +1,11 @@ +#! /usr/bin/env dash + +# shellcheck source=/dev/null +SHELL_LIBRARY_VERSION="2.0.13" . %SHELL_LIBRARY_PATH + +# clone packer.nvim to the needed dir, for the nvim install to work +git clone --depth 1 https://github.com/wbthomason/packer.nvim /mnt/srv/home/soispha/.local/share/nvim/site/pack/packer/start/packer.nvim + +nixos-enter --command 'nvim -c "PackerSync" -c "qall" -u "/mnt/srv/home/soispha/.config/nvim/init.lua" --headless' + +# vim: ft=sh diff --git a/bootstrap/99_ensure_config_variables b/bootstrap/99_ensure_config_variables deleted file mode 100755 index ce8ffa0f..00000000 --- a/bootstrap/99_ensure_config_variables +++ /dev/null @@ -1,122 +0,0 @@ -#! /usr/bin/env dash - -# shellcheck source=/dev/null -SHELL_LIBRARY_VERSION="2.0.13" . %SHELL_LIBRARY_PATH - -if ! [ "$NIX_ENVIRONMENT_VARIABLES_SET" ]; then - if ! [ "$NIX_HOST" ]; then - msg "Select a host:" - _hosts=$(mktmp) - curl https://codeberg.org/soispha/nixos-config/raw/branch/prime/flake/nixosConfigurations/default.nix 2> /dev/null | awk -F '"' '/hosts = /{for (i=2;i "$_hosts" - - while ! grep "$host" "$_hosts" > /dev/null || [ "$(printf "%s" "$host" | wc -c)" -eq 0 ]; do - i=1 - while read -r host_read; do - printf "%4s) %s \n" "$i" "$host_read" - i=$((i + 1)) - done < "$_hosts" - printf "%4s) Exit\n" "q" - readp "Enter a option: " host - - [ "$host" = "q" ] && exit 1 - host=$(awk -v i="$host" '{if (NR==i) {print $0}}' "$_hosts") - if ! grep "$host" "$_hosts" > /dev/null || [ "$(printf "%s" "$host" | wc -c)" -eq 0 ]; then - warning "No host selected. Select a host to continue.\n" - fi - done - - export NIX_HOST="$host" - fi - if ! [ "$NIX_DISK" ] && [ "$INSTALL" ]; then - available_disks="$(mktmp)" - lsblk -J | jq '.[] | map(.name) | [foreach .[] as $item ({item: null, index: -1}; {$item, index: (.index + 1)})]' > "$available_disks" - - [ "$(jq '.[]' "$available_disks" | wc -l)" -eq 0 ] && die "No disks found" - msg "Select a disk to format:" - - i=9999 # nobody will have so many disks attached - - while ! jq -e --argjson i "$i" '.[$i]' "$available_disks" > /dev/null 2>&1; do - for _disk in $(jq -c '.[]' "$available_disks"); do - printf "%4s) %s \n" "$(echo "$_disk" | jq '.index')" "$(echo "$_disk" | jq '.item' | tr -d "\"")" - done - printf "%4s) Exit\n" "q" - readp "Enter a option: " _disk - - if [ "$_disk" = "q" ]; then - exit 1 - else - i="$_disk" - fi - if jq -e --argjson i "$i" 'nth($i)' "$available_disks" > /dev/null 2>&1; then - _disk=$(mktmp) - jq -e --argjson i "$i" 'nth($i)' "$available_disks" > "$_disk" - else - warning "No disk selected. Select a disk to continue.\n" - fi - done - - warn "All data on disk $(jq '.item' "$_disk") will be deleted." - readp "Continue with this disk? [N/y]: " result - case "$result" in - [Yy]) - msg "Great, continuing..." - _disk="$(jq '.item' "$_disk" | tr -d "\"")" - _disk_serial="$(udevadm info --query=all --name="$_disk" | grep ID_SERIAL= | awk 'BEGIN{FS="="}{print $2}')" - case "$_disk" in - "nvme"*) - _nix_disk="nvme-$_disk_serial" - ;; - "sd"*) - _nix_disk="ata-$_disk_serial" - ;; - *) - die "Disk with name '$_disk' and serial '$_disk_serial' not yet supported!" - ;; - esac - export NIX_DISK="$_nix_disk" - ;; - *) - msg "Sure, keep your data" - exit 1 - ;; - esac - fi - - if ! [ "$ACTIVATE_TO_SETUP" ] && ! [ "$INSTALL" ]; then - readp "Do you want to continue with nixos-install after activation? [N/y]: " result - case $result in - [Yy]) - export ACTIVATE_TO_SETUP=yes - ;; - *) - export ACTIVATE_TO_SETUP=no - ;; - esac - fi - if ! [ "$INSTALL_TO_SETUP" ] && [ "$INSTALL" ]; then - readp "Do you want to continue with nixos-install after disk formatting? [N/y]: " result - case $result in - [Yy]) - export INSTALL_TO_SETUP=yes - ;; - *) - export INSTALL_TO_SETUP=no - ;; - esac - fi - if ! [ "$SETUP_TO_CONFIG_SETUP" ]; then - readp "Do you want to continue with the user configuration setup after setup? [N/y]: " result - case $result in - [Yy]) - export SETUP_TO_CONFIG_SETUP=yes - ;; - *) - export SETUP_TO_CONFIG_SETUP=no - ;; - esac - fi - export NIX_ENVIRONMENT_VARIABLES_SET="set"; -fi - -# vim: ft=sh diff --git a/bootstrap/99_ensure_config_variables.sh b/bootstrap/99_ensure_config_variables.sh new file mode 100755 index 00000000..ce8ffa0f --- /dev/null +++ b/bootstrap/99_ensure_config_variables.sh @@ -0,0 +1,122 @@ +#! /usr/bin/env dash + +# shellcheck source=/dev/null +SHELL_LIBRARY_VERSION="2.0.13" . %SHELL_LIBRARY_PATH + +if ! [ "$NIX_ENVIRONMENT_VARIABLES_SET" ]; then + if ! [ "$NIX_HOST" ]; then + msg "Select a host:" + _hosts=$(mktmp) + curl https://codeberg.org/soispha/nixos-config/raw/branch/prime/flake/nixosConfigurations/default.nix 2> /dev/null | awk -F '"' '/hosts = /{for (i=2;i "$_hosts" + + while ! grep "$host" "$_hosts" > /dev/null || [ "$(printf "%s" "$host" | wc -c)" -eq 0 ]; do + i=1 + while read -r host_read; do + printf "%4s) %s \n" "$i" "$host_read" + i=$((i + 1)) + done < "$_hosts" + printf "%4s) Exit\n" "q" + readp "Enter a option: " host + + [ "$host" = "q" ] && exit 1 + host=$(awk -v i="$host" '{if (NR==i) {print $0}}' "$_hosts") + if ! grep "$host" "$_hosts" > /dev/null || [ "$(printf "%s" "$host" | wc -c)" -eq 0 ]; then + warning "No host selected. Select a host to continue.\n" + fi + done + + export NIX_HOST="$host" + fi + if ! [ "$NIX_DISK" ] && [ "$INSTALL" ]; then + available_disks="$(mktmp)" + lsblk -J | jq '.[] | map(.name) | [foreach .[] as $item ({item: null, index: -1}; {$item, index: (.index + 1)})]' > "$available_disks" + + [ "$(jq '.[]' "$available_disks" | wc -l)" -eq 0 ] && die "No disks found" + msg "Select a disk to format:" + + i=9999 # nobody will have so many disks attached + + while ! jq -e --argjson i "$i" '.[$i]' "$available_disks" > /dev/null 2>&1; do + for _disk in $(jq -c '.[]' "$available_disks"); do + printf "%4s) %s \n" "$(echo "$_disk" | jq '.index')" "$(echo "$_disk" | jq '.item' | tr -d "\"")" + done + printf "%4s) Exit\n" "q" + readp "Enter a option: " _disk + + if [ "$_disk" = "q" ]; then + exit 1 + else + i="$_disk" + fi + if jq -e --argjson i "$i" 'nth($i)' "$available_disks" > /dev/null 2>&1; then + _disk=$(mktmp) + jq -e --argjson i "$i" 'nth($i)' "$available_disks" > "$_disk" + else + warning "No disk selected. Select a disk to continue.\n" + fi + done + + warn "All data on disk $(jq '.item' "$_disk") will be deleted." + readp "Continue with this disk? [N/y]: " result + case "$result" in + [Yy]) + msg "Great, continuing..." + _disk="$(jq '.item' "$_disk" | tr -d "\"")" + _disk_serial="$(udevadm info --query=all --name="$_disk" | grep ID_SERIAL= | awk 'BEGIN{FS="="}{print $2}')" + case "$_disk" in + "nvme"*) + _nix_disk="nvme-$_disk_serial" + ;; + "sd"*) + _nix_disk="ata-$_disk_serial" + ;; + *) + die "Disk with name '$_disk' and serial '$_disk_serial' not yet supported!" + ;; + esac + export NIX_DISK="$_nix_disk" + ;; + *) + msg "Sure, keep your data" + exit 1 + ;; + esac + fi + + if ! [ "$ACTIVATE_TO_SETUP" ] && ! [ "$INSTALL" ]; then + readp "Do you want to continue with nixos-install after activation? [N/y]: " result + case $result in + [Yy]) + export ACTIVATE_TO_SETUP=yes + ;; + *) + export ACTIVATE_TO_SETUP=no + ;; + esac + fi + if ! [ "$INSTALL_TO_SETUP" ] && [ "$INSTALL" ]; then + readp "Do you want to continue with nixos-install after disk formatting? [N/y]: " result + case $result in + [Yy]) + export INSTALL_TO_SETUP=yes + ;; + *) + export INSTALL_TO_SETUP=no + ;; + esac + fi + if ! [ "$SETUP_TO_CONFIG_SETUP" ]; then + readp "Do you want to continue with the user configuration setup after setup? [N/y]: " result + case $result in + [Yy]) + export SETUP_TO_CONFIG_SETUP=yes + ;; + *) + export SETUP_TO_CONFIG_SETUP=no + ;; + esac + fi + export NIX_ENVIRONMENT_VARIABLES_SET="set"; +fi + +# vim: ft=sh diff --git a/bootstrap/default.nix b/bootstrap/default.nix index 859434e1..b3e44380 100644 --- a/bootstrap/default.nix +++ b/bootstrap/default.nix @@ -8,31 +8,31 @@ activate = sysLib.writeShellScript { dependencies = builtins.attrValues {inherit (pkgs) jq gawk curl coreutils libuuid nix git;} ++ ensure_config_variables_dependencies; name = "activate"; - src = ./01_activate; + src = ./01_activate.sh; inherit replacementStrings; }; install = sysLib.writeShellScript { dependencies = builtins.attrValues {inherit (pkgs) jq dash curl gawk btrfs-progs coreutils libuuid gptfdisk dosfstools toybox nix git;} ++ ensure_config_variables_dependencies; name = "install"; - src = ./01_install; + src = ./01_install.sh; inherit replacementStrings; }; setup = sysLib.writeShellScript { dependencies = builtins.attrValues {inherit (pkgs) dash gawk curl git nix gnugrep nixos-install-tools coreutils libuuid;} ++ ensure_config_variables_dependencies; name = "setup"; - src = ./02_setup; + src = ./02_setup.sh; inherit replacementStrings; }; config_setup = sysLib.writeShellScript { dependencies = builtins.attrValues {inherit (pkgs) git neovim;} ++ ensure_config_variables_dependencies; name = "config_setup"; - src = ./03_config_setup; + src = ./03_config_setup.sh; keepPath = true; inherit replacementStrings; }; ensure_config_variables = sysLib.writeShellScript { name = "ensure_config_variables"; - src = ./99_ensure_config_variables; + src = ./99_ensure_config_variables.sh; wrap = false; }; output = {inherit activate install setup config_setup ensure_config_variables;}; 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}}''; diff --git a/hm/soispha/pkgs/scripts.nix b/hm/soispha/pkgs/scripts.nix index 57aff326..a1603656 100644 --- a/hm/soispha/pkgs/scripts.nix +++ b/hm/soispha/pkgs/scripts.nix @@ -14,7 +14,7 @@ }: sysLib.writeShellScript { inherit name keepPath; - src = ./scripts/${path}/${name}; + src = ./scripts/${path}/${name}.sh; dependencies = dependencies ++ [pkgs.dash]; generateCompletions = completions; }; @@ -25,7 +25,7 @@ dependencies_python ? _: [], keepPath ? false, }: let - src = ./scripts/${path}/${name}; + src = ./scripts/${path}/${name}.py; dependencies = [(pkgs.python3.withPackages dependencies_python)] ++ dependencies_system; @@ -53,7 +53,7 @@ con2pdf-scr = sysLib.writeShellScript { name = "con2pdf"; - src = ./scripts/apps/con2pdf; + src = ./scripts/apps/con2pdf.sh; dependencies = builtins.attrValues {inherit (pkgs) sane-backends imagemagick coreutils fd;}; generateCompletions = true; replacementStrings = { @@ -113,7 +113,7 @@ ll-scr = sysLib.writeShellScript { name = "ll"; - src = ./scripts/wrappers/ll; + src = ./scripts/wrappers/ll.sh; wrap = false; }; diff --git a/hm/soispha/pkgs/scripts/apps/aumo b/hm/soispha/pkgs/scripts/apps/aumo deleted file mode 100755 index b5840fc3..00000000 --- a/hm/soispha/pkgs/scripts/apps/aumo +++ /dev/null @@ -1,54 +0,0 @@ -#! /usr/bin/env dash - -# 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/ diff --git a/hm/soispha/pkgs/scripts/apps/aumo.sh b/hm/soispha/pkgs/scripts/apps/aumo.sh new file mode 100755 index 00000000..b5840fc3 --- /dev/null +++ b/hm/soispha/pkgs/scripts/apps/aumo.sh @@ -0,0 +1,54 @@ +#! /usr/bin/env dash + +# 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/ diff --git a/hm/soispha/pkgs/scripts/apps/con2pdf b/hm/soispha/pkgs/scripts/apps/con2pdf deleted file mode 100644 index be8810bb..00000000 --- a/hm/soispha/pkgs/scripts/apps/con2pdf +++ /dev/null @@ -1,237 +0,0 @@ -#! /usr/bin/env dash - -# shellcheck source=/dev/null -SHELL_LIBRARY_VERSION="2.0.13" . %SHELL_LIBRARY_PATH - - -# needed for help() and version -# shellcheck disable=2034 -AUTHORS="Soispha"; -# shellcheck disable=2034 -YEARS="2023"; -# shellcheck disable=2034 -VERSION="1.0.0"; - -help() { -cat << EOF -Scan images and turn them into a pdf. - -Usage: - $NAME [OPTIONS] --name --device - -OPTIONS: - --out-dir | -o [FILE] - Path to place the generated pdf files (default: ./pdf). - - --name | -n NAME - Name for the pdf files (e.g. _1.pdf). - - --num-pages | -p NUM - Number of pages to merge into one pdf (default: 1). - - --device | -d DEVICE - Device used for scanning. - - --method | -m METHOD - Method to use for scanning (default: ADF). - - --help | -h - Display this help and exit. - - --version | -v - Display version and copyright information and exit. -ARGUMENTS: - FILE := [[fd . --max-depth 3]] - A name of a file to store, default is: ./pdf - - NAME | * := [[fd . --max-depth 3]] - The basename of the generated files - - NUM | *([0-9]) := 0 | 1 | 2 | 3 | 4 - Possible numbers of pages, can be more than 4 - - DEVICE := [[$(cat %DEVICE_FUNCTION)]] - Possible scanner names - - METHOD := ADF | Flatbed - The scanning method to use, not all scanners support both of - these. The default is ADF -EOF -} - -scan_adf() { - 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!"; - readp "Press enter to continue" noop - fi - done -} -process_images_adf() { - tiff_temp_path="$1"; - output_directory="$2"; - name="$3"; - - 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" - : $((counter += 1)) - if [ "$counter" = "$number_of_pages" ]; then - dbg "$counter == $number_of_pages" - counter=0; - convert_images "$image_cache" "${name}_$pdf_counter" "$output_directory" - : $((pdf_counter += 1)) - printf "" > "$image_cache" - fi - done < "$(tmp_pipe fd . "$tiff_temp_path" "|" sort -V)" -} - -scan_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!"; - readp "Press enter to continue" noop - fi - done -} -process_images_flatbed() { - tiff_temp_path="$1"; - output_directory="$2"; - name="$3"; - - counter=0; - image_cache="$(mktmp)" - while read -r scanned_image; do - echo "$scanned_image" >> "$image_cache" - : $((counter += 1)) - if [ "$counter" = "$number_of_pages" ]; then - counter=0; - convert_images "$image_cache" "$name" "$output_directory" - printf "" > "$image_cache" - fi - done < "$(tmp_pipe fd . "$tiff_temp_path" "|" sort -V)" -} -convert_images() { - image_cache="$1"; - pdf_name="$2"; - output_dir="$3"; - - set -- - while read -r image; do - dbg "setting image: $image"; - set -- "$@" "$image" - done < "$image_cache" - - while [ -e "$output_dir/${pdf_name}.pdf" ]; do - pdf_name="${pdf_name}_$(tr -dc 'A-Za-z0-9' _1.pdf). + + --num-pages | -p NUM + Number of pages to merge into one pdf (default: 1). + + --device | -d DEVICE + Device used for scanning. + + --method | -m METHOD + Method to use for scanning (default: ADF). + + --help | -h + Display this help and exit. + + --version | -v + Display version and copyright information and exit. +ARGUMENTS: + FILE := [[fd . --max-depth 3]] + A name of a file to store, default is: ./pdf + + NAME | * := [[fd . --max-depth 3]] + The basename of the generated files + + NUM | *([0-9]) := 0 | 1 | 2 | 3 | 4 + Possible numbers of pages, can be more than 4 + + DEVICE := [[$(cat %DEVICE_FUNCTION)]] + Possible scanner names + + METHOD := ADF | Flatbed + The scanning method to use, not all scanners support both of + these. The default is ADF +EOF +} + +scan_adf() { + 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!"; + readp "Press enter to continue" noop + fi + done +} +process_images_adf() { + tiff_temp_path="$1"; + output_directory="$2"; + name="$3"; + + 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" + : $((counter += 1)) + if [ "$counter" = "$number_of_pages" ]; then + dbg "$counter == $number_of_pages" + counter=0; + convert_images "$image_cache" "${name}_$pdf_counter" "$output_directory" + : $((pdf_counter += 1)) + printf "" > "$image_cache" + fi + done < "$(tmp_pipe fd . "$tiff_temp_path" "|" sort -V)" +} + +scan_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!"; + readp "Press enter to continue" noop + fi + done +} +process_images_flatbed() { + tiff_temp_path="$1"; + output_directory="$2"; + name="$3"; + + counter=0; + image_cache="$(mktmp)" + while read -r scanned_image; do + echo "$scanned_image" >> "$image_cache" + : $((counter += 1)) + if [ "$counter" = "$number_of_pages" ]; then + counter=0; + convert_images "$image_cache" "$name" "$output_directory" + printf "" > "$image_cache" + fi + done < "$(tmp_pipe fd . "$tiff_temp_path" "|" sort -V)" +} +convert_images() { + image_cache="$1"; + pdf_name="$2"; + output_dir="$3"; + + set -- + while read -r image; do + dbg "setting image: $image"; + set -- "$@" "$image" + done < "$image_cache" + + while [ -e "$output_dir/${pdf_name}.pdf" ]; do + pdf_name="${pdf_name}_$(tr -dc 'A-Za-z0-9' "$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_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!"; - fi -} - -help() { -cat << EOF -This is a Nix flake update manager. - -Usage: - $NAME [--help] - -Options: - --help | -h - Display this help and exit. - --version | -v - Display version and copyright information and exit. - -Commands: - flake - update the flake project - - runs a executable called "update-", if it exists -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"; - - if [ "$update_script" = "" ]; then - update "" "$flake_base_dir"; - elif check_for_allowed_update_script "$update_script" && ! [ "$update_script" = "" ]; then - update "$update_script" "$flake_base_dir"; - else - ask_to_allow_update_script "$update_script"; - main; - fi - fi -} - -if [ "$#" -eq 0 ]; then - main; -fi - -for input in "$@"; do - case "$input" in - "--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 - 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/apps/fupdate.sh b/hm/soispha/pkgs/scripts/apps/fupdate.sh new file mode 100755 index 00000000..7722c070 --- /dev/null +++ b/hm/soispha/pkgs/scripts/apps/fupdate.sh @@ -0,0 +1,167 @@ +#! /usr/bin/env dash + +# 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"; + +AUTHORS="Soispha" +YEARS="2023" + +# Searches upward for a `UPDATE_SCRIPT_NAME` script +# Returns a path to the script if it exists, otherwise nothing is returned +check_for_update_script() { + dirname="$(search_upward_files "$UPDATE_SCRIPT_NAME")" + if [ "$dirname" ]; then + printf "%s/%s" "$dirname" "$UPDATE_SCRIPT_NAME" + fi +} + +# 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")"; + if [ -f "$config_path" ]; then + 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; + fi + else + 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"; + 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; + ;; + 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_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!"; + fi +} + +help() { +cat << EOF +This is a Nix flake update manager. + +Usage: + $NAME [--help] + +Options: + --help | -h + Display this help and exit. + --version | -v + Display version and copyright information and exit. + +Commands: + flake + update the flake project + + runs a executable called "update-", if it exists +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"; + + if [ "$update_script" = "" ]; then + update "" "$flake_base_dir"; + elif check_for_allowed_update_script "$update_script" && ! [ "$update_script" = "" ]; then + update "$update_script" "$flake_base_dir"; + else + ask_to_allow_update_script "$update_script"; + main; + fi + fi +} + +if [ "$#" -eq 0 ]; then + main; +fi + +for input in "$@"; do + case "$input" in + "--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 + 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/nato b/hm/soispha/pkgs/scripts/small_functions/nato deleted file mode 100755 index e9d15f56..00000000 --- a/hm/soispha/pkgs/scripts/small_functions/nato +++ /dev/null @@ -1,106 +0,0 @@ -#!/usr/bin/env python3 -# originally from here: https://cgit.pacien.net/desktop-utilities/ - -import sys - -alphabet = { - "nato": { - "A": "Alfa", # No idea why this is not just 'Alpha' .. - "B": "Bravo", - "C": "Charlie", - "D": "Delta", - "E": "Echo", - "F": "Foxtrot", - "G": "Golf", - "H": "Hotel", - "I": "India", - "J": "Juliett", - "K": "Kilo", - "L": "Lima", - "M": "Mike", - "N": "November", - "O": "Oscar", - "P": "Papa", - "Q": "Quebec", - "R": "Romeo", - "S": "Sierra", - "T": "Tango", - "U": "Uniform", - "V": "Victor", - "W": "Whiskey", - "X": "X-ray", - "Y": "Yankee", - "Z": "Zulu", - "0": "Nadazero", - "1": "Unaone", - "2": "Bissotwo", - "3": "Terrathree", - "4": "Kartefour", - "5": "Pantafive", - "6": "Soxisix", - "7": "Setteseven", - "8": "Oktoeight", - "9": "Novenine", - ",": "Comma", - "/": "Forward slash", - ".": "Stop/Decimal", - }, - "german": { - "A": "Aachen", - "Ä": "Umlaut Aachen", - "B": "Berlin", - "C": "Chemnitz", - "D": "Düsseldorf", - "E": "Essen", - "F": "Frankfurt", - "G": "Goslar", - "H": "Hamburg", - "I": "Ingelheim", - "J": "Jena", - "K": "Köln", - "L": "Leipzig", - "M": "München", - "N": "Nürnberg", - "O": "Offenbach", - "Ö": "Umlaut Offenbach", - "P": "Potsdam", - "Q": "Quickborn", - "R": "Rostock", - "S": "Salzwedel", - "ẞ": "Eszett", - "T": "Tübingen", - "U": "Unna", - "Ü": "Umlaut Unna", - "V": "Völklingen", - "W": "Wuppertal", - "X": "Xanten", - "Y": "Ypsilon", - "Z": "Zwickau", - }, -} - - -def str_to_telephony(phrase, language): - language_alphabet = alphabet[language] - - return [ - language_alphabet[c] if c in language_alphabet else c for c in phrase.upper() - ] - - -language = sys.argv[1] -if language not in ["nato", "german"]: - print( - f"Langugae '{language}' is not a valid language, only 'nato' and 'german' are!", - file=sys.stderr, - ) - exit(1) - -print( - "\n".join( - str_to_telephony( - " ".join(sys.argv[2:]), - language, - ) - ) -) diff --git a/hm/soispha/pkgs/scripts/small_functions/nato.py b/hm/soispha/pkgs/scripts/small_functions/nato.py new file mode 100755 index 00000000..e9d15f56 --- /dev/null +++ b/hm/soispha/pkgs/scripts/small_functions/nato.py @@ -0,0 +1,106 @@ +#!/usr/bin/env python3 +# originally from here: https://cgit.pacien.net/desktop-utilities/ + +import sys + +alphabet = { + "nato": { + "A": "Alfa", # No idea why this is not just 'Alpha' .. + "B": "Bravo", + "C": "Charlie", + "D": "Delta", + "E": "Echo", + "F": "Foxtrot", + "G": "Golf", + "H": "Hotel", + "I": "India", + "J": "Juliett", + "K": "Kilo", + "L": "Lima", + "M": "Mike", + "N": "November", + "O": "Oscar", + "P": "Papa", + "Q": "Quebec", + "R": "Romeo", + "S": "Sierra", + "T": "Tango", + "U": "Uniform", + "V": "Victor", + "W": "Whiskey", + "X": "X-ray", + "Y": "Yankee", + "Z": "Zulu", + "0": "Nadazero", + "1": "Unaone", + "2": "Bissotwo", + "3": "Terrathree", + "4": "Kartefour", + "5": "Pantafive", + "6": "Soxisix", + "7": "Setteseven", + "8": "Oktoeight", + "9": "Novenine", + ",": "Comma", + "/": "Forward slash", + ".": "Stop/Decimal", + }, + "german": { + "A": "Aachen", + "Ä": "Umlaut Aachen", + "B": "Berlin", + "C": "Chemnitz", + "D": "Düsseldorf", + "E": "Essen", + "F": "Frankfurt", + "G": "Goslar", + "H": "Hamburg", + "I": "Ingelheim", + "J": "Jena", + "K": "Köln", + "L": "Leipzig", + "M": "München", + "N": "Nürnberg", + "O": "Offenbach", + "Ö": "Umlaut Offenbach", + "P": "Potsdam", + "Q": "Quickborn", + "R": "Rostock", + "S": "Salzwedel", + "ẞ": "Eszett", + "T": "Tübingen", + "U": "Unna", + "Ü": "Umlaut Unna", + "V": "Völklingen", + "W": "Wuppertal", + "X": "Xanten", + "Y": "Ypsilon", + "Z": "Zwickau", + }, +} + + +def str_to_telephony(phrase, language): + language_alphabet = alphabet[language] + + return [ + language_alphabet[c] if c in language_alphabet else c for c in phrase.upper() + ] + + +language = sys.argv[1] +if language not in ["nato", "german"]: + print( + f"Langugae '{language}' is not a valid language, only 'nato' and 'german' are!", + file=sys.stderr, + ) + exit(1) + +print( + "\n".join( + str_to_telephony( + " ".join(sys.argv[2:]), + language, + ) + ) +) diff --git a/hm/soispha/pkgs/scripts/small_functions/screenshot_persistent b/hm/soispha/pkgs/scripts/small_functions/screenshot_persistent deleted file mode 100755 index 9e73bed3..00000000 --- a/hm/soispha/pkgs/scripts/small_functions/screenshot_persistent +++ /dev/null @@ -1,25 +0,0 @@ -#! /usr/bin/env dash - -# shellcheck source=/dev/null -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 - 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"; - done - - 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/screenshot_persistent.sh b/hm/soispha/pkgs/scripts/small_functions/screenshot_persistent.sh new file mode 100755 index 00000000..9e73bed3 --- /dev/null +++ b/hm/soispha/pkgs/scripts/small_functions/screenshot_persistent.sh @@ -0,0 +1,25 @@ +#! /usr/bin/env dash + +# shellcheck source=/dev/null +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 + 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"; + done + + 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/screenshot_temporary b/hm/soispha/pkgs/scripts/small_functions/screenshot_temporary deleted file mode 100755 index e411340d..00000000 --- a/hm/soispha/pkgs/scripts/small_functions/screenshot_temporary +++ /dev/null @@ -1,8 +0,0 @@ -#! /usr/bin/env dash - -# shellcheck source=/dev/null -SHELL_LIBRARY_VERSION="2.0.13" . %SHELL_LIBRARY_PATH - -grim -g "$(slurp)" | wl-copy - -# vim: ft=sh diff --git a/hm/soispha/pkgs/scripts/small_functions/screenshot_temporary.sh b/hm/soispha/pkgs/scripts/small_functions/screenshot_temporary.sh new file mode 100755 index 00000000..e411340d --- /dev/null +++ b/hm/soispha/pkgs/scripts/small_functions/screenshot_temporary.sh @@ -0,0 +1,8 @@ +#! /usr/bin/env dash + +# shellcheck source=/dev/null +SHELL_LIBRARY_VERSION="2.0.13" . %SHELL_LIBRARY_PATH + +grim -g "$(slurp)" | wl-copy + +# vim: ft=sh diff --git a/hm/soispha/pkgs/scripts/small_functions/update-sys b/hm/soispha/pkgs/scripts/small_functions/update-sys deleted file mode 100755 index 20e38841..00000000 --- a/hm/soispha/pkgs/scripts/small_functions/update-sys +++ /dev/null @@ -1,78 +0,0 @@ -#!/usr/bin/env dash - -# shellcheck source=/dev/null -SHELL_LIBRARY_VERSION="2.0.13" . %SHELL_LIBRARY_PATH - -help() { - cat << EOF -This is a NixOS System flake update manager. - -Usage: - $NAME [--branch ] [--help] - -Options: - --branch | -b BRANCHNAME - select a branch to update from. - --mode | -m MODE - select a mode to update with - --help | -h - output this help. -EOF - exit "$1"; -} -default_branch=$(mktmp); -BRANCH=""; - -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; - ;; - 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'"; -fi -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" & - -msg2 "Updating system..."; -if [ -n "$MODE" ]; then - nixos-rebuild "$MODE"; -else - nixos-rebuild switch; -fi - -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/small_functions/update-sys.sh b/hm/soispha/pkgs/scripts/small_functions/update-sys.sh new file mode 100755 index 00000000..20e38841 --- /dev/null +++ b/hm/soispha/pkgs/scripts/small_functions/update-sys.sh @@ -0,0 +1,78 @@ +#!/usr/bin/env dash + +# shellcheck source=/dev/null +SHELL_LIBRARY_VERSION="2.0.13" . %SHELL_LIBRARY_PATH + +help() { + cat << EOF +This is a NixOS System flake update manager. + +Usage: + $NAME [--branch ] [--help] + +Options: + --branch | -b BRANCHNAME + select a branch to update from. + --mode | -m MODE + select a mode to update with + --help | -h + output this help. +EOF + exit "$1"; +} +default_branch=$(mktmp); +BRANCH=""; + +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; + ;; + 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'"; +fi +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" & + +msg2 "Updating system..."; +if [ -n "$MODE" ]; then + nixos-rebuild "$MODE"; +else + nixos-rebuild switch; +fi + +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/sh/functions/add b/hm/soispha/pkgs/scripts/specific/neorg/sh/functions/add deleted file mode 100755 index bd700775..00000000 --- a/hm/soispha/pkgs/scripts/specific/neorg/sh/functions/add +++ /dev/null @@ -1,23 +0,0 @@ -#!/usr/bin/env dash - -add0open_taskwarrior_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" ] || die "(BUG): No git directory?" - cd "$git_dir" || die "Unreachable, this MUST exists" - - 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; - - # 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" - 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 new file mode 100755 index 00000000..bd700775 --- /dev/null +++ b/hm/soispha/pkgs/scripts/specific/neorg/sh/functions/add.sh @@ -0,0 +1,23 @@ +#!/usr/bin/env dash + +add0open_taskwarrior_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" ] || die "(BUG): No git directory?" + cd "$git_dir" || die "Unreachable, this MUST exists" + + 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; + + # 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" + fi +} diff --git a/hm/soispha/pkgs/scripts/specific/neorg/sh/functions/context b/hm/soispha/pkgs/scripts/specific/neorg/sh/functions/context deleted file mode 100755 index b9ae4463..00000000 --- a/hm/soispha/pkgs/scripts/specific/neorg/sh/functions/context +++ /dev/null @@ -1,43 +0,0 @@ -#!/usr/bin/env dash - -context0open_current_task_context() { - 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)"; - cd "$extended_neorg_project_dir" || die "(BUG?): Can not access the project dir: $extended_neorg_project_dir"; - - nvim "$extended_neorg_project_dir/$context_path"; - - git add .; - git commit --message="chore($(dirname "$context_path")): Update" --no-gpg-sign - else - warn "No context active"; - fi -} - -context0open_current_task_context_at_task_id() { - 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)"; - task_uuid="$(task "$task_id" uuids)" - - 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" - fi - - nvim "$extended_neorg_project_dir/$context_path" -c "/% $task_uuid"; - - git add .; - git commit --message="chore($(dirname "$context_path")): Update" --no-gpg-sign - else - warn "No context active"; - 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 new file mode 100755 index 00000000..b9ae4463 --- /dev/null +++ b/hm/soispha/pkgs/scripts/specific/neorg/sh/functions/context.sh @@ -0,0 +1,43 @@ +#!/usr/bin/env dash + +context0open_current_task_context() { + 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)"; + cd "$extended_neorg_project_dir" || die "(BUG?): Can not access the project dir: $extended_neorg_project_dir"; + + nvim "$extended_neorg_project_dir/$context_path"; + + git add .; + git commit --message="chore($(dirname "$context_path")): Update" --no-gpg-sign + else + warn "No context active"; + fi +} + +context0open_current_task_context_at_task_id() { + 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)"; + task_uuid="$(task "$task_id" uuids)" + + 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" + fi + + nvim "$extended_neorg_project_dir/$context_path" -c "/% $task_uuid"; + + git add .; + git commit --message="chore($(dirname "$context_path")): Update" --no-gpg-sign + else + warn "No context active"; + fi +} diff --git a/hm/soispha/pkgs/scripts/specific/neorg/sh/functions/dmenu b/hm/soispha/pkgs/scripts/specific/neorg/sh/functions/dmenu deleted file mode 100755 index 36133004..00000000 --- a/hm/soispha/pkgs/scripts/specific/neorg/sh/functions/dmenu +++ /dev/null @@ -1,12 +0,0 @@ -#!/usr/bin/env dash - -dmenu0open_context_in_browser() { - project="$(echo "%ALL_PROJECTS_PIPE" | rofi -sep "|" -dmenu)"; - - if [ "$project" ]; then - project0open_project_in_browser "$project"; - else - notify-send "(neorg/dmenu) No project selected"; - exit 1 - 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 new file mode 100755 index 00000000..36133004 --- /dev/null +++ b/hm/soispha/pkgs/scripts/specific/neorg/sh/functions/dmenu.sh @@ -0,0 +1,12 @@ +#!/usr/bin/env dash + +dmenu0open_context_in_browser() { + project="$(echo "%ALL_PROJECTS_PIPE" | rofi -sep "|" -dmenu)"; + + if [ "$project" ]; then + project0open_project_in_browser "$project"; + else + notify-send "(neorg/dmenu) No project selected"; + exit 1 + fi +} diff --git a/hm/soispha/pkgs/scripts/specific/neorg/sh/functions/f_start b/hm/soispha/pkgs/scripts/specific/neorg/sh/functions/f_start deleted file mode 100755 index c75986a7..00000000 --- a/hm/soispha/pkgs/scripts/specific/neorg/sh/functions/f_start +++ /dev/null @@ -1,7 +0,0 @@ -#!/usr/bin/env dash - -fstart0start_new_task() { - task_id="$1"; - fstop0stop_current_task; - task start "$task_id" -} 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 new file mode 100755 index 00000000..c75986a7 --- /dev/null +++ b/hm/soispha/pkgs/scripts/specific/neorg/sh/functions/f_start.sh @@ -0,0 +1,7 @@ +#!/usr/bin/env dash + +fstart0start_new_task() { + task_id="$1"; + fstop0stop_current_task; + task start "$task_id" +} diff --git a/hm/soispha/pkgs/scripts/specific/neorg/sh/functions/f_stop b/hm/soispha/pkgs/scripts/specific/neorg/sh/functions/f_stop deleted file mode 100755 index d60cb46f..00000000 --- a/hm/soispha/pkgs/scripts/specific/neorg/sh/functions/f_stop +++ /dev/null @@ -1,7 +0,0 @@ -#!/usr/bin/env dash - -fstop0stop_current_task() { - # we ensured that only one task may be active - active="$(task +ACTIVE _ids)"; - [ "$active" ] && task stop "$active"; -} 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 new file mode 100755 index 00000000..d60cb46f --- /dev/null +++ b/hm/soispha/pkgs/scripts/specific/neorg/sh/functions/f_stop.sh @@ -0,0 +1,7 @@ +#!/usr/bin/env dash + +fstop0stop_current_task() { + # we ensured that only one task may be active + active="$(task +ACTIVE _ids)"; + [ "$active" ] && task stop "$active"; +} diff --git a/hm/soispha/pkgs/scripts/specific/neorg/sh/functions/list b/hm/soispha/pkgs/scripts/specific/neorg/sh/functions/list deleted file mode 100755 index 10659457..00000000 --- a/hm/soispha/pkgs/scripts/specific/neorg/sh/functions/list +++ /dev/null @@ -1,8 +0,0 @@ -#!/usr/bin/env dash - -list0list_all_contexts_newline() { - print "%ALL_PROJECTS_NEWLINE" -} -list0list_all_contexts_comma() { - print "%ALL_PROJECTS_COMMA" -} diff --git a/hm/soispha/pkgs/scripts/specific/neorg/sh/functions/list.sh b/hm/soispha/pkgs/scripts/specific/neorg/sh/functions/list.sh new file mode 100755 index 00000000..10659457 --- /dev/null +++ b/hm/soispha/pkgs/scripts/specific/neorg/sh/functions/list.sh @@ -0,0 +1,8 @@ +#!/usr/bin/env dash + +list0list_all_contexts_newline() { + print "%ALL_PROJECTS_NEWLINE" +} +list0list_all_contexts_comma() { + print "%ALL_PROJECTS_COMMA" +} diff --git a/hm/soispha/pkgs/scripts/specific/neorg/sh/functions/project b/hm/soispha/pkgs/scripts/specific/neorg/sh/functions/project deleted file mode 100755 index 8def0930..00000000 --- a/hm/soispha/pkgs/scripts/specific/neorg/sh/functions/project +++ /dev/null @@ -1,42 +0,0 @@ -#!/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")"; -} - -project0open_project_in_browser() { - project="$1"; - [ "$project" ] || die "BUG: No context supplied to project0open_context_in_browser" - - old_context="$(utils0get_current_context)"; - # We have ensured that only one task may be active - old_started_task="$(task +ACTIVE _ids)"; - - 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}' )"; - if [ "$desc" = "tracking" ]; then - task_id="$(echo "$description" | awk -F: '{print $1}' )"; - notify-send "(Neorg)" "Starting task $project -> $desc"; - task start "$task_id" - break - fi - done < "$tracking" - - - firefox -P "$project" - - task stop "$task_id" - [ "$old_started_task" ] && task start "$old_started_task" - - if [ "$old_context" ]; then - task context "$old_context" - else - task context none - fi -} diff --git a/hm/soispha/pkgs/scripts/specific/neorg/sh/functions/project.sh b/hm/soispha/pkgs/scripts/specific/neorg/sh/functions/project.sh new file mode 100755 index 00000000..8def0930 --- /dev/null +++ b/hm/soispha/pkgs/scripts/specific/neorg/sh/functions/project.sh @@ -0,0 +1,42 @@ +#!/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")"; +} + +project0open_project_in_browser() { + project="$1"; + [ "$project" ] || die "BUG: No context supplied to project0open_context_in_browser" + + old_context="$(utils0get_current_context)"; + # We have ensured that only one task may be active + old_started_task="$(task +ACTIVE _ids)"; + + 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}' )"; + if [ "$desc" = "tracking" ]; then + task_id="$(echo "$description" | awk -F: '{print $1}' )"; + notify-send "(Neorg)" "Starting task $project -> $desc"; + task start "$task_id" + break + fi + done < "$tracking" + + + firefox -P "$project" + + task stop "$task_id" + [ "$old_started_task" ] && task start "$old_started_task" + + if [ "$old_context" ]; then + task context "$old_context" + else + task context none + fi +} diff --git a/hm/soispha/pkgs/scripts/specific/neorg/sh/functions/utils b/hm/soispha/pkgs/scripts/specific/neorg/sh/functions/utils deleted file mode 100755 index 91da811a..00000000 --- a/hm/soispha/pkgs/scripts/specific/neorg/sh/functions/utils +++ /dev/null @@ -1,40 +0,0 @@ -#!/usr/bin/env dash - -# Runs it's first argument and then the second, regardless if the first failed or -# succeeded -utils0chain() { - eval "$1"; eval "$2" -} - -utils0get_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)"; - if ! [ "$context_path" ]; then - 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" -} - -utils0get_neorg_project_dir() { - # Perform shell expansion of Tilde - 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"; -} -utils0context2project() { - context="$1"; - project="$(sed 's|_|\.|g' "$(ptmp "$context")")"; - printf "%s\n" "$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 new file mode 100755 index 00000000..91da811a --- /dev/null +++ b/hm/soispha/pkgs/scripts/specific/neorg/sh/functions/utils.sh @@ -0,0 +1,40 @@ +#!/usr/bin/env dash + +# Runs it's first argument and then the second, regardless if the first failed or +# succeeded +utils0chain() { + eval "$1"; eval "$2" +} + +utils0get_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)"; + if ! [ "$context_path" ]; then + 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" +} + +utils0get_neorg_project_dir() { + # Perform shell expansion of Tilde + 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"; +} +utils0context2project() { + context="$1"; + project="$(sed 's|_|\.|g' "$(ptmp "$context")")"; + printf "%s\n" "$project"; +} diff --git a/hm/soispha/pkgs/scripts/specific/neorg/sh/functions/workspace b/hm/soispha/pkgs/scripts/specific/neorg/sh/functions/workspace deleted file mode 100755 index d5eb2fca..00000000 --- a/hm/soispha/pkgs/scripts/specific/neorg/sh/functions/workspace +++ /dev/null @@ -1,9 +0,0 @@ -#!/usr/bin/env dash - -workspace0open_neorg_workspace() { - workspace="$1" - nvim -c "NeorgStart" -s "$(ptmp ":Neorg workspace $workspace\n")" -} -workspace0open_neorg_workspace_prompt() { - nvim -c "NeorgStart" -s "$(ptmp ":Neorg workspace ")" -} diff --git a/hm/soispha/pkgs/scripts/specific/neorg/sh/functions/workspace.sh b/hm/soispha/pkgs/scripts/specific/neorg/sh/functions/workspace.sh new file mode 100755 index 00000000..d5eb2fca --- /dev/null +++ b/hm/soispha/pkgs/scripts/specific/neorg/sh/functions/workspace.sh @@ -0,0 +1,9 @@ +#!/usr/bin/env dash + +workspace0open_neorg_workspace() { + workspace="$1" + nvim -c "NeorgStart" -s "$(ptmp ":Neorg workspace $workspace\n")" +} +workspace0open_neorg_workspace_prompt() { + nvim -c "NeorgStart" -s "$(ptmp ":Neorg workspace ")" +} diff --git a/hm/soispha/pkgs/scripts/specific/neorg/sh/main b/hm/soispha/pkgs/scripts/specific/neorg/sh/main deleted file mode 100755 index 25b434fc..00000000 --- a/hm/soispha/pkgs/scripts/specific/neorg/sh/main +++ /dev/null @@ -1,156 +0,0 @@ -#!/usr/bin/env dash - -# shellcheck source=/dev/null -SHELL_LIBRARY_VERSION="2.0.13" . %SHELL_LIBRARY_PATH - -# load dependencies -. ./functions/add -. ./functions/context -. ./functions/dmenu -. ./functions/f_start -. ./functions/f_stop -. ./functions/list -. ./functions/project -. ./functions/utils -. ./functions/workspace - - -# these are used in version() -# shellcheck disable=2034 -AUTHORS="Soispha" -# shellcheck disable=2034 -YEARS="2023" - -NAME="neorg" - -help() { -cat << EOF -This is the core interface to the system-integrated task management - -USAGE: - $NAME [OPTIONS] [COMMAND] - -OPTIONS: - --help | -h - Display this help and exit. - - --version | -v - Display version and copyright information and exit. -COMMANDS: - task [ID] - Open the neorg context associated with the current context and - the uuid of the task with id ID. Without ID, it'll open the - current context's norg file. - If no context is set, drops you to the selection prompt - - dmenu - Select a project in dmenu mode. This will give you all projects - and exectute the selected one as in 'neorg projects ' - - workspace [WS] - The neorg workspace (WS) to open at startup, an empty value drops - you at a prompt to enter the workspace yourself. - - project [P] - Opens the webbrowser with either the context (P) or - the current active context as argument if no context is supplied - - list - Lists all available contexts - - add - Allows you to quickly add projects - - fstart ID - Starts the task (ID) but only after it stooped - the previous active task, if it existed. - - fstop - Stops the current active task -ARGUMENTS: - ID | *([0-9]) := [[%ID_GENERATION_FUNCTION]] - The function displays all possible IDs of the eligable tasks. - - WS := %ALL_WORKSPACES - All possible workspaces - - P := %ALL_PROJECTS_PIPE - The possible project - -EOF -} - -for arg in "$@"; do - case "$arg" in - "--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; - ;; - esac -done - -context0open_current_task_context; -# vim: ft=sh diff --git a/hm/soispha/pkgs/scripts/specific/neorg/sh/main.sh b/hm/soispha/pkgs/scripts/specific/neorg/sh/main.sh new file mode 100755 index 00000000..25b434fc --- /dev/null +++ b/hm/soispha/pkgs/scripts/specific/neorg/sh/main.sh @@ -0,0 +1,156 @@ +#!/usr/bin/env dash + +# shellcheck source=/dev/null +SHELL_LIBRARY_VERSION="2.0.13" . %SHELL_LIBRARY_PATH + +# load dependencies +. ./functions/add +. ./functions/context +. ./functions/dmenu +. ./functions/f_start +. ./functions/f_stop +. ./functions/list +. ./functions/project +. ./functions/utils +. ./functions/workspace + + +# these are used in version() +# shellcheck disable=2034 +AUTHORS="Soispha" +# shellcheck disable=2034 +YEARS="2023" + +NAME="neorg" + +help() { +cat << EOF +This is the core interface to the system-integrated task management + +USAGE: + $NAME [OPTIONS] [COMMAND] + +OPTIONS: + --help | -h + Display this help and exit. + + --version | -v + Display version and copyright information and exit. +COMMANDS: + task [ID] + Open the neorg context associated with the current context and + the uuid of the task with id ID. Without ID, it'll open the + current context's norg file. + If no context is set, drops you to the selection prompt + + dmenu + Select a project in dmenu mode. This will give you all projects + and exectute the selected one as in 'neorg projects ' + + workspace [WS] + The neorg workspace (WS) to open at startup, an empty value drops + you at a prompt to enter the workspace yourself. + + project [P] + Opens the webbrowser with either the context (P) or + the current active context as argument if no context is supplied + + list + Lists all available contexts + + add + Allows you to quickly add projects + + fstart ID + Starts the task (ID) but only after it stooped + the previous active task, if it existed. + + fstop + Stops the current active task +ARGUMENTS: + ID | *([0-9]) := [[%ID_GENERATION_FUNCTION]] + The function displays all possible IDs of the eligable tasks. + + WS := %ALL_WORKSPACES + All possible workspaces + + P := %ALL_PROJECTS_PIPE + The possible project + +EOF +} + +for arg in "$@"; do + case "$arg" in + "--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; + ;; + esac +done + +context0open_current_task_context; +# vim: ft=sh diff --git a/hm/soispha/pkgs/scripts/specific/ytcc/description b/hm/soispha/pkgs/scripts/specific/ytcc/description deleted file mode 100755 index e2a1afaa..00000000 --- a/hm/soispha/pkgs/scripts/specific/ytcc/description +++ /dev/null @@ -1,8 +0,0 @@ -#!/usr/bin/env dash - -# shellcheck source=/dev/null -SHELL_LIBRARY_VERSION="2.0.13" . %SHELL_LIBRARY_PATH - -jq --raw-output '.description' "$XDG_RUNTIME_DIR/ytcc/running" | fmt -u -s | less - -# vim: ft=sh diff --git a/hm/soispha/pkgs/scripts/specific/ytcc/description.sh b/hm/soispha/pkgs/scripts/specific/ytcc/description.sh new file mode 100755 index 00000000..e2a1afaa --- /dev/null +++ b/hm/soispha/pkgs/scripts/specific/ytcc/description.sh @@ -0,0 +1,8 @@ +#!/usr/bin/env dash + +# shellcheck source=/dev/null +SHELL_LIBRARY_VERSION="2.0.13" . %SHELL_LIBRARY_PATH + +jq --raw-output '.description' "$XDG_RUNTIME_DIR/ytcc/running" | fmt -u -s | less + +# vim: ft=sh diff --git a/hm/soispha/pkgs/scripts/wrappers/hibernate b/hm/soispha/pkgs/scripts/wrappers/hibernate deleted file mode 100755 index 96170bcb..00000000 --- a/hm/soispha/pkgs/scripts/wrappers/hibernate +++ /dev/null @@ -1,16 +0,0 @@ -#!/usr/bin/env dash - -# shellcheck source=/dev/null -SHELL_LIBRARY_VERSION="2.0.13" . %SHELL_LIBRARY_PATH - -context="$(task _get rc.context)"; -[ "$context" ] && task context none - -# We have ensured that only one task is active -active="$(task +ACTIVE _ids)"; -[ "$active" ] && task stop "$active" - -systemctl hibernate "$@" - - -# vim: ft=sh diff --git a/hm/soispha/pkgs/scripts/wrappers/hibernate.sh b/hm/soispha/pkgs/scripts/wrappers/hibernate.sh new file mode 100755 index 00000000..96170bcb --- /dev/null +++ b/hm/soispha/pkgs/scripts/wrappers/hibernate.sh @@ -0,0 +1,16 @@ +#!/usr/bin/env dash + +# shellcheck source=/dev/null +SHELL_LIBRARY_VERSION="2.0.13" . %SHELL_LIBRARY_PATH + +context="$(task _get rc.context)"; +[ "$context" ] && task context none + +# We have ensured that only one task is active +active="$(task +ACTIVE _ids)"; +[ "$active" ] && task stop "$active" + +systemctl hibernate "$@" + + +# vim: ft=sh diff --git a/hm/soispha/pkgs/scripts/wrappers/ll b/hm/soispha/pkgs/scripts/wrappers/ll deleted file mode 100755 index 2a65d0a6..00000000 --- a/hm/soispha/pkgs/scripts/wrappers/ll +++ /dev/null @@ -1,14 +0,0 @@ -#!/usr/bin/env dash - -# shellcheck source=/dev/null -SHELL_LIBRARY_VERSION="2.0.13" . %SHELL_LIBRARY_PATH - -last_directory="$(mktemp)" - -command lf -last-dir-path="$last_directory" "$@" - -dir="$(cat "$last_directory")" -cd "$dir" || die "$dir does not exist!" -rm "$last_directory" - -# vim: ft=sh diff --git a/hm/soispha/pkgs/scripts/wrappers/ll.sh b/hm/soispha/pkgs/scripts/wrappers/ll.sh new file mode 100755 index 00000000..2a65d0a6 --- /dev/null +++ b/hm/soispha/pkgs/scripts/wrappers/ll.sh @@ -0,0 +1,14 @@ +#!/usr/bin/env dash + +# shellcheck source=/dev/null +SHELL_LIBRARY_VERSION="2.0.13" . %SHELL_LIBRARY_PATH + +last_directory="$(mktemp)" + +command lf -last-dir-path="$last_directory" "$@" + +dir="$(cat "$last_directory")" +cd "$dir" || die "$dir does not exist!" +rm "$last_directory" + +# vim: ft=sh diff --git a/hm/soispha/pkgs/scripts/wrappers/lock b/hm/soispha/pkgs/scripts/wrappers/lock deleted file mode 100755 index 376773c6..00000000 --- a/hm/soispha/pkgs/scripts/wrappers/lock +++ /dev/null @@ -1,19 +0,0 @@ -#!/usr/bin/env dash - -# shellcheck source=/dev/null -SHELL_LIBRARY_VERSION="2.0.13" . %SHELL_LIBRARY_PATH - - -context="$(task _get rc.context)"; -[ "$context" ] && task context none - -# We have ensured that only one task is active -active="$(task +ACTIVE _ids)"; -[ "$active" ] && task stop "$active" - -swaylock - -[ "$active" ] && task start "$active" - -[ "$context" ] && task context "$context" -# vim: ft=sh diff --git a/hm/soispha/pkgs/scripts/wrappers/lock.sh b/hm/soispha/pkgs/scripts/wrappers/lock.sh new file mode 100755 index 00000000..376773c6 --- /dev/null +++ b/hm/soispha/pkgs/scripts/wrappers/lock.sh @@ -0,0 +1,19 @@ +#!/usr/bin/env dash + +# shellcheck source=/dev/null +SHELL_LIBRARY_VERSION="2.0.13" . %SHELL_LIBRARY_PATH + + +context="$(task _get rc.context)"; +[ "$context" ] && task context none + +# We have ensured that only one task is active +active="$(task +ACTIVE _ids)"; +[ "$active" ] && task stop "$active" + +swaylock + +[ "$active" ] && task start "$active" + +[ "$context" ] && task context "$context" +# vim: ft=sh diff --git a/hm/soispha/pkgs/scripts/wrappers/lyrics b/hm/soispha/pkgs/scripts/wrappers/lyrics deleted file mode 100755 index 83a01083..00000000 --- a/hm/soispha/pkgs/scripts/wrappers/lyrics +++ /dev/null @@ -1,11 +0,0 @@ -#!/usr/bin/env dash - -# shellcheck source=/dev/null -SHELL_LIBRARY_VERSION="2.0.13" . %SHELL_LIBRARY_PATH - -( - cd "$XDG_MUSIC_DIR" || die "No music dir!" - exiftool "$(mpc --format '%file%' current)" -json | jq '.[0].Lyrics' -r | less -) - -# vim: ft=sh diff --git a/hm/soispha/pkgs/scripts/wrappers/lyrics.sh b/hm/soispha/pkgs/scripts/wrappers/lyrics.sh new file mode 100755 index 00000000..83a01083 --- /dev/null +++ b/hm/soispha/pkgs/scripts/wrappers/lyrics.sh @@ -0,0 +1,11 @@ +#!/usr/bin/env dash + +# shellcheck source=/dev/null +SHELL_LIBRARY_VERSION="2.0.13" . %SHELL_LIBRARY_PATH + +( + cd "$XDG_MUSIC_DIR" || die "No music dir!" + exiftool "$(mpc --format '%file%' current)" -json | jq '.[0].Lyrics' -r | less +) + +# vim: ft=sh diff --git a/hm/soispha/pkgs/scripts/wrappers/mpc-fav b/hm/soispha/pkgs/scripts/wrappers/mpc-fav deleted file mode 100755 index f9107ff6..00000000 --- a/hm/soispha/pkgs/scripts/wrappers/mpc-fav +++ /dev/null @@ -1,15 +0,0 @@ -#!/usr/bin/env dash - -# shellcheck source=/dev/null -SHELL_LIBRARY_VERSION="2.0.13" . %SHELL_LIBRARY_PATH - -FAV_DIR="$XDG_MUSIC_DIR/playlists/favourites"; - -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!"; - - -# vim: ft=sh diff --git a/hm/soispha/pkgs/scripts/wrappers/mpc-fav.sh b/hm/soispha/pkgs/scripts/wrappers/mpc-fav.sh new file mode 100755 index 00000000..f9107ff6 --- /dev/null +++ b/hm/soispha/pkgs/scripts/wrappers/mpc-fav.sh @@ -0,0 +1,15 @@ +#!/usr/bin/env dash + +# shellcheck source=/dev/null +SHELL_LIBRARY_VERSION="2.0.13" . %SHELL_LIBRARY_PATH + +FAV_DIR="$XDG_MUSIC_DIR/playlists/favourites"; + +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!"; + + +# vim: ft=sh diff --git a/hm/soispha/pkgs/scripts/wrappers/mpc-rm b/hm/soispha/pkgs/scripts/wrappers/mpc-rm deleted file mode 100755 index cc01c322..00000000 --- a/hm/soispha/pkgs/scripts/wrappers/mpc-rm +++ /dev/null @@ -1,14 +0,0 @@ -#!/usr/bin/env dash - -# 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; - - - - -# vim: ft=sh diff --git a/hm/soispha/pkgs/scripts/wrappers/mpc-rm.sh b/hm/soispha/pkgs/scripts/wrappers/mpc-rm.sh new file mode 100755 index 00000000..cc01c322 --- /dev/null +++ b/hm/soispha/pkgs/scripts/wrappers/mpc-rm.sh @@ -0,0 +1,14 @@ +#!/usr/bin/env dash + +# 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; + + + + +# vim: ft=sh diff --git a/hm/soispha/pkgs/scripts/wrappers/show b/hm/soispha/pkgs/scripts/wrappers/show deleted file mode 100755 index 95afb16c..00000000 --- a/hm/soispha/pkgs/scripts/wrappers/show +++ /dev/null @@ -1,9 +0,0 @@ -#!/usr/bin/env dash - -# shellcheck source=/dev/null -SHELL_LIBRARY_VERSION="2.0.13" . %SHELL_LIBRARY_PATH - -# Maybe add `--quit-if-one-screen` -less --redraw-on-quit "$@" - -# vim: ft=sh diff --git a/hm/soispha/pkgs/scripts/wrappers/show.sh b/hm/soispha/pkgs/scripts/wrappers/show.sh new file mode 100755 index 00000000..95afb16c --- /dev/null +++ b/hm/soispha/pkgs/scripts/wrappers/show.sh @@ -0,0 +1,9 @@ +#!/usr/bin/env dash + +# shellcheck source=/dev/null +SHELL_LIBRARY_VERSION="2.0.13" . %SHELL_LIBRARY_PATH + +# Maybe add `--quit-if-one-screen` +less --redraw-on-quit "$@" + +# vim: ft=sh diff --git a/hm/soispha/pkgs/scripts/wrappers/sort_song b/hm/soispha/pkgs/scripts/wrappers/sort_song deleted file mode 100755 index f539cf15..00000000 --- a/hm/soispha/pkgs/scripts/wrappers/sort_song +++ /dev/null @@ -1,33 +0,0 @@ -#!/usr/bin/env dash - -# 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'"; -esac - -process() { - mediainfo --Output=JSON "$1" | jq '.media.track | map(.Lyrics) | join("")' -}; - -mkdir "../$directory"; - -fd . --extension=opus | while read -r file; do - if [ "$(process "$file")" = '""' ] || [ "$(process "$file")" = '"Instrumental"' ] || [ "$(process "$file")" = '"instrumental"' ]; then - 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 - -# vim: ft=sh diff --git a/hm/soispha/pkgs/scripts/wrappers/sort_song.sh b/hm/soispha/pkgs/scripts/wrappers/sort_song.sh new file mode 100755 index 00000000..f539cf15 --- /dev/null +++ b/hm/soispha/pkgs/scripts/wrappers/sort_song.sh @@ -0,0 +1,33 @@ +#!/usr/bin/env dash + +# 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'"; +esac + +process() { + mediainfo --Output=JSON "$1" | jq '.media.track | map(.Lyrics) | join("")' +}; + +mkdir "../$directory"; + +fd . --extension=opus | while read -r file; do + if [ "$(process "$file")" = '""' ] || [ "$(process "$file")" = '"Instrumental"' ] || [ "$(process "$file")" = '"instrumental"' ]; then + 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 + +# vim: ft=sh diff --git a/hm/soispha/pkgs/scripts/wrappers/spodi b/hm/soispha/pkgs/scripts/wrappers/spodi deleted file mode 100755 index f8bc5337..00000000 --- a/hm/soispha/pkgs/scripts/wrappers/spodi +++ /dev/null @@ -1,58 +0,0 @@ -#!/usr/bin/env dash - -# shellcheck source=/dev/null -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"; - - - -already_downloaded_files="$(mktmp)" -fd . "$DOWN_DIR" --exclude spotdl.log --exclude spotdl-errors.log > "$already_downloaded_files"; - -config="$(mktmp)" -cat << EOF | clean > "$config" -# Main options ---audio slider-kz bandcamp youtube-music piped youtube soundcloud ---lyrics genius musixmatch azlyrics synced - -# FFmpeg options ---ffmpeg ffmpeg ---threads 16 ---bitrate 256k - -# Spotify options ---cache-path /home/soispha/.cache/spotdl/.spotipy - -# Output options ---preload ---format opus ---output {artists}_-_{title} ---print-errors ---save-errors $DOWN_DIR/spotdl-errors.log -# TODO: Reactive whence spotdl support for these has improved <2023-12-19> -# --generate-lrc ---overwrite skip - -# Misc options ---log-level INFO -EOF - -if [ -z "$NO_CHECK" ] && [ "$(wc -l < "$already_downloaded_files" )" -ne 0 ];then - die "something is already downloaded" -fi - -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" - -[ -d ~/.spotdl ] && rm -r ~/.spotdl -# vim: ft=sh diff --git a/hm/soispha/pkgs/scripts/wrappers/spodi.sh b/hm/soispha/pkgs/scripts/wrappers/spodi.sh new file mode 100755 index 00000000..f8bc5337 --- /dev/null +++ b/hm/soispha/pkgs/scripts/wrappers/spodi.sh @@ -0,0 +1,58 @@ +#!/usr/bin/env dash + +# shellcheck source=/dev/null +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"; + + + +already_downloaded_files="$(mktmp)" +fd . "$DOWN_DIR" --exclude spotdl.log --exclude spotdl-errors.log > "$already_downloaded_files"; + +config="$(mktmp)" +cat << EOF | clean > "$config" +# Main options +--audio slider-kz bandcamp youtube-music piped youtube soundcloud +--lyrics genius musixmatch azlyrics synced + +# FFmpeg options +--ffmpeg ffmpeg +--threads 16 +--bitrate 256k + +# Spotify options +--cache-path /home/soispha/.cache/spotdl/.spotipy + +# Output options +--preload +--format opus +--output {artists}_-_{title} +--print-errors +--save-errors $DOWN_DIR/spotdl-errors.log +# TODO: Reactive whence spotdl support for these has improved <2023-12-19> +# --generate-lrc +--overwrite skip + +# Misc options +--log-level INFO +EOF + +if [ -z "$NO_CHECK" ] && [ "$(wc -l < "$already_downloaded_files" )" -ne 0 ];then + die "something is already downloaded" +fi + +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" + +[ -d ~/.spotdl ] && rm -r ~/.spotdl +# vim: ft=sh diff --git a/hm/soispha/pkgs/scripts/wrappers/virsh-del b/hm/soispha/pkgs/scripts/wrappers/virsh-del deleted file mode 100755 index 96a9404d..00000000 --- a/hm/soispha/pkgs/scripts/wrappers/virsh-del +++ /dev/null @@ -1,10 +0,0 @@ -#! /usr/bin/env dash - -# shellcheck source=/dev/null -SHELL_LIBRARY_VERSION="2.0.13" . %SHELL_LIBRARY_PATH - -virsh destroy "$1" -virsh undefine "$1" --nvram -virsh vol-delete --pool default "$1".qcow2 - -# vim: ft=sh diff --git a/hm/soispha/pkgs/scripts/wrappers/virsh-del.sh b/hm/soispha/pkgs/scripts/wrappers/virsh-del.sh new file mode 100755 index 00000000..96a9404d --- /dev/null +++ b/hm/soispha/pkgs/scripts/wrappers/virsh-del.sh @@ -0,0 +1,10 @@ +#! /usr/bin/env dash + +# shellcheck source=/dev/null +SHELL_LIBRARY_VERSION="2.0.13" . %SHELL_LIBRARY_PATH + +virsh destroy "$1" +virsh undefine "$1" --nvram +virsh vol-delete --pool default "$1".qcow2 + +# vim: ft=sh diff --git a/hm/soispha/pkgs/scripts/wrappers/yti b/hm/soispha/pkgs/scripts/wrappers/yti deleted file mode 100755 index c07f6665..00000000 --- a/hm/soispha/pkgs/scripts/wrappers/yti +++ /dev/null @@ -1,34 +0,0 @@ -#! /usr/bin/env dash - -# shellcheck source=/dev/null -SHELL_LIBRARY_VERSION="2.0.13" . %SHELL_LIBRARY_PATH - -DOWN_DIR=/home/soispha/media/music/down/youtube - -tmp=$(mktmp) -config=$(mktmp) - -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" ---paths home:"$DOWN_DIR" -#--output %(fulltitle) ---restrict-filenames ---no-overwrites ---no-write-info-json ---clean-info-json ---prefer-free-formats -#--format mp3 ---extract-audio ---audio-quality 0 ---audio-format best -EO - - -rm "$DOWN_DIR/yt-dlp.log" -cd "$DOWN_DIR" || die "BUG: no $DOWN_DIR" - -unbuffer yt-dlp --config-location "$config" "$1" | tee "$DOWN_DIR/yt-dlp.log" - -# vim: ft=sh diff --git a/hm/soispha/pkgs/scripts/wrappers/yti.sh b/hm/soispha/pkgs/scripts/wrappers/yti.sh new file mode 100755 index 00000000..c07f6665 --- /dev/null +++ b/hm/soispha/pkgs/scripts/wrappers/yti.sh @@ -0,0 +1,34 @@ +#! /usr/bin/env dash + +# shellcheck source=/dev/null +SHELL_LIBRARY_VERSION="2.0.13" . %SHELL_LIBRARY_PATH + +DOWN_DIR=/home/soispha/media/music/down/youtube + +tmp=$(mktmp) +config=$(mktmp) + +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" +--paths home:"$DOWN_DIR" +#--output %(fulltitle) +--restrict-filenames +--no-overwrites +--no-write-info-json +--clean-info-json +--prefer-free-formats +#--format mp3 +--extract-audio +--audio-quality 0 +--audio-format best +EO + + +rm "$DOWN_DIR/yt-dlp.log" +cd "$DOWN_DIR" || die "BUG: no $DOWN_DIR" + +unbuffer yt-dlp --config-location "$config" "$1" | tee "$DOWN_DIR/yt-dlp.log" + +# vim: ft=sh diff --git a/hm/soispha/wms/river/default.nix b/hm/soispha/wms/river/default.nix index 3abe3753..36a9ca74 100644 --- a/hm/soispha/wms/river/default.nix +++ b/hm/soispha/wms/river/default.nix @@ -37,7 +37,7 @@ else builtins.throw "Host not covered in river screen setup"; env_vars = "XDG_CURRENT_DESKTOP=river DESKTOP_SESSION=river"; init_scr = pkgs.substituteAll { - src = ./init; + src = ./init.sh; inherit mappings screen_setup env_vars; }; in { diff --git a/hm/soispha/wms/river/init b/hm/soispha/wms/river/init deleted file mode 100755 index 7286318e..00000000 --- a/hm/soispha/wms/river/init +++ /dev/null @@ -1,81 +0,0 @@ -#!/usr/bin/env bash - -# shellcheck source=/dev/null -SHELL_LIBRARY_VERSION="2.0.13" . %SHELL_LIBRARY_PATH - -err_fail() { - if ! "$@";then - warning "\"$*\" failed!\n" >> ~/river_log - # msg "Executing the safe init!" - # exec ~/.config/river/res/safe_init - fi -} -err_fail rm ~/river_log -exec 1>> "$HOME"/river_log -exec 2>> "$HOME"/river_log - -#trap err_fail ERR - -#Setup of environment variables {{{ -err_fail riverctl spawn "exec dbus-update-activation-environment --systemd SEATD_SOCK DISPLAY WAYLAND_DISPLAY DESKTOP_SESSION=river XDG_CURRENT_DESKTOP=river" -export @env_vars@ -#}}} - -# Setup of mappings {{{ -@mappings@ -# }}} - -# Setup of Rules {{{ -err_fail riverctl float-filter-add app-id float -err_fail riverctl float-filter-add app-id mpv -err_fail riverctl float-filter-add app-id ModernGL -err_fail riverctl float-filter-add title "Manim Slides" -err_fail riverctl float-filter-add title 'floating please' - -err_fail riverctl csd-filter-add app-id firefox -# }}} - -# Set riverctl settings {{{ -# background -err_fail riverctl background-color 0x002b36 -err_fail riverctl border-color-focused 0x93a1a1 -err_fail riverctl border-color-unfocused 0x586e75 - -# keyboard repeat rate -err_fail riverctl set-repeat 50 300 - -# Cursor -err_fail riverctl focus-follows-cursor normal -#riverctl hide-cursor timeout 2000 -err_fail riverctl hide-cursor when-typing enabled -err_fail riverctl set-cursor-warp on-output-change -err_fail riverctl xcursor-theme Nordzy-cursors 24 - -err_fail riverctl input pointer-1133-49970-Logitech_Gaming_Mouse_G502 pointer-accel 0 -err_fail riverctl input pointer-1133-49970-Logitech_Gaming_Mouse_G502 accel-profile none - -err_fail riverctl input pointer-12951-6505-ZSA_Technology_Labs_Moonlander_Mark_I pointer-accel 0 -err_fail riverctl input pointer-12951-6505-ZSA_Technology_Labs_Moonlander_Mark_I accel-profile none -# }}} - -# Setup of general apps {{{ -@screen_setup@ - -err_fail yambar & - -err_fail mako & -err_fail swaybg -i "$WALLPAPER" & -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 - -#riverctl default-layout luatile -#river-luatile -# }}} -# vim: ft=sh diff --git a/hm/soispha/wms/river/init.sh b/hm/soispha/wms/river/init.sh new file mode 100755 index 00000000..07b30732 --- /dev/null +++ b/hm/soispha/wms/river/init.sh @@ -0,0 +1,81 @@ +#!/usr/bin/env bash + +# shellcheck source=/dev/null +SHELL_LIBRARY_VERSION="2.0.13" . %SHELL_LIBRARY_PATH + +err_fail() { + 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 + +#trap err_fail ERR + +#Setup of environment variables {{{ +err_fail riverctl spawn "exec dbus-update-activation-environment --systemd SEATD_SOCK DISPLAY WAYLAND_DISPLAY DESKTOP_SESSION=river XDG_CURRENT_DESKTOP=river" +export @env_vars@ +#}}} + +# Setup of mappings {{{ +@mappings@ +# }}} + +# Setup of Rules {{{ +err_fail riverctl float-filter-add app-id float +err_fail riverctl float-filter-add app-id mpv +err_fail riverctl float-filter-add app-id ModernGL +err_fail riverctl float-filter-add title "Manim Slides" +err_fail riverctl float-filter-add title 'floating please' + +err_fail riverctl csd-filter-add app-id firefox +# }}} + +# Set riverctl settings {{{ +# background +err_fail riverctl background-color 0x002b36 +err_fail riverctl border-color-focused 0x93a1a1 +err_fail riverctl border-color-unfocused 0x586e75 + +# keyboard repeat rate +err_fail riverctl set-repeat 50 300 + +# Cursor +err_fail riverctl focus-follows-cursor normal +#riverctl hide-cursor timeout 2000 +err_fail riverctl hide-cursor when-typing enabled +err_fail riverctl set-cursor-warp on-output-change +err_fail riverctl xcursor-theme Nordzy-cursors 24 + +err_fail riverctl input pointer-1133-49970-Logitech_Gaming_Mouse_G502 pointer-accel 0 +err_fail riverctl input pointer-1133-49970-Logitech_Gaming_Mouse_G502 accel-profile none + +err_fail riverctl input pointer-12951-6505-ZSA_Technology_Labs_Moonlander_Mark_I pointer-accel 0 +err_fail riverctl input pointer-12951-6505-ZSA_Technology_Labs_Moonlander_Mark_I accel-profile none +# }}} + +# Setup of general apps {{{ +@screen_setup@ + +err_fail yambar & + +err_fail mako & +err_fail swaybg -i "$WALLPAPER" & +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 + +#riverctl default-layout luatile +#river-luatile +# }}} +# vim: ft=sh diff --git a/hm/soispha/wms/river/res/safe_init b/hm/soispha/wms/river/res/safe_init deleted file mode 100755 index 8e80026a..00000000 --- a/hm/soispha/wms/river/res/safe_init +++ /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 diff --git a/hm/soispha/wms/river/res/safe_init.sh b/hm/soispha/wms/river/res/safe_init.sh new file mode 100755 index 00000000..8e80026a --- /dev/null +++ b/hm/soispha/wms/river/res/safe_init.sh @@ -0,0 +1,160 @@ +#!/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 diff --git a/sys/nixpkgs/pkgs/snap-sync-forked/default.nix b/sys/nixpkgs/pkgs/snap-sync-forked/default.nix index 964a277a..5b086a5a 100644 --- a/sys/nixpkgs/pkgs/snap-sync-forked/default.nix +++ b/sys/nixpkgs/pkgs/snap-sync-forked/default.nix @@ -2,7 +2,7 @@ (final: prev: { snap-sync-forked = sysLib.writeShellScript { name = "snap-sync-forked"; - src = ./snap-sync-forked; + src = ./snap-sync-forked.sh; dependencies = with prev; [ bash btrfs-progs diff --git a/sys/nixpkgs/pkgs/snap-sync-forked/snap-sync-forked b/sys/nixpkgs/pkgs/snap-sync-forked/snap-sync-forked deleted file mode 100755 index a66f31ae..00000000 --- a/sys/nixpkgs/pkgs/snap-sync-forked/snap-sync-forked +++ /dev/null @@ -1,529 +0,0 @@ -#!/usr/bin/env bash -# snap-sync -# https://github.com/wesbarnett/snap-sync -# Copyright (C) 2016-2021 Wes Barnett - -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License along -# with this program; if not, write to the Free Software Foundation, Inc., - -# ------------------------------------------------------------------------- - -# Takes snapshots of each snapper configuration. It then sends the snapshot to -# a location on an external drive. After the initial transfer, it does -# incremental snapshots on later calls. It's important not to delete the -# snapshot created on your system since that will be used to determine the -# difference for the next incremental snapshot. - -set -o errtrace - -version="0.7" -name="snap-sync" - -printf "\nsnap-sync version %s, Copyright (C) 2016-2021 Wes Barnett\n" "$version" -printf "snap-sync comes with ABSOLUTELY NO WARRANTY. This is free software, and you are welcome to redistribute it under certain conditions. See the license for more information. \n\n" - -# The following line is modified by the Makefile or -# find_snapper_config script -SNAPPER_CONFIG=/etc/sysconfig/snapper - -donotify=0 -if ! command -v notify-send &> /dev/null; then - donotify=1 -fi - -doprogress=0 -if ! command -v pv &> /dev/null; then - doprogress=1 -fi - -error() { - printf "==> ERROR: %s\n" "$@" - notify_error 'Error' 'Check journal for more information.' -} >&2 - -die() { - error "$@" - exit 1 -} - -traperror() { - printf "Exited due to error on line %s.\n" "$1" - printf "exit status: %s\n" "$2" - printf "command: %s\n" "$3" - printf "bash line: %s\n" "$4" - printf "function name: %s\n" "$5" - exit 1 -} - -trapkill() { - die "Exited due to user intervention." -} - -trap 'traperror ${LINENO} $? "$BASH_COMMAND" $BASH_LINENO "${FUNCNAME[@]}"' ERR -trap trapkill SIGTERM SIGINT - -usage() { - cat < snapper configuration to backup - -d, --description snapper description - -h, --help print this message - -n, --noconfirm do not ask for confirmation - -k, --keepold keep old incremental snapshots instead of deleting them - after backup is performed - -p, --port remote port; used with '--remote'. - -q, --quiet do not send notifications; instead print them. - -r, --remote
ip address of a remote machine to backup to - --sudo use sudo on the remote machine - -s, --subvolid subvolume id of the mounted BTRFS subvolume to back up to - -u, --UUID UUID of the mounted BTRFS subvolume to back up to - -See 'man snap-sync' for more details. -EOF -} - -ssh="" -sudo=0 -while [[ $# -gt 0 ]]; do - key="$1" - case $key in - -d|--description) - description="$2" - shift 2 - ;; - -c|--config) - selected_configs="$2" - shift 2 - ;; - -u|--UUID) - uuid_cmdline="$2" - shift 2 - ;; - -s|--subvolid) - subvolid_cmdline="$2" - shift 2 - ;; - -k|--keepold) - keep="yes" - shift - ;; - -n|--noconfirm) - noconfirm="yes" - shift - ;; - -h|--help) - usage - exit 1 - ;; - -q|--quiet) - donotify=1 - shift - ;; - -r|--remote) - remote=$2 - shift 2 - ;; - -p|--port) - port=$2 - shift 2 - ;; - --sudo) - sudo=1 - shift - ;; - *) - die "Unknown option: '$key'. Run '$name -h' for valid options." - ;; - esac -done - -notify() { - for u in $(users | tr ' ' '\n' | sort -u); do - sudo -u "$u" DISPLAY=:0 \ - DBUS_SESSION_BUS_ADDRESS="unix:path=/run/user/$(sudo -u "$u" id -u)/bus" \ - notify-send -a $name "$1" "$2" --icon="dialog-$3" - done -} - -notify_info() { - if [[ $donotify -eq 0 ]]; then - notify "$1" "$2" "information" - else - printf '%s\n' "$1: $2" - fi -} - -notify_error() { - if [[ $donotify -eq 0 ]]; then - notify "$1" "$2" "error" - else - printf '%s\n' "$1: $2" - fi -} - -[[ $EUID -ne 0 ]] && die "Script must be run as root. See '$name -h' for a description of options" -! [[ -f $SNAPPER_CONFIG ]] && die "$SNAPPER_CONFIG does not exist." - -description=${description:-"latest incremental backup"} -uuid_cmdline=${uuid_cmdline:-"none"} -subvolid_cmdline=${subvolid_cmdline:-"5"} -noconfirm=${noconfirm:-"no"} - -if [[ -z $remote ]]; then - if ! command -v rsync &> /dev/null; then - die "--remote specified but rsync command not found" - fi -fi - -if [[ "$uuid_cmdline" != "none" ]]; then - if [[ -z $remote ]]; then - notify_info "Backup started" "Starting backups to $uuid_cmdline subvolid=$subvolid_cmdline..." - else - notify_info "Backup started" "Starting backups to $uuid_cmdline subvolid $subvolid_cmdline at $remote..." - fi -else - if [[ -z $remote ]]; then - notify_info "Backup started" "Starting backups. Use command line menu to select disk." - else - notify_info "Backup started" "Starting backups. Use command line menu to select disk on $remote." - fi -fi - -if [[ -n $remote ]]; then - ssh="ssh $remote" - if [[ -n $port ]]; then - ssh="$ssh -p $port" - fi - if [[ $sudo -eq 1 ]]; then - ssh="$ssh sudo" - fi -fi - -if [[ "$($ssh findmnt -n -v --target / -o FSTYPE)" == "btrfs" ]]; then - EXCLUDE_UUID=$($ssh findmnt -n -v -t btrfs --target / -o UUID) - TARGETS=$($ssh findmnt -n -v -t btrfs -o UUID,TARGET --list | grep -v "$EXCLUDE_UUID" | awk '{print $2}') - UUIDS=$($ssh findmnt -n -v -t btrfs -o UUID,TARGET --list | grep -v "$EXCLUDE_UUID" | awk '{print $1}') -else - TARGETS=$($ssh findmnt -n -v -t btrfs -o TARGET --list) - UUIDS=$($ssh findmnt -n -v -t btrfs -o UUID --list) -fi - -declare -a TARGETS_ARRAY -declare -a UUIDS_ARRAY -declare -a SUBVOLIDS_ARRAY - -i=0 -for x in $TARGETS; do - SUBVOLIDS_ARRAY[$i]=$($ssh btrfs subvolume show "$x" | awk '/Subvolume ID:/ { print $3 }') - TARGETS_ARRAY[$i]=$x - i=$((i+1)) -done - -i=0 -disk=-1 -disk_count=0 -for x in $UUIDS; do - UUIDS_ARRAY[$i]=$x - if [[ "$x" == "$uuid_cmdline" && ${SUBVOLIDS_ARRAY[$((i))]} == "$subvolid_cmdline" ]]; then - disk=$i - disk_count=$((disk_count+1)) - fi - i=$((i+1)) -done - -if [[ "${#UUIDS_ARRAY[$@]}" -eq 0 ]]; then - die "No external btrfs subvolumes found to backup to. Run '$name -h' for more options." -fi - -if [[ "$disk_count" -gt 1 ]]; then - printf "Multiple mount points were found with UUID %s and subvolid %s.\n" "$uuid_cmdline" "$subvolid_cmdline" - disk="-1" -fi - -if [[ "$disk" == -1 ]]; then - if [[ "$disk_count" == 0 && "$uuid_cmdline" != "none" ]]; then - error "A device with UUID $uuid_cmdline and subvolid $subvolid_cmdline was not found to be mounted, or it is not a BTRFS device." - fi - if [[ -z $ssh ]]; then - printf "Select a mounted BTRFS device on your local machine to backup to.\nFor more options, exit and run '%s -h'.\n" "$name" - else - printf "Select a mounted BTRFS device on %s to backup to.\nFor more options, exit and run '%s -h'.\n" "$remote" "$name" - fi - while [[ $disk -lt 0 || $disk -gt $i ]]; do - for x in "${!TARGETS_ARRAY[@]}"; do - printf "%4s) %s (uuid=%s, subvolid=%s)\n" "$((x+1))" "${TARGETS_ARRAY[$x]}" "${UUIDS_ARRAY[$x]}" "${SUBVOLIDS_ARRAY[$x]}" - done - printf "%4s) Exit\n" "0" - read -e -r -p "Enter a number: " disk - if ! [[ $disk == ?(-)+([0-9]) ]] || [[ $disk -lt 0 || $disk -gt $i ]]; then - printf "\nNo disk selected. Select a disk to continue.\n" - disk=-1 - fi - done - if [[ $disk == 0 ]]; then - exit 0 - fi - disk=$((disk-1)) -fi - -selected_subvolid="${SUBVOLIDS_ARRAY[$((disk))]}" -selected_uuid="${UUIDS_ARRAY[$((disk))]}" -selected_mnt="${TARGETS_ARRAY[$((disk))]}" -printf "\nYou selected the disk with uuid=%s, subvolid=%s.\n" "$selected_uuid" "$selected_subvolid" -if [[ -z $ssh ]]; then - printf "The disk is mounted at '%s'.\n" "$selected_mnt" -else - printf "The disk is mounted at '%s:%s'.\n" "$remote" "$selected_mnt" -fi - -# shellcheck source=/etc/default/snapper -source "$SNAPPER_CONFIG" - -if [[ -z $selected_configs ]]; then - printf "\nInteractively cycling through all snapper configurations...\n" -fi -selected_configs=${selected_configs:-$SNAPPER_CONFIGS} - -declare -a BACKUPDIRS_ARRAY -declare -a MYBACKUPDIR_ARRAY -declare -a OLD_NUM_ARRAY -declare -a OLD_SNAP_ARRAY -declare -a NEW_NUM_ARRAY -declare -a NEW_SNAP_ARRAY -declare -a NEW_INFO_ARRAY -declare -a BACKUPLOC_ARRAY -declare -a CONT_BACKUP_ARRAY - -# Initial configuration of where backup directories are -i=0 -for x in $selected_configs; do - - if [[ "$(snapper -c "$x" list --disable-used-space -t single | awk '/'"subvolid=$selected_subvolid, uuid=$selected_uuid"'/ {cnt++} END {print cnt}')" -gt 1 ]]; then - error "More than one snapper entry found with UUID $selected_uuid subvolid $selected_subvolid for configuration $x. Skipping configuration $x." - continue - fi - - if [[ "$(snapper -c "$x" list --disable-used-space -t single | awk '/'$name' backup in progress/ {cnt++} END {print cnt}')" -gt 0 ]]; then - printf "\nNOTE: Previous failed %s backup snapshots found for '%s'.\n" "$name" "$x" - if [[ $noconfirm == "yes" ]]; then - printf "'noconfirm' option passed. Failed backups will not be deleted.\n" - else - read -e -r -p "Delete failed backup snapshot(s)? (These local snapshots from failed backups are not used.) [y/N]? " delete_failed - while [[ -n "$delete_failed" && "$delete_failed" != [Yy]"es" && - "$delete_failed" != [Yy] && "$delete_failed" != [Nn]"o" && - "$delete_failed" != [Nn] ]]; do - read -e -r -p "Delete failed backup snapshot(s)? (These local snapshots from failed backups are not used.) [y/N] " delete_failed - if [[ -n "$delete_failed" && "$delete_failed" != [Yy]"es" && - "$delete_failed" != [Yy] && "$delete_failed" != [Nn]"o" && - "$delete_failed" != [Nn] ]]; then - printf "Select 'y' or 'N'.\n" - fi - done - if [[ "$delete_failed" == [Yy]"es" || "$delete_failed" == [Yy] ]]; then - # explicit split list of snapshots (on whitespace) into multiple arguments - # shellcheck disable=SC2046 - snapper -c "$x" delete $(snapper -c "$x" list --disable-used-space | awk '/'$name' backup in progress/ {print $1}') - fi - fi - fi - - SNAP_SYNC_EXCLUDE=no - - if [[ -f "/etc/snapper/configs/$x" ]]; then - # shellcheck source=/etc/snapper/config-templates/default - source "/etc/snapper/configs/$x" - else - die "Selected snapper configuration $x does not exist." - fi - - if [[ $SNAP_SYNC_EXCLUDE == "yes" ]]; then - continue - fi - - printf "\n" - - old_num=$(snapper -c "$x" list --disable-used-space -t single | awk '/'"subvolid=$selected_subvolid, uuid=$selected_uuid"'/ {print $1}') - old_snap=$SUBVOLUME/.snapshots/$old_num/snapshot - - OLD_NUM_ARRAY[$i]=$old_num - OLD_SNAP_ARRAY[$i]=$old_snap - - if [[ -z "$old_num" ]]; then - printf "No backups have been performed for '%s' on this disk.\n" "$x" - read -e -r -p "Enter name of subvolume to store backups, relative to $selected_mnt (to be created if not existing): " mybackupdir - printf "This will be the initial backup for snapper configuration '%s' to this disk. This could take awhile.\n" "$x" - BACKUPDIR="$selected_mnt/$mybackupdir" - $ssh test -d "$BACKUPDIR" || $ssh btrfs subvolume create "$BACKUPDIR" - else - mybackupdir=$(snapper -c "$x" list --disable-used-space -t single | awk -F"|" '/'"subvolid=$selected_subvolid, uuid=$selected_uuid"'/ {print $5}' | awk -F "," '/backupdir/ {print $1}' | awk -F"=" '{print $2}') - BACKUPDIR="$selected_mnt/$mybackupdir" - $ssh test -d "$BACKUPDIR" || die "%s is not a directory on %s.\n" "$BACKUPDIR" "$selected_uuid" - fi - BACKUPDIRS_ARRAY[$i]="$BACKUPDIR" - MYBACKUPDIR_ARRAY[$i]="$mybackupdir" - - printf "Creating new local snapshot for '%s' configuration...\n" "$x" - new_num=$(snapper -c "$x" create --print-number -d "$name backup in progress") - new_snap=$SUBVOLUME/.snapshots/$new_num/snapshot - new_info=$SUBVOLUME/.snapshots/$new_num/info.xml - sync - backup_location=$BACKUPDIR/$x/$new_num/ - if [[ -z $ssh ]]; then - printf "Will backup %s to %s\n" "$new_snap" "$backup_location/snapshot" - else - printf "Will backup %s to %s\n" "$new_snap" "$remote":"$backup_location/snapshot" - fi - - if ($ssh test -d "$backup_location/snapshot") ; then - printf "WARNING: Backup directory '%s' already exists. This configuration will be skipped!\n" "$backup_location/snapshot" - printf "Move or delete destination directory and try backup again.\n" - fi - - NEW_NUM_ARRAY[$i]="$new_num" - NEW_SNAP_ARRAY[$i]="$new_snap" - NEW_INFO_ARRAY[$i]="$new_info" - BACKUPLOC_ARRAY[$i]="$backup_location" - - cont_backup="K" - CONT_BACKUP_ARRAY[$i]="yes" - if [[ $noconfirm == "yes" ]]; then - cont_backup="yes" - else - while [[ -n "$cont_backup" && "$cont_backup" != [Yy]"es" && - "$cont_backup" != [Yy] && "$cont_backup" != [Nn]"o" && - "$cont_backup" != [Nn] ]]; do - read -e -r -p "Proceed with backup of '$x' configuration [Y/n]? " cont_backup - if [[ -n "$cont_backup" && "$cont_backup" != [Yy]"es" && - "$cont_backup" != [Yy] && "$cont_backup" != [Nn]"o" && - "$cont_backup" != [Nn] ]]; then - printf "Select 'Y' or 'n'.\n" - fi - done - fi - - if [[ "$cont_backup" != [Yy]"es" && "$cont_backup" != [Yy] && -n "$cont_backup" ]]; then - CONT_BACKUP_ARRAY[$i]="no" - printf "Not backing up '%s' configuration.\n" "$x" - snapper -c "$x" delete "$new_num" - fi - - i=$((i+1)) - -done - -# Actual backing up -printf "\nPerforming backups...\n" -i=-1 -for x in $selected_configs; do - - i=$((i+1)) - - SNAP_SYNC_EXCLUDE=no - - if [[ -f "/etc/snapper/configs/$x" ]]; then - # shellcheck source=/etc/snapper/config-templates/default - source "/etc/snapper/configs/$x" - else - die "Selected snapper configuration $x does not exist." - fi - - cont_backup=${CONT_BACKUP_ARRAY[$i]} - if [[ $cont_backup == "no" || $SNAP_SYNC_EXCLUDE == "yes" ]]; then - notify_info "Backup in progress" "NOTE: Skipping $x configuration." - continue - fi - - notify_info "Backup in progress" "Backing up $x configuration." - - printf "\n" - - old_num="${OLD_NUM_ARRAY[$i]}" - old_snap="${OLD_SNAP_ARRAY[$i]}" - BACKUPDIR="${BACKUPDIRS_ARRAY[$i]}" - mybackupdir="${MYBACKUPDIR_ARRAY[$i]}" - new_num="${NEW_NUM_ARRAY[$i]}" - new_snap="${NEW_SNAP_ARRAY[$i]}" - new_info="${NEW_INFO_ARRAY[$i]}" - backup_location="${BACKUPLOC_ARRAY[$i]}" - - if ($ssh test -d "$backup_location/snapshot") ; then - printf "ERROR: Backup directory '%s' already exists. Skipping backup of this configuration!\n" "$backup_location/snapshot" - continue - fi - - $ssh mkdir -p "$backup_location" - - if [[ -z "$old_num" ]]; then - printf "Sending first snapshot for '%s' configuration...\n" "$x" - if [[ $doprogress -eq 0 ]]; then - btrfs send "$new_snap" | pv | $ssh btrfs receive "$backup_location" &>/dev/null - else - btrfs send "$new_snap" | $ssh btrfs receive "$backup_location" &>/dev/null - fi - else - - printf "Sending incremental snapshot for '%s' configuration...\n" "$x" - # Sends the difference between the new snapshot and old snapshot to the - # backup location. Using the -c flag instead of -p tells it that there - # is an identical subvolume to the old snapshot at the receiving - # location where it can get its data. This helps speed up the transfer. - - if [[ $doprogress -eq 0 ]]; then - btrfs send -c "$old_snap" "$new_snap" | pv | $ssh btrfs receive "$backup_location" - else - btrfs send -c "$old_snap" "$new_snap" | $ssh btrfs receive "$backup_location" - fi - - if [[ $keep == "yes" ]]; then - printf "Modifying data for old local snapshot for '%s' configuration...\n" "$x" - snapper -v -c "$x" modify -d "old snap-sync snapshot (you may remove)" -u "backupdir=,subvolid=,uuid=" -c "number" "$old_num" - else - printf "Deleting old snapshot for %s...\n" "$x" - snapper -c "$x" delete "$old_num" - fi - - fi - - if [[ -z $remote ]]; then - cp "$new_info" "$backup_location" - else - if [[ -z $port ]]; then - rsync -avzq "$new_info" "$remote":"$backup_location" - else - rsync -avzqe "ssh -p $port" "$new_info" "$remote":"$backup_location" - fi - fi - - # It's important not to change this userdata in the snapshots, since that's how - # we find the previous one. - - userdata="backupdir=$mybackupdir, subvolid=$selected_subvolid, uuid=$selected_uuid" - - # Tag new snapshot as the latest - printf "Tagging local snapshot as latest backup for '%s' configuration...\n" "$x" - snapper -v -c "$x" modify -d "$description" -u "$userdata" "$new_num" - - printf "Backup complete for '%s' configuration.\n" "$x" - -done - -printf "\nDone!\n" - -if [[ "$uuid_cmdline" != "none" ]]; then - notify_info "Finished" "Backups to $uuid_cmdline complete!" -else - notify_info "Finished" "Backups complete!" -fi diff --git a/sys/nixpkgs/pkgs/snap-sync-forked/snap-sync-forked.sh b/sys/nixpkgs/pkgs/snap-sync-forked/snap-sync-forked.sh new file mode 100755 index 00000000..a66f31ae --- /dev/null +++ b/sys/nixpkgs/pkgs/snap-sync-forked/snap-sync-forked.sh @@ -0,0 +1,529 @@ +#!/usr/bin/env bash +# snap-sync +# https://github.com/wesbarnett/snap-sync +# Copyright (C) 2016-2021 Wes Barnett + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License along +# with this program; if not, write to the Free Software Foundation, Inc., + +# ------------------------------------------------------------------------- + +# Takes snapshots of each snapper configuration. It then sends the snapshot to +# a location on an external drive. After the initial transfer, it does +# incremental snapshots on later calls. It's important not to delete the +# snapshot created on your system since that will be used to determine the +# difference for the next incremental snapshot. + +set -o errtrace + +version="0.7" +name="snap-sync" + +printf "\nsnap-sync version %s, Copyright (C) 2016-2021 Wes Barnett\n" "$version" +printf "snap-sync comes with ABSOLUTELY NO WARRANTY. This is free software, and you are welcome to redistribute it under certain conditions. See the license for more information. \n\n" + +# The following line is modified by the Makefile or +# find_snapper_config script +SNAPPER_CONFIG=/etc/sysconfig/snapper + +donotify=0 +if ! command -v notify-send &> /dev/null; then + donotify=1 +fi + +doprogress=0 +if ! command -v pv &> /dev/null; then + doprogress=1 +fi + +error() { + printf "==> ERROR: %s\n" "$@" + notify_error 'Error' 'Check journal for more information.' +} >&2 + +die() { + error "$@" + exit 1 +} + +traperror() { + printf "Exited due to error on line %s.\n" "$1" + printf "exit status: %s\n" "$2" + printf "command: %s\n" "$3" + printf "bash line: %s\n" "$4" + printf "function name: %s\n" "$5" + exit 1 +} + +trapkill() { + die "Exited due to user intervention." +} + +trap 'traperror ${LINENO} $? "$BASH_COMMAND" $BASH_LINENO "${FUNCNAME[@]}"' ERR +trap trapkill SIGTERM SIGINT + +usage() { + cat < snapper configuration to backup + -d, --description snapper description + -h, --help print this message + -n, --noconfirm do not ask for confirmation + -k, --keepold keep old incremental snapshots instead of deleting them + after backup is performed + -p, --port remote port; used with '--remote'. + -q, --quiet do not send notifications; instead print them. + -r, --remote
ip address of a remote machine to backup to + --sudo use sudo on the remote machine + -s, --subvolid subvolume id of the mounted BTRFS subvolume to back up to + -u, --UUID UUID of the mounted BTRFS subvolume to back up to + +See 'man snap-sync' for more details. +EOF +} + +ssh="" +sudo=0 +while [[ $# -gt 0 ]]; do + key="$1" + case $key in + -d|--description) + description="$2" + shift 2 + ;; + -c|--config) + selected_configs="$2" + shift 2 + ;; + -u|--UUID) + uuid_cmdline="$2" + shift 2 + ;; + -s|--subvolid) + subvolid_cmdline="$2" + shift 2 + ;; + -k|--keepold) + keep="yes" + shift + ;; + -n|--noconfirm) + noconfirm="yes" + shift + ;; + -h|--help) + usage + exit 1 + ;; + -q|--quiet) + donotify=1 + shift + ;; + -r|--remote) + remote=$2 + shift 2 + ;; + -p|--port) + port=$2 + shift 2 + ;; + --sudo) + sudo=1 + shift + ;; + *) + die "Unknown option: '$key'. Run '$name -h' for valid options." + ;; + esac +done + +notify() { + for u in $(users | tr ' ' '\n' | sort -u); do + sudo -u "$u" DISPLAY=:0 \ + DBUS_SESSION_BUS_ADDRESS="unix:path=/run/user/$(sudo -u "$u" id -u)/bus" \ + notify-send -a $name "$1" "$2" --icon="dialog-$3" + done +} + +notify_info() { + if [[ $donotify -eq 0 ]]; then + notify "$1" "$2" "information" + else + printf '%s\n' "$1: $2" + fi +} + +notify_error() { + if [[ $donotify -eq 0 ]]; then + notify "$1" "$2" "error" + else + printf '%s\n' "$1: $2" + fi +} + +[[ $EUID -ne 0 ]] && die "Script must be run as root. See '$name -h' for a description of options" +! [[ -f $SNAPPER_CONFIG ]] && die "$SNAPPER_CONFIG does not exist." + +description=${description:-"latest incremental backup"} +uuid_cmdline=${uuid_cmdline:-"none"} +subvolid_cmdline=${subvolid_cmdline:-"5"} +noconfirm=${noconfirm:-"no"} + +if [[ -z $remote ]]; then + if ! command -v rsync &> /dev/null; then + die "--remote specified but rsync command not found" + fi +fi + +if [[ "$uuid_cmdline" != "none" ]]; then + if [[ -z $remote ]]; then + notify_info "Backup started" "Starting backups to $uuid_cmdline subvolid=$subvolid_cmdline..." + else + notify_info "Backup started" "Starting backups to $uuid_cmdline subvolid $subvolid_cmdline at $remote..." + fi +else + if [[ -z $remote ]]; then + notify_info "Backup started" "Starting backups. Use command line menu to select disk." + else + notify_info "Backup started" "Starting backups. Use command line menu to select disk on $remote." + fi +fi + +if [[ -n $remote ]]; then + ssh="ssh $remote" + if [[ -n $port ]]; then + ssh="$ssh -p $port" + fi + if [[ $sudo -eq 1 ]]; then + ssh="$ssh sudo" + fi +fi + +if [[ "$($ssh findmnt -n -v --target / -o FSTYPE)" == "btrfs" ]]; then + EXCLUDE_UUID=$($ssh findmnt -n -v -t btrfs --target / -o UUID) + TARGETS=$($ssh findmnt -n -v -t btrfs -o UUID,TARGET --list | grep -v "$EXCLUDE_UUID" | awk '{print $2}') + UUIDS=$($ssh findmnt -n -v -t btrfs -o UUID,TARGET --list | grep -v "$EXCLUDE_UUID" | awk '{print $1}') +else + TARGETS=$($ssh findmnt -n -v -t btrfs -o TARGET --list) + UUIDS=$($ssh findmnt -n -v -t btrfs -o UUID --list) +fi + +declare -a TARGETS_ARRAY +declare -a UUIDS_ARRAY +declare -a SUBVOLIDS_ARRAY + +i=0 +for x in $TARGETS; do + SUBVOLIDS_ARRAY[$i]=$($ssh btrfs subvolume show "$x" | awk '/Subvolume ID:/ { print $3 }') + TARGETS_ARRAY[$i]=$x + i=$((i+1)) +done + +i=0 +disk=-1 +disk_count=0 +for x in $UUIDS; do + UUIDS_ARRAY[$i]=$x + if [[ "$x" == "$uuid_cmdline" && ${SUBVOLIDS_ARRAY[$((i))]} == "$subvolid_cmdline" ]]; then + disk=$i + disk_count=$((disk_count+1)) + fi + i=$((i+1)) +done + +if [[ "${#UUIDS_ARRAY[$@]}" -eq 0 ]]; then + die "No external btrfs subvolumes found to backup to. Run '$name -h' for more options." +fi + +if [[ "$disk_count" -gt 1 ]]; then + printf "Multiple mount points were found with UUID %s and subvolid %s.\n" "$uuid_cmdline" "$subvolid_cmdline" + disk="-1" +fi + +if [[ "$disk" == -1 ]]; then + if [[ "$disk_count" == 0 && "$uuid_cmdline" != "none" ]]; then + error "A device with UUID $uuid_cmdline and subvolid $subvolid_cmdline was not found to be mounted, or it is not a BTRFS device." + fi + if [[ -z $ssh ]]; then + printf "Select a mounted BTRFS device on your local machine to backup to.\nFor more options, exit and run '%s -h'.\n" "$name" + else + printf "Select a mounted BTRFS device on %s to backup to.\nFor more options, exit and run '%s -h'.\n" "$remote" "$name" + fi + while [[ $disk -lt 0 || $disk -gt $i ]]; do + for x in "${!TARGETS_ARRAY[@]}"; do + printf "%4s) %s (uuid=%s, subvolid=%s)\n" "$((x+1))" "${TARGETS_ARRAY[$x]}" "${UUIDS_ARRAY[$x]}" "${SUBVOLIDS_ARRAY[$x]}" + done + printf "%4s) Exit\n" "0" + read -e -r -p "Enter a number: " disk + if ! [[ $disk == ?(-)+([0-9]) ]] || [[ $disk -lt 0 || $disk -gt $i ]]; then + printf "\nNo disk selected. Select a disk to continue.\n" + disk=-1 + fi + done + if [[ $disk == 0 ]]; then + exit 0 + fi + disk=$((disk-1)) +fi + +selected_subvolid="${SUBVOLIDS_ARRAY[$((disk))]}" +selected_uuid="${UUIDS_ARRAY[$((disk))]}" +selected_mnt="${TARGETS_ARRAY[$((disk))]}" +printf "\nYou selected the disk with uuid=%s, subvolid=%s.\n" "$selected_uuid" "$selected_subvolid" +if [[ -z $ssh ]]; then + printf "The disk is mounted at '%s'.\n" "$selected_mnt" +else + printf "The disk is mounted at '%s:%s'.\n" "$remote" "$selected_mnt" +fi + +# shellcheck source=/etc/default/snapper +source "$SNAPPER_CONFIG" + +if [[ -z $selected_configs ]]; then + printf "\nInteractively cycling through all snapper configurations...\n" +fi +selected_configs=${selected_configs:-$SNAPPER_CONFIGS} + +declare -a BACKUPDIRS_ARRAY +declare -a MYBACKUPDIR_ARRAY +declare -a OLD_NUM_ARRAY +declare -a OLD_SNAP_ARRAY +declare -a NEW_NUM_ARRAY +declare -a NEW_SNAP_ARRAY +declare -a NEW_INFO_ARRAY +declare -a BACKUPLOC_ARRAY +declare -a CONT_BACKUP_ARRAY + +# Initial configuration of where backup directories are +i=0 +for x in $selected_configs; do + + if [[ "$(snapper -c "$x" list --disable-used-space -t single | awk '/'"subvolid=$selected_subvolid, uuid=$selected_uuid"'/ {cnt++} END {print cnt}')" -gt 1 ]]; then + error "More than one snapper entry found with UUID $selected_uuid subvolid $selected_subvolid for configuration $x. Skipping configuration $x." + continue + fi + + if [[ "$(snapper -c "$x" list --disable-used-space -t single | awk '/'$name' backup in progress/ {cnt++} END {print cnt}')" -gt 0 ]]; then + printf "\nNOTE: Previous failed %s backup snapshots found for '%s'.\n" "$name" "$x" + if [[ $noconfirm == "yes" ]]; then + printf "'noconfirm' option passed. Failed backups will not be deleted.\n" + else + read -e -r -p "Delete failed backup snapshot(s)? (These local snapshots from failed backups are not used.) [y/N]? " delete_failed + while [[ -n "$delete_failed" && "$delete_failed" != [Yy]"es" && + "$delete_failed" != [Yy] && "$delete_failed" != [Nn]"o" && + "$delete_failed" != [Nn] ]]; do + read -e -r -p "Delete failed backup snapshot(s)? (These local snapshots from failed backups are not used.) [y/N] " delete_failed + if [[ -n "$delete_failed" && "$delete_failed" != [Yy]"es" && + "$delete_failed" != [Yy] && "$delete_failed" != [Nn]"o" && + "$delete_failed" != [Nn] ]]; then + printf "Select 'y' or 'N'.\n" + fi + done + if [[ "$delete_failed" == [Yy]"es" || "$delete_failed" == [Yy] ]]; then + # explicit split list of snapshots (on whitespace) into multiple arguments + # shellcheck disable=SC2046 + snapper -c "$x" delete $(snapper -c "$x" list --disable-used-space | awk '/'$name' backup in progress/ {print $1}') + fi + fi + fi + + SNAP_SYNC_EXCLUDE=no + + if [[ -f "/etc/snapper/configs/$x" ]]; then + # shellcheck source=/etc/snapper/config-templates/default + source "/etc/snapper/configs/$x" + else + die "Selected snapper configuration $x does not exist." + fi + + if [[ $SNAP_SYNC_EXCLUDE == "yes" ]]; then + continue + fi + + printf "\n" + + old_num=$(snapper -c "$x" list --disable-used-space -t single | awk '/'"subvolid=$selected_subvolid, uuid=$selected_uuid"'/ {print $1}') + old_snap=$SUBVOLUME/.snapshots/$old_num/snapshot + + OLD_NUM_ARRAY[$i]=$old_num + OLD_SNAP_ARRAY[$i]=$old_snap + + if [[ -z "$old_num" ]]; then + printf "No backups have been performed for '%s' on this disk.\n" "$x" + read -e -r -p "Enter name of subvolume to store backups, relative to $selected_mnt (to be created if not existing): " mybackupdir + printf "This will be the initial backup for snapper configuration '%s' to this disk. This could take awhile.\n" "$x" + BACKUPDIR="$selected_mnt/$mybackupdir" + $ssh test -d "$BACKUPDIR" || $ssh btrfs subvolume create "$BACKUPDIR" + else + mybackupdir=$(snapper -c "$x" list --disable-used-space -t single | awk -F"|" '/'"subvolid=$selected_subvolid, uuid=$selected_uuid"'/ {print $5}' | awk -F "," '/backupdir/ {print $1}' | awk -F"=" '{print $2}') + BACKUPDIR="$selected_mnt/$mybackupdir" + $ssh test -d "$BACKUPDIR" || die "%s is not a directory on %s.\n" "$BACKUPDIR" "$selected_uuid" + fi + BACKUPDIRS_ARRAY[$i]="$BACKUPDIR" + MYBACKUPDIR_ARRAY[$i]="$mybackupdir" + + printf "Creating new local snapshot for '%s' configuration...\n" "$x" + new_num=$(snapper -c "$x" create --print-number -d "$name backup in progress") + new_snap=$SUBVOLUME/.snapshots/$new_num/snapshot + new_info=$SUBVOLUME/.snapshots/$new_num/info.xml + sync + backup_location=$BACKUPDIR/$x/$new_num/ + if [[ -z $ssh ]]; then + printf "Will backup %s to %s\n" "$new_snap" "$backup_location/snapshot" + else + printf "Will backup %s to %s\n" "$new_snap" "$remote":"$backup_location/snapshot" + fi + + if ($ssh test -d "$backup_location/snapshot") ; then + printf "WARNING: Backup directory '%s' already exists. This configuration will be skipped!\n" "$backup_location/snapshot" + printf "Move or delete destination directory and try backup again.\n" + fi + + NEW_NUM_ARRAY[$i]="$new_num" + NEW_SNAP_ARRAY[$i]="$new_snap" + NEW_INFO_ARRAY[$i]="$new_info" + BACKUPLOC_ARRAY[$i]="$backup_location" + + cont_backup="K" + CONT_BACKUP_ARRAY[$i]="yes" + if [[ $noconfirm == "yes" ]]; then + cont_backup="yes" + else + while [[ -n "$cont_backup" && "$cont_backup" != [Yy]"es" && + "$cont_backup" != [Yy] && "$cont_backup" != [Nn]"o" && + "$cont_backup" != [Nn] ]]; do + read -e -r -p "Proceed with backup of '$x' configuration [Y/n]? " cont_backup + if [[ -n "$cont_backup" && "$cont_backup" != [Yy]"es" && + "$cont_backup" != [Yy] && "$cont_backup" != [Nn]"o" && + "$cont_backup" != [Nn] ]]; then + printf "Select 'Y' or 'n'.\n" + fi + done + fi + + if [[ "$cont_backup" != [Yy]"es" && "$cont_backup" != [Yy] && -n "$cont_backup" ]]; then + CONT_BACKUP_ARRAY[$i]="no" + printf "Not backing up '%s' configuration.\n" "$x" + snapper -c "$x" delete "$new_num" + fi + + i=$((i+1)) + +done + +# Actual backing up +printf "\nPerforming backups...\n" +i=-1 +for x in $selected_configs; do + + i=$((i+1)) + + SNAP_SYNC_EXCLUDE=no + + if [[ -f "/etc/snapper/configs/$x" ]]; then + # shellcheck source=/etc/snapper/config-templates/default + source "/etc/snapper/configs/$x" + else + die "Selected snapper configuration $x does not exist." + fi + + cont_backup=${CONT_BACKUP_ARRAY[$i]} + if [[ $cont_backup == "no" || $SNAP_SYNC_EXCLUDE == "yes" ]]; then + notify_info "Backup in progress" "NOTE: Skipping $x configuration." + continue + fi + + notify_info "Backup in progress" "Backing up $x configuration." + + printf "\n" + + old_num="${OLD_NUM_ARRAY[$i]}" + old_snap="${OLD_SNAP_ARRAY[$i]}" + BACKUPDIR="${BACKUPDIRS_ARRAY[$i]}" + mybackupdir="${MYBACKUPDIR_ARRAY[$i]}" + new_num="${NEW_NUM_ARRAY[$i]}" + new_snap="${NEW_SNAP_ARRAY[$i]}" + new_info="${NEW_INFO_ARRAY[$i]}" + backup_location="${BACKUPLOC_ARRAY[$i]}" + + if ($ssh test -d "$backup_location/snapshot") ; then + printf "ERROR: Backup directory '%s' already exists. Skipping backup of this configuration!\n" "$backup_location/snapshot" + continue + fi + + $ssh mkdir -p "$backup_location" + + if [[ -z "$old_num" ]]; then + printf "Sending first snapshot for '%s' configuration...\n" "$x" + if [[ $doprogress -eq 0 ]]; then + btrfs send "$new_snap" | pv | $ssh btrfs receive "$backup_location" &>/dev/null + else + btrfs send "$new_snap" | $ssh btrfs receive "$backup_location" &>/dev/null + fi + else + + printf "Sending incremental snapshot for '%s' configuration...\n" "$x" + # Sends the difference between the new snapshot and old snapshot to the + # backup location. Using the -c flag instead of -p tells it that there + # is an identical subvolume to the old snapshot at the receiving + # location where it can get its data. This helps speed up the transfer. + + if [[ $doprogress -eq 0 ]]; then + btrfs send -c "$old_snap" "$new_snap" | pv | $ssh btrfs receive "$backup_location" + else + btrfs send -c "$old_snap" "$new_snap" | $ssh btrfs receive "$backup_location" + fi + + if [[ $keep == "yes" ]]; then + printf "Modifying data for old local snapshot for '%s' configuration...\n" "$x" + snapper -v -c "$x" modify -d "old snap-sync snapshot (you may remove)" -u "backupdir=,subvolid=,uuid=" -c "number" "$old_num" + else + printf "Deleting old snapshot for %s...\n" "$x" + snapper -c "$x" delete "$old_num" + fi + + fi + + if [[ -z $remote ]]; then + cp "$new_info" "$backup_location" + else + if [[ -z $port ]]; then + rsync -avzq "$new_info" "$remote":"$backup_location" + else + rsync -avzqe "ssh -p $port" "$new_info" "$remote":"$backup_location" + fi + fi + + # It's important not to change this userdata in the snapshots, since that's how + # we find the previous one. + + userdata="backupdir=$mybackupdir, subvolid=$selected_subvolid, uuid=$selected_uuid" + + # Tag new snapshot as the latest + printf "Tagging local snapshot as latest backup for '%s' configuration...\n" "$x" + snapper -v -c "$x" modify -d "$description" -u "$userdata" "$new_num" + + printf "Backup complete for '%s' configuration.\n" "$x" + +done + +printf "\nDone!\n" + +if [[ "$uuid_cmdline" != "none" ]]; then + notify_info "Finished" "Backups to $uuid_cmdline complete!" +else + notify_info "Finished" "Backups complete!" +fi diff --git a/sys/nixpkgs/pkgs/update_pkgs b/sys/nixpkgs/pkgs/update_pkgs deleted file mode 100755 index 8392fb1c..00000000 --- a/sys/nixpkgs/pkgs/update_pkgs +++ /dev/null @@ -1,27 +0,0 @@ -#!/usr/bin/env sh - -die() { - printf "\033[31;1mError: \033[0m%s" "$1"; - exit 1 -} - -cd "$(dirname "$0")" || die "Bug: run with false dirname ('$0')!" - - -fd . --type directory --max-depth 1 | while read -r dir; do - cd "$dir" || die "Dir '$dir' does not exist" - - if [ -f update.sh ]; then - printf "\033[34;1m> \033[0m\033[34;1m%s\033[0m\n" "Running '${dir}update.sh'"; - - [ -f flake.nix ] && nix flake update - - direnv allow - eval "$(direnv export bash 2>/dev/null)" - ./update.sh "$@" - fi - cd - > /dev/null || die "Bug: Last dir does not exist" -done - - -# vim: ft=sh diff --git a/sys/nixpkgs/pkgs/update_pkgs.sh b/sys/nixpkgs/pkgs/update_pkgs.sh new file mode 100755 index 00000000..8392fb1c --- /dev/null +++ b/sys/nixpkgs/pkgs/update_pkgs.sh @@ -0,0 +1,27 @@ +#!/usr/bin/env sh + +die() { + printf "\033[31;1mError: \033[0m%s" "$1"; + exit 1 +} + +cd "$(dirname "$0")" || die "Bug: run with false dirname ('$0')!" + + +fd . --type directory --max-depth 1 | while read -r dir; do + cd "$dir" || die "Dir '$dir' does not exist" + + if [ -f update.sh ]; then + printf "\033[34;1m> \033[0m\033[34;1m%s\033[0m\n" "Running '${dir}update.sh'"; + + [ -f flake.nix ] && nix flake update + + direnv allow + eval "$(direnv export bash 2>/dev/null)" + ./update.sh "$@" + fi + cd - > /dev/null || die "Bug: Last dir does not exist" +done + + +# vim: ft=sh diff --git a/sys/svcs/xdg/default.nix b/sys/svcs/xdg/default.nix index 513e7a65..3229b97c 100644 --- a/sys/svcs/xdg/default.nix +++ b/sys/svcs/xdg/default.nix @@ -14,7 +14,7 @@ filechooser = { default_dir = "/tmp"; cmd = "${sysLib.writeShellScript { - src = ./scripts/lf_wrapper; + src = ./scripts/lf_wrapper.sh; name = "lf_wrapper"; keepPath = true; dependencies = with pkgs; [ diff --git a/sys/svcs/xdg/scripts/lf_wrapper b/sys/svcs/xdg/scripts/lf_wrapper deleted file mode 100755 index 7a508d39..00000000 --- a/sys/svcs/xdg/scripts/lf_wrapper +++ /dev/null @@ -1,76 +0,0 @@ -#!/usr/bin/env sh - -# This wrapper script is invoked by xdg-desktop-portal-termfilechooser. -# -# Inputs: -# 1. "1" if multiple files can be chosen, "0" otherwise. -# 2. "1" if a directory should be chosen, "0" otherwise. -# 3. "0" if opening files was requested, "1" if writing to a file was -# requested. For example, when uploading files in Firefox, this will be "0". -# When saving a web page in Firefox, this will be "1". -# 4. If writing to a file, this is recommended path provided by the caller. For -# example, when saving a web page in Firefox, this will be the recommended -# path Firefox provided, such as "~/Downloads/webpage_title.html". -# Note that if the path already exists, we keep appending "_" to it until we -# get a path that does not exist. -# 5. The output path, to which results should be written. -# -# Output: -# The script should print the selected paths to the output path (argument #5), -# one path per line. -# If nothing is printed, then the operation is assumed to have been canceled. - -multiple="$1" -directory="$2" -save="$3" -recommended_path="$4" -out="$5" - -# echo > /tmp/stdout -# echo > /tmp/stderr -# -# exec 1>> /tmp/stdout -# exec 2>> /tmp/stderr - -cmd="$(command -v lf)" -termcmd="${TERMINAL:-$(command -v alacritty)}" - -if [ "$save" = "1" ]; then - set -- -selection-path="$out" -command='set promptfmt "Select the file to write to %S \033[32;1m%u@%h\033[0m:\033[34;1m%d\033[0m\033[1m%f\033[0m"' "$recommended_path" - cat << EOF > "$recommended_path" -xdg-desktop-portal-termfilechooser saving files tutorial - -!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -!!! === WARNING! === !!! -!!! The contents of *whatever* file you open last in !!! -!!! lf will be *overwritten*! !!! -!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - -Instructions: -1) Move this file wherever you want. -2) Rename the file if needed. -3) Confirm your selection by opening the file, for - example by pressing . - -Notes: -1) This file is provided for your convenience. You - could delete it and choose another file to overwrite - that, for example. -2) If you quit lf without opening a file, this file - will be removed and the save operation aborted. -EOF - -elif [ "$directory" = "1" ]; then - set -- -selection-path="$out" -command='set dironly' -command='set promptfmt "Select directory (quit in dir to select it) %S \033[32;1m%u@%h\033[0m:\033[34;1m%d\033[0m\033[1m%f\033[0m"' -elif [ "$multiple" = "1" ]; then - set -- -selection-path="$out" -command='set promptfmt "Select file(s) (open file to select it; to select multiple) %S \033[32;1m%u@%h\033[0m:\033[34;1m%d\033[0m\033[1m%f\033[0m"' -else - set -- -selection-path="$out" -command='set promptfmt "Select file (open file to select it) %S \033[32;1m%u@%h\033[0m:\033[34;1m%d\033[0m\033[1m%f\033[0m"' -fi - -"$termcmd" --title 'floating please' -e "$cmd" "$@" - -if [ "$save" = "1" ] && [ ! -s "$out" ]; then - rm "$recommended_path" -fi -# vim: ft=sh diff --git a/sys/svcs/xdg/scripts/lf_wrapper.sh b/sys/svcs/xdg/scripts/lf_wrapper.sh new file mode 100755 index 00000000..7a508d39 --- /dev/null +++ b/sys/svcs/xdg/scripts/lf_wrapper.sh @@ -0,0 +1,76 @@ +#!/usr/bin/env sh + +# This wrapper script is invoked by xdg-desktop-portal-termfilechooser. +# +# Inputs: +# 1. "1" if multiple files can be chosen, "0" otherwise. +# 2. "1" if a directory should be chosen, "0" otherwise. +# 3. "0" if opening files was requested, "1" if writing to a file was +# requested. For example, when uploading files in Firefox, this will be "0". +# When saving a web page in Firefox, this will be "1". +# 4. If writing to a file, this is recommended path provided by the caller. For +# example, when saving a web page in Firefox, this will be the recommended +# path Firefox provided, such as "~/Downloads/webpage_title.html". +# Note that if the path already exists, we keep appending "_" to it until we +# get a path that does not exist. +# 5. The output path, to which results should be written. +# +# Output: +# The script should print the selected paths to the output path (argument #5), +# one path per line. +# If nothing is printed, then the operation is assumed to have been canceled. + +multiple="$1" +directory="$2" +save="$3" +recommended_path="$4" +out="$5" + +# echo > /tmp/stdout +# echo > /tmp/stderr +# +# exec 1>> /tmp/stdout +# exec 2>> /tmp/stderr + +cmd="$(command -v lf)" +termcmd="${TERMINAL:-$(command -v alacritty)}" + +if [ "$save" = "1" ]; then + set -- -selection-path="$out" -command='set promptfmt "Select the file to write to %S \033[32;1m%u@%h\033[0m:\033[34;1m%d\033[0m\033[1m%f\033[0m"' "$recommended_path" + cat << EOF > "$recommended_path" +xdg-desktop-portal-termfilechooser saving files tutorial + +!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! +!!! === WARNING! === !!! +!!! The contents of *whatever* file you open last in !!! +!!! lf will be *overwritten*! !!! +!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +Instructions: +1) Move this file wherever you want. +2) Rename the file if needed. +3) Confirm your selection by opening the file, for + example by pressing . + +Notes: +1) This file is provided for your convenience. You + could delete it and choose another file to overwrite + that, for example. +2) If you quit lf without opening a file, this file + will be removed and the save operation aborted. +EOF + +elif [ "$directory" = "1" ]; then + set -- -selection-path="$out" -command='set dironly' -command='set promptfmt "Select directory (quit in dir to select it) %S \033[32;1m%u@%h\033[0m:\033[34;1m%d\033[0m\033[1m%f\033[0m"' +elif [ "$multiple" = "1" ]; then + set -- -selection-path="$out" -command='set promptfmt "Select file(s) (open file to select it; to select multiple) %S \033[32;1m%u@%h\033[0m:\033[34;1m%d\033[0m\033[1m%f\033[0m"' +else + set -- -selection-path="$out" -command='set promptfmt "Select file (open file to select it) %S \033[32;1m%u@%h\033[0m:\033[34;1m%d\033[0m\033[1m%f\033[0m"' +fi + +"$termcmd" --title 'floating please' -e "$cmd" "$@" + +if [ "$save" = "1" ] && [ ! -s "$out" ]; then + rm "$recommended_path" +fi +# vim: ft=sh diff --git a/update.sh b/update.sh index 6f8a65c1..ab38ea56 100755 --- a/update.sh +++ b/update.sh @@ -1,6 +1,6 @@ #!/bin/sh # shellcheck disable=SC2086 -./hm/soispha/conf/firefox/scripts/update_extensions +./hm/soispha/conf/firefox/scripts/update_extensions.sh -./sys/nixpkgs/pkgs/update_pkgs "$@" +./sys/nixpkgs/pkgs/update_pkgs.sh "$@" -- cgit 1.4.1