Skip to content

Commit

Permalink
colorized output
Browse files Browse the repository at this point in the history
  • Loading branch information
graysky2 committed Dec 1, 2012
1 parent 5bb8379 commit 0d214c5
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 15 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG
@@ -1,3 +1,7 @@
v2.14
01-Dec-2012
Colorized output.

v2.13 v2.13
17-Nov-2012 17-Nov-2012
Clean up stats view. Clean up stats view.
Expand Down
36 changes: 21 additions & 15 deletions backdrop-randomizer
Expand Up @@ -7,6 +7,10 @@
# #
# see manpage for usage # see manpage for usage
# #

VERS="2.14"
export BLD="\e[01m" RED="\e[01;31m" GRN="\e[01;32m" YLW="\e[01;33m" NRM="\e[00m"

[[ -z "$XDG_CONFIG_HOME" ]] && XDG_CONFIG_HOME="$HOME/.config" # make sure env var is setup correctly [[ -z "$XDG_CONFIG_HOME" ]] && XDG_CONFIG_HOME="$HOME/.config" # make sure env var is setup correctly
cfg_file=$XDG_CONFIG_HOME/backdrop-randomizer.conf cfg_file=$XDG_CONFIG_HOME/backdrop-randomizer.conf


Expand Down Expand Up @@ -106,11 +110,11 @@ check() {
} }


stats() { stats() {
echo " Number of pics left before next cycle: $howmany" echo -e " ${BLD}Pics left before next db refresh: ${NRM}${GRN}$howmany"${NRM}
echo echo
echo " Database: $pic_database" echo -e " ${BLD}Database: ${NRM}${RED}$pic_database"${NRM}
echo " Current pic: $(readlink -f $SLINK_DIR/backdrop-randomizer.jpg)" echo -e " ${BLD}Current: ${NRM}${GRN}$(readlink -f $SLINK_DIR/backdrop-randomizer.jpg)"${NRM}
echo " Symlink: $SLINK_DIR/backdrop-randomizer.jpg" echo -e " ${BLD}Symlink: ${NRM}${YLW}$SLINK_DIR/backdrop-randomizer.jpg"${NRM}
} }


list() { list() {
Expand Down Expand Up @@ -152,16 +156,15 @@ randomize() {


add() { add() {
if [[ -z "$arg" ]]; then if [[ -z "$arg" ]]; then
echo "You must provide a supported image." echo -e "${RED}You must provide a supported image."${NRM}
exit 1 exit 1
fi fi


file=$(/usr/bin/readlink -f "$arg") file=$(/usr/bin/readlink -f "$arg")
if [[ -n $(echo "$file"| grep -E '*.jpg|*.JPG|*.gif|*.GIF|*.png|*.PNG') ]]; then if [[ -n $(echo "$file"| grep -E '*.jpg|*.JPG|*.gif|*.GIF|*.png|*.PNG') ]]; then
# check for dups # check for dups
if [[ -n $(grep "$file" "$pic_database") ]]; then if [[ -n $(grep "$file" "$pic_database") ]]; then
echo " File already exists in db." echo -e " ${RED}$file${NRM}${BLD} already exists in db. Refusing to add it twice."${NRM}
echo " Refusing to add it twice."
exit 1 exit 1
fi fi


Expand Down Expand Up @@ -191,13 +194,16 @@ case "$1" in
check ; cycle ; randomize ;; check ; cycle ; randomize ;;
*) *)
check check
echo -en "\E[31musage: " echo -e "${RED}backdrop-randomizer v$VERS"${NRM}
tput sgr0 # reset colors to normal echo
echo "$0 {r|s|l|a|c}" echo -e "${BLD} $0${NRM} ${GRN}{r|s|l|a|c}${NRM}"
echo "r) select a pic at (R)andom from the database." echo
echo "s) display database (S)tats." echo -e "${BLD} r) ${GRN}R${NRM}${BLD}andomly select a pic from the database and refresh xfdesktop."
echo "l) (L)ist all pics in the database." echo -e "${BLD} s) Display database ${GRN}s${NRM}${BLD}tatistics."
echo "a) (A) the next token to database." echo -e "${BLD} l) ${GRN}L${NRM}${BLD}ist all pics in the database."
echo "c) (C)lear or (C)ycle the database and start anew." echo -e "${BLD} a) ${GRN}A${NRM}${BLD}dd the next token to database."
echo -e "${BLD} c) ${GRN}C${NRM}${BLD}lear the database and start anew."${NRM}
echo
echo -e " Add all new pics to the database: ${YLW}find -L /path/to/pics -type f -mtime -1 | xargs -n1 bdr a"${NRM}
;; ;;
esac esac

0 comments on commit 0d214c5

Please sign in to comment.