Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

colorized output

  • Loading branch information...
commit 0d214c543287e2ec53cf132ca1866e2d711a7fea 1 parent 5bb8379
@graysky2 authored
Showing with 25 additions and 15 deletions.
  1. +4 −0 CHANGELOG
  2. +21 −15 backdrop-randomizer
View
4 CHANGELOG
@@ -1,3 +1,7 @@
+v2.14
+01-Dec-2012
+Colorized output.
+
v2.13
17-Nov-2012
Clean up stats view.
View
36 backdrop-randomizer
@@ -7,6 +7,10 @@
#
# 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
cfg_file=$XDG_CONFIG_HOME/backdrop-randomizer.conf
@@ -106,11 +110,11 @@ check() {
}
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 " Database: $pic_database"
- echo " Current pic: $(readlink -f $SLINK_DIR/backdrop-randomizer.jpg)"
- echo " Symlink: $SLINK_DIR/backdrop-randomizer.jpg"
+ echo -e " ${BLD}Database: ${NRM}${RED}$pic_database"${NRM}
+ echo -e " ${BLD}Current: ${NRM}${GRN}$(readlink -f $SLINK_DIR/backdrop-randomizer.jpg)"${NRM}
+ echo -e " ${BLD}Symlink: ${NRM}${YLW}$SLINK_DIR/backdrop-randomizer.jpg"${NRM}
}
list() {
@@ -152,7 +156,7 @@ randomize() {
add() {
if [[ -z "$arg" ]]; then
- echo "You must provide a supported image."
+ echo -e "${RED}You must provide a supported image."${NRM}
exit 1
fi
@@ -160,8 +164,7 @@ add() {
if [[ -n $(echo "$file"| grep -E '*.jpg|*.JPG|*.gif|*.GIF|*.png|*.PNG') ]]; then
# check for dups
if [[ -n $(grep "$file" "$pic_database") ]]; then
- echo " File already exists in db."
- echo " Refusing to add it twice."
+ echo -e " ${RED}$file${NRM}${BLD} already exists in db. Refusing to add it twice."${NRM}
exit 1
fi
@@ -191,13 +194,16 @@ case "$1" in
check ; cycle ; randomize ;;
*)
check
- echo -en "\E[31musage: "
- tput sgr0 # reset colors to normal
- echo "$0 {r|s|l|a|c}"
- echo "r) select a pic at (R)andom from the database."
- echo "s) display database (S)tats."
- echo "l) (L)ist all pics in the database."
- echo "a) (A) the next token to database."
- echo "c) (C)lear or (C)ycle the database and start anew."
+ echo -e "${RED}backdrop-randomizer v$VERS"${NRM}
+ echo
+ echo -e "${BLD} $0${NRM} ${GRN}{r|s|l|a|c}${NRM}"
+ echo
+ echo -e "${BLD} r) ${GRN}R${NRM}${BLD}andomly select a pic from the database and refresh xfdesktop."
+ echo -e "${BLD} s) Display database ${GRN}s${NRM}${BLD}tatistics."
+ echo -e "${BLD} l) ${GRN}L${NRM}${BLD}ist all pics in the database."
+ 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
Please sign in to comment.
Something went wrong with that request. Please try again.