summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSuleyman Farajli <suleyman@farajli.net>2025-05-31 01:37:06 +0400
committerSuleyman Farajli <suleyman@farajli.net>2025-05-31 01:37:06 +0400
commit185944f3c4bdaf459bbc3a1b9a1590413080ea2b (patch)
tree99f0d94a0e2240f51d0d9ed51acc571002424964
parent4d35abf62d12fa6f5877c201221f09eca620841c (diff)
dep.sh: use one function for checking installed programsdev
-rwxr-xr-xdep.sh92
1 files changed, 43 insertions, 49 deletions
diff --git a/dep.sh b/dep.sh
index 7ce898f..d4274f9 100755
--- a/dep.sh
+++ b/dep.sh
@@ -1,61 +1,55 @@
#!/bin/sh
-check()
-{
- for program in "${@}"; do
- if ! command -v "${program}" > /dev/null 2>&1; then
- echo "'${program}' is missing." >&2
- fi
- done;
-}
-check_double()
-{
- if ! command -v "${1}" > /dev/null 2>&1 && ! command -v "${2}" > /dev/null 2>&1; then
- echo "'${1}' is missing." >&2
- fi
-}
-check_with_msg()
-{
- if ! command -v "${1}" > /dev/null 2>&1; then
- echo "${2}" >&2
+# Format for entries `program,alternative_program:output_message`
+# `alternative_program` and `message` are optional
+check() {
+ for entry in "$@"; do
+ program_part=${entry%%:*}
+ program1=${program_part%%,*}
+ alt_program=${program_part#*,}
+
+ msg=${entry#*:}
+ [ "${msg}" = "${entry}" ] && msg="${program1} is missing"
+
+ if ! command -v "${program1}" > /dev/null 2>&1 && ! command -v "${alt_program}" > /dev/null 2>&1; then
+ echo "$msg" >&2
fi
+ done
}
-# Configurated programs
+# Programs
check \
- git \
- lf \
- fzf \
- mpv \
- picom \
- qutebrowser \
- zathura
-
-check_double vim nvim # If at least one exists don't print error
-check_double sxiv nsxiv
-check_double zsh bash
-
-# Programs required by the scripts
+ git \
+ lf \
+ fzf \
+ mpv \
+ picom \
+ qutebrowser \
+ zathura \
+ vim,nvim \
+ sxiv,nsxiv \
+ zsh,bash \
+ dunst \
+ scrot \
+ startx:"xorg-xinit is missing"
+
+# Script dependencies
check \
- dunst \
- scrot \
- brightnessctl
-
-check_with_msg pactl "'pulseaudio' is missing."
-
-# X11 dependencies
-check \
- xinput \
- xset \
+ brightnessctl \
+ pactl:"pulseaudio is missing" \
+ xinput \
+ xset \
+ xwallpaper \
xgamma
-check_with_msg startx "'xorg-xinit' is missing."
-
-# C X11 dependencies
-
-check_with_msg cc "c compiler is missing"
-check_with_msg ld "linker is missing"
+# Build dependencies
+check \
+ curl \
+ tar \
+ make \
+ cc:"c compiler is missing" \
+ ld:"linker is missing"
if ! command -v ld -L/usr/X11R6/lib -lX11 -lXinerama -lfontconfig -lXft > /dev/null 2>&1;then
- echo "Xorg library files missing"
+ echo "Xorg library files missing" >&2
fi