From 9c349f09ca7cf103ed2e908e493b7b4632858af5 Mon Sep 17 00:00:00 2001 From: mollusk Date: Thu, 2 Feb 2017 09:55:41 -0700 Subject: [PATCH] Added colors and keybindings --- bdk.sh | 43 +++++++++++++++++++++++++++++++------------ kits/default/config | 14 +++++++++++--- 2 files changed, 42 insertions(+), 15 deletions(-) diff --git a/bdk.sh b/bdk.sh index 6819454..12455fe 100755 --- a/bdk.sh +++ b/bdk.sh @@ -3,11 +3,29 @@ # Directory containing sounds and config file KIT_DIR="kits" +# Colors +RED='\033[0;31m' +LRED="\033[1;31m" +BLUE="\033[0;34m" +LBLUE="\033[1;34m" +GREEN="\033[0;32m" +LGREEN="\033[1;32m" +YELLOW="\033[1;33m" +CYAN="\033[0;36m" +LCYAN="\033[1;36m" +PURPLE="\033[0;35m" +LPURPLE="\033[1;35m" +BWHITE="\e[1m" +NC='\033[0m' # No Color + + + #Check for kits and load the config #load default kit if specified kit not found defaultKit(){ - echo "the kit: ${1} was not found" + echo + printf "${LRED}The kit: '${1}' was not found${NC}\n" echo "Loading default kit.." echo @@ -38,7 +56,7 @@ checkKits(){ fi else - defaultKit + defaultKit ${1} fi } @@ -67,6 +85,7 @@ case $1 in ;; -l | --list) + printf "\n" printf "[ Installed Kits]\n" if [[ $(ls -A $DIR) ]];then ls ${KIT_DIR} @@ -83,35 +102,35 @@ case $1 in esac -echo "BDK - Bash Drum Kit" +printf "${LPURPLE}\(*)/ BDK - Bash Drum Kit${NC}\n" key(){ echo - echo "[d] = Bass Drum | [s] = Hi-Hat | [enter] = Snare | [h] help | [q] Quit" + printf "${LCYAN}[${KP}] = Kick${NC} | ${LGREEN}[${HHC}] = Hi-Hat Closed${NC} | ${YELLOW}[enter] = Snare${NC} | ${LPURPLE}[h] help${NC} |${LRED} [q] Quit${NC}\n" } key echo while true;do - printf "(*)> " + printf "${YELLOW}(*)>${NC} " read -s -n 1 key # -s: do not echo input character. -n 1: read only 1 character (separate with space) - if [[ $key = "d" ]]; then + if [[ $key = "${KP}" ]]; then aplay ${KICK} >/dev/null 2>/dev/null & - echo "[d] Bass Drum" - elif [[ $key == '' ]];then + printf "${LCYAN}[${KP}] Kick${NC}\n" + elif [[ $key == ${SD} ]];then aplay ${SNARE} >/dev/null 2>/dev/null & - echo "[enter] Snare Drum" - elif [[ $key == "s" ]];then + printf "${YELLOW}[${SD}] Snare Drum${NC}\n" + elif [[ $key == "${HHC}" ]];then aplay ${HIHAT} >/dev/null 2>/dev/null & - echo "[s] Hi-hat" + printf "${LGREEN}[${HHC}] Hi-Hat Closed${NC}\n" elif [[ $key == "h" ]];then key elif [[ $key == "q" ]];then exit 0; else - echo "'${key}' does nothing!" + printf "${LRED}'${key}' does nothing!${NC}\n" fi done diff --git a/kits/default/config b/kits/default/config index 8a20022..566483a 100644 --- a/kits/default/config +++ b/kits/default/config @@ -1,6 +1,14 @@ #!/bin/bash +# SOUNDS + KICK='sounds/kick.wav' + SNARE='sounds/snare.wav' + HIHAT='sounds/hihat.wav' + +# KEYBINDINGS + +KP="d" # Kick Petal +SD='' # Snare Drum (leave blank single quotes) +HHC="s" #Hi-Hat + -KICK=sounds/kick.wav -SNARE=sounds/snare.wav -HIHAT=sounds/hihat.wav