summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSuleyman Farajli <suleyman@farajli.net>2024-07-26 21:24:52 +0400
committerSuleyman Farajli <suleyman@farajli.net>2024-07-26 21:24:52 +0400
commit93e5e8870e9099c67a7ba17df3ea6e4faa70fad0 (patch)
tree706e48c312d98140e33f422bf6cc37c590d6771f
parent289eadf9a2a1e2ef0771d6362c281068ccafe8df (diff)
swall: err and run functions updated
-rwxr-xr-xscripts/swall19
1 files changed, 10 insertions, 9 deletions
diff --git a/scripts/swall b/scripts/swall
index d9da702..0b0a088 100755
--- a/scripts/swall
+++ b/scripts/swall
@@ -14,7 +14,9 @@ EOF
}
err() {
- echo "$*" >&2
+ for line in "${@}"; do
+ echo "${line}" >&2
+ done
exit 1
}
@@ -22,17 +24,18 @@ run() {
if ! ${1} > /dev/null 2>&1; then
err "${2}"
fi
+ exit 0
}
if ! command -v xwallpaper > /dev/null 2>&1; then
err "${0}: xwallpaper must be installed"
fi
-if [ $# = 0 ]; then
+if [ ${#} = 0 ]; then
input="${HOME}/.config/wallpapers"
-elif [ $# != 1 ] && [ $# != 2 ]; then
- err "${0}: Invalid usage
-Try '$0 -h' for help."
+elif [ ${#} != 1 ] && [ $# != 2 ]; then
+ err "${0}: Invalid usage" \
+ "Try '$0 -h' for help."
fi
while getopts "hcd:" option; do
@@ -40,7 +43,6 @@ while getopts "hcd:" option; do
c)
run "xwallpaper --clear" \
"${0}: Failed to clear wallpaper"
- exit 0
;;
d) input="${OPTARG}" ;;
@@ -57,7 +59,7 @@ if [ -n "${input}" ]; then
inode/directory) waldir="${input}" ;;
- *) err "Couldn't read given file" ;;
+ *) err "${0}: Couldn't read given file" ;;
esac
fi
@@ -68,7 +70,6 @@ fi
[ -z "${image}" ] && err "${0}: No image file found"
-run "xwallpaper --zoom ${image}" \
-"${0}: Failed to set wallpaper"
+run "xwallpaper --zoom ${image}" "${0}: Failed to set wallpaper"
echo "${image}"