add elf_package "manager"

This commit is contained in:
2025-11-08 19:40:04 +01:00
parent b3936cd23a
commit 03b96050bc
12 changed files with 418 additions and 14 deletions

View File

@@ -0,0 +1,104 @@
#!/usr/bin/env bash
SCRIPTS_DIR="$HOME/.local/share/elfos"
function print_help() {
echo "usage: elf_packages <ACTION>"
echo
echo "ACTION:"
echo " list list available scripts"
echo " install <script> execute install script"
echo " uninstall <script> execute remove script"
echo " help display this help"
}
function check_if_script_exists() {
script="$1"
if [[ ! -f "$SCRIPTS_DIR/$script.sh" ]]
then
echo "ERROR: $script does not exists"
print_help
return 1
else
return 0
fi
}
function install_pacman_deps() {
deps="$1"
pacman -Sy --noconfirm $deps
}
function update() {
script="$1"
check_if_script_exists "$script" || return 1
. "$SCRIPTS_DIR/$script.sh"
if package_check_installed
then
package_update
else
echo "package not installed"
fi
}
function uninstall() {
script="$1"
check_if_script_exists "$script" || return 1
. "$SCRIPTS_DIR/$script.sh"
if package_check_installed
then
package_remove
else
echo "package not installed"
fi
}
function update() {
script="$1"
check_if_script_exists "$script" && return 1
. "$SCRIPTS_DIR/$script"
package_update
}
case $1 in
list)
find "$SCRIPTS_DIR" -maxdepth 1 -name '*.sh' \
-exec basename "{}" ';' \
| sed -e 's/\.sh$//'
;;
install)
shift
install $*
;;
uninstall)
shift
uninstall $*
;;
update)
shift
update $*
;;
help)
print_help
;;
"--help")
print_help
;;
"-h")
print_help
;;
*)
echo "ERROR: invalid action $1"
print_help
;;
esac

View File

@@ -1,4 +1,11 @@
#!/usr/bin/env bash
cat "$1"/* | sed -e 's|//.*$||' -e 's|^[ \t]*||' | grep -v '^[ \t]*$' | awk '/\/\*/ {s=1} /\*\// && s==1 {s=0} !s' | grep -v '^.$' | grep -v '^..$' | grep -v '^...$' | wc -l
cat "$1"/* \
| sed -e 's|//.*$||' -e 's|^[ \t]*||' \
| grep -v '^[ \t]*$' \
| awk '/\/\*/ {s=1} /\*\// && s==1 {s=0} !s' \
| grep -v '^.$' \
| grep -v '^..$' \
| grep -v '^...$' \
| wc -l

View File

@@ -19,7 +19,7 @@ function pick_song() {
playlist_path="$PLAYLIST_DIR/$playlist.pls"
if [[ ! -f "$playlist_path" ]]
then
echo "error: playlist $playlist not found"
echo "ERROR: playlist $playlist not found" >&2
exit 1
fi

View File

@@ -0,0 +1,4 @@
#!/usr/bin/env bash
cat "$(find "$HOME/.config/env" -name '*.env' -type f)" \
>"$HOME/.config/env/all"