summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDerek Taylor <derek@distrotube.com>2022-02-21 12:49:08 -0600
committerDerek Taylor <derek@distrotube.com>2022-02-21 12:49:08 -0600
commit9b3fc956a6667272851a72be5e35210753ea55ac (patch)
tree2c027ce950d35afcb081e52b1fca194ca7d9c95e
parentUpdating PKGBUILD. (diff)
Separating animated and non-animated colorscripts.
-rwxr-xr-xanimated-colorscripts/bomber (renamed from colorscripts/bomber)0
-rwxr-xr-xanimated-colorscripts/pipes1 (renamed from colorscripts/pipes1)0
-rwxr-xr-xanimated-colorscripts/pipes2 (renamed from colorscripts/pipes2)0
-rwxr-xr-xanimated-colorscripts/pipes2-slim (renamed from colorscripts/pipes2-slim)0
-rw-r--r--colorscript.18
-rwxr-xr-xcolorscript.sh27
6 files changed, 31 insertions, 4 deletions
diff --git a/colorscripts/bomber b/animated-colorscripts/bomber
index 3c632ed..3c632ed 100755
--- a/colorscripts/bomber
+++ b/animated-colorscripts/bomber
diff --git a/colorscripts/pipes1 b/animated-colorscripts/pipes1
index 70a751e..70a751e 100755
--- a/colorscripts/pipes1
+++ b/animated-colorscripts/pipes1
diff --git a/colorscripts/pipes2 b/animated-colorscripts/pipes2
index c658f37..c658f37 100755
--- a/colorscripts/pipes2
+++ b/animated-colorscripts/pipes2
diff --git a/colorscripts/pipes2-slim b/animated-colorscripts/pipes2-slim
index 7b26506..7b26506 100755
--- a/colorscripts/pipes2-slim
+++ b/animated-colorscripts/pipes2-slim
diff --git a/colorscript.1 b/colorscript.1
index e4eb4a2..6911a41 100644
--- a/colorscript.1
+++ b/colorscript.1
@@ -21,10 +21,16 @@ Print this help.
List all installed color scripts.
.SS "-r, --random, random"
.PP
-Run a random color script.
+Run a random NON-ANIMATED color script.
+.SS "-R, --random-animated, random-animated"
+.PP
+Run a random ANIMATED color script.
.SS "-e, --exec, exec"
.PP
Run specified color script by SCRIPT NAME or INDEX.
+.SS "-a, --all, all"
+.PP
+Print all NON-ANIMATED color scripts with their script name.
.SH "FILES"
.SS "/usr/bin/colorscript"
diff --git a/colorscript.sh b/colorscript.sh
index 3d30375..97e70e8 100755
--- a/colorscript.sh
+++ b/colorscript.sh
@@ -9,6 +9,13 @@ else
LS_CMD="$(command -v ls) ${DIR_COLORSCRIPTS}"
fi
+DIR_ANIMATED_COLORSCRIPTS="/opt/shell-color-scripts/animated-colorscripts"
+if command -v find &>/dev/null; then
+ LS_CMD="$(command -v find) ${DIR_ANIMATED_COLORSCRIPTS} -maxdepth 1 -type f"
+else
+ LS_CMD="$(command -v ls) ${DIR_ANIMATED_COLORSCRIPTS}"
+fi
+
list_colorscripts="$($LS_CMD | xargs -I $ basename $ | cut -d ' ' -f 1 | nl)"
length_colorscripts="$($LS_CMD | wc -l)"
@@ -20,10 +27,11 @@ function _help() {
printf "${fmt_help}" \
"-h, --help, help" "Print this help." \
"-l, --list, list" "List all installed color scripts." \
- "-r, --random, random" "Run a random color script." \
+ "-r, --random, random" "Run a random NON-ANIMATED color script." \
+ "-R, --random-animated, random-animated" "Run a random ANIMATED color script." \
"-e, --exec, exec" "Run a specified color script by SCRIPT NAME or INDEX."\
"-b, --blacklist, blacklist" "Blacklist a color script by SCRIPT NAME or INDEX." \
- "-a, --all, all" "List the outputs of all colorscripts with their SCRIPT NAME"
+ "-a, --all, all" "List the outputs of all NON-ANIMATED colorscripts with their SCRIPT NAME"
}
function _list() {
@@ -41,6 +49,16 @@ function _random() {
exec "${DIR_COLORSCRIPTS}/${random_colorscript}"
}
+function _random_animated() {
+ declare -i random_index=$RANDOM%$length_colorscripts
+ [[ $random_index -eq 0 ]] && random_index=1
+
+ random_colorscript="$(echo "${list_colorscripts}" | sed -n ${random_index}p \
+ | tr -d ' ' | tr '\t' ' ' | cut -d ' ' -f 2)"
+ # echo "${random_colorscript}"
+ exec "${DIR_ANIMATED_COLORSCRIPTS}/${random_colorscript}"
+}
+
function ifhascolorscipt() {
[[ -e "${DIR_COLORSCRIPTS}/$1" ]] && echo "Has this color script."
}
@@ -104,9 +122,12 @@ case "$#" in
-l | --list | list)
_list
;;
- -r | --random | random)
+ -r | --random-static | random)
_random
;;
+ -R | --random-animated | random-animated)
+ _random_animated
+ ;;
-a | --all | all)
_run_all
;;