added beets config and improved lemonbar

This commit is contained in:
Enrico Fasoli 2015-08-28 13:41:44 +00:00
parent 6676dbb3e6
commit de469a185a
5 changed files with 159 additions and 10 deletions

4
beets_config.yaml Normal file
View File

@ -0,0 +1,4 @@
directory: ~/Music
library: ~/.config/beets/library.blb
paths:
singleton: Singles/$artist/$title

103
bin/spark Executable file
View File

@ -0,0 +1,103 @@
#!/usr/bin/env bash
#
# spark
# https://github.com/holman/spark
#
# Generates sparklines for a set of data.
#
# Here's a good web-based sparkline generator that was a bit of inspiration
# for spark:
#
# https://datacollective.org/sparkblocks
#
# spark takes a comma-separated or space-separated list of data and then prints
# a sparkline out of it.
#
# Examples:
#
# spark 1 5 22 13 53
# # => ▁▁▃▂▇
#
# spark 0 30 55 80 33 150
# # => ▁▂▃▅▂▇
#
# spark -h
# # => Prints the spark help text.
# Generates sparklines.
#
# $1 - The data we'd like to graph.
_echo()
{
if [ "X$1" = "X-n" ]; then
shift
printf "%s" "$*"
else
printf "%s\n" "$*"
fi
}
spark()
{
local n numbers=
# find min/max values
local min=0xffffffff max=0
for n in ${@//,/ }
do
# on Linux (or with bash4) we could use `printf %.0f $n` here to
# round the number but that doesn't work on OS X (bash3) nor does
# `awk '{printf "%.0f",$1}' <<< $n` work, so just cut it off
n=${n%.*}
(( n < min )) && min=$n
(( n > max )) && max=$n
numbers=$numbers${numbers:+ }$n
done
# print ticks
local ticks=(▁ ▂ ▃ ▄ ▅ ▆ ▇ █)
# use a high tick if data is constant
(( min == max )) && ticks=(▅ ▆)
local f=$(( (($max-$min)<<8)/(${#ticks[@]}-1) ))
(( f < 1 )) && f=1
for n in $numbers
do
_echo -n ${ticks[$(( ((($n-$min)<<8)/$f) ))]}
done
_echo
}
# If we're being sourced, don't worry about such things
if [ "$BASH_SOURCE" == "$0" ]; then
# Prints the help text for spark.
help()
{
local spark=$(basename $0)
cat <<EOF
USAGE:
$spark [-h|--help] VALUE,...
EXAMPLES:
$spark 1 5 22 13 53
▁▁▃▂█
$spark 0,30,55,80,33,150
▁▂▃▄▂█
echo 9 13 5 17 1 | $spark
▄▆▂█▁
EOF
}
# show help for no arguments if stdin is a terminal
if { [ -z "$1" ] && [ -t 0 ] ; } || [ "$1" == '-h' ] || [ "$1" == '--help' ]
then
help
exit 0
fi
spark ${@:-`cat`}
fi

View File

@ -41,9 +41,14 @@ cp .gitconfig ~/
mkdir -p ~/.config/mpd
mkdir -p ~/Music/
# beets
mkdir -p ~/.config/beets
cp beets_config.yaml ~/.config/beets/config.yaml
# ncmpcpp
mkdir -p ~/.config/ncmpcpp
cp ncmpcpp_config ~/.config/ncmpcpp/
cp ncmpcpp_config ~/.config/ncmpcpp/config
echo "Run install-prezto with ZSH to install prezto"

View File

@ -1,33 +1,68 @@
GREY="#5f5f5f"
WHITE="#9b9081"
WHITE2="#b3b3b3"
BLACK="#181b20"
RED="#6b4a49"
BLUE="#435861"
GREEN="#6f6749"
GREEN2="#6d6137"
BROWN="#776049"
buildClock() {
echo -n $(date "+%A, %e %B, %k:%M:%S")
echo -n "%{F$WHITE2}$(date "+%A, %e %B, %k:%M:%S")"
}
getVolume() {
echo -n "$(amixer get Master | cut -d$'\n' -f 5 | cut -d ' ' -f 8) $(amixer get Master | sed -n 's/^.*\[\([0-9]\+\)%.*$/\1/p' | uniq)%%"
ONOFF=$(amixer get Master | cut -d$'\n' -f 5 | cut -d ' ' -f 8)
VOLUME=$(amixer get Master | sed -n 's/^.*\[\([0-9]\+\)%.*$/\1/p' | uniq)
COLOR=
if [ $ONOFF == "[off]" ]; then
COLOR=$RED
elif [ $VOLUME -gt 60 ]; then
COLOR=$GREEN2
elif [ $VOLUME -gt 35 ]; then
COLOR=$GREEN
else
COLOR=$GREY
fi
VOLUME=$(spark $VOLUME 0 100 | tail -n 1 | cut -b1-3)
echo -n "$(separator) %{F$COLOR}$VOLUME $(separator)"
}
getMPD(){
echo -n "♫ "
echo -n "%{F$BLUE}"
if [ "$(mpc | wc -l)" -gt 1 ]; then
echo -n "$(mpc | cut -d$'\n' -f1)$(mpc | cut -d$'\n' -f2)"
echo -n "%{F$BROWN}$(mpc | cut -d$'\n' -f1) %{F$BLUE}%{F$GREY}$(mpc | cut -d$'\n' -f2)"
fi
}
getNET(){
echo -n "$(curl -s http://canihazip.com/s)"
if [ ! -f /tmp/myip ]; then
echo "$(curl -s --connect-timeout 1 http://canihazip.com/s)" > /tmp/myip
fi
IP="$(cat /tmp/myip)"
if [ -n "$IP" ]; then
echo -n "%{F$GREEN}$IP"
else
echo -n "%{F$RED}Offline"
fi
}
getDISK(){
echo -n "$(du -hs ~ | cut -d$'\t' -f1)"
echo -n "%{F$BLUE}$(echo "$(du -ms ~ | cut -d$'\t' -f1)/1000" | bc) GB"
}
separator(){
echo -n "%{F$GREY}◆"
}
buildBar () {
while true
do
echo "$(getVolume) $(getMPD) %{c}$(buildClock)%{r}$(getDISK) | $(getNET)"
sleep 0.5
echo " $(getVolume) $(getMPD) %{c}$(buildClock) %{r} $(getDISK) $(separator) $(getNET) "
sleep 1
done
}
buildBar | lemonbar -p -g "1872x20+24+8" -B "#181b20" -F "#9b9081" -f -gohu-gohufont-medium-r-normal--14-100-100-100-c-80-iso10646-1
buildBar | lemonbar -p -g "1872x20+24+8" -B "$BLACK" -F "$GREY" -f -gohu-gohufont-medium-r-normal--14-100-100-100-c-80-iso10646-1

View File

@ -1,4 +1,6 @@
ncmpcpp_directory = ~/.config/ncmpcpp
mpd_music_dir = ~/Music
lyrics_directory = ~/.config/ncmpcpp/lyrics
visualizer_type = "spectrum"
progressbar_look = "─╼─"