Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ecode="\033["
- yellow="${ecode}1;33m"
- darkyellow="${ecode}0;33m"
- red="${ecode}1;31m"
- darkred="${ecode}0;31m"
- endcolor="${ecode}0m"
- green="${ecode}1;32m"
- darkgreen="${ecode}1;32m"
- blue="${ecode}1;34m"
- darkblue="${ecode}0;34m"
- cyan="${ecode}0;36"
- darkcyan="${ecode}0;36"
- gray="${ecode}0;37"
- purple="${ecode}1;35"
- darkpurple="${ecode}0;35"
- # Back compatability w. old scripts
- export YELLOW="$yellow"
- export RED="$red"
- export ENDCOLOR="$endcolor"
- export GREEN="$green"
- export BLUE="$blue"
- anim=(
- "${blue}•${green}•${red}•${magenta}• "
- " ${green}•${red}•${magenta}•${blue}• "
- " ${red}•${magenta}•${blue}•${green}• "
- " ${magenta}•${blue}•${green}•${red}• "
- " ${blue}•${green}•${red}•${magenta}•"
- )
- anim::start_animation () {
- # Description:
- # A simple function to display and animation during a silent acton
- #
- # Globals:
- # Arguments:
- # Outputs: Standard out
- # Returns:
- # Usage:
- # oem::start_animation ; EXPRESSION of COMMAND or FUNCTION
- # oem::stop_animation
- #
- # End of documentation
- setterm -cursor off
- export ANIM_PID="0"
- (
- while true; do
- for i in {0..4}; do
- printf "\r\033[2K ${anim[i]}"
- sleep 0.1
- done
- for i in {4..0}; do
- printf "\r\033[2K ${anim[i]}"
- sleep 0.1
- done
- done
- ) &
- export ANIM_PID="${!}"
- }
- test_me () {
- write_warning "WARNING: blablablabla"
- anim::start_animation; sleep 5; anim::stop_animation
- }
- anim::stop_animation () {
- # Description:
- # A simple function to STOP display and animation during a silent acton
- #
- # Globals:
- # Arguments:
- # Outputs: Standard out
- # Returns:
- # Usage:
- # oem::start_animation ; EXPRESSION of COMMAND or FUNCTION
- # oem::stop_animation
- #
- # End of documentation
- [[ -e "/proc/${ANIM_PID}" ]] && kill SIGPIPE "${ANIM_PID}" &>/dev/null
- setterm -cursor on
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement