sb

shitty bar for dwm
git clone git://git.ckyln.com/~cem/sb.git
Log | Files | Refs | README | LICENSE

commit ceaec97d6c88c84558a63140493dd9b99f2d864b
parent 8014b2ec9911cfcf9dfcbf3a2671e7c748a2adca
Author: Cem Keylan <cem@ckyln.com>
Date:   Sat, 21 Dec 2019 21:56:36 +0300

do some config on Makefile

Diffstat:
MMakefile | 22++++++++++++++++++----
Dsb | 61-------------------------------------------------------------
Asb.in | 61+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
3 files changed, 79 insertions(+), 65 deletions(-)

diff --git a/Makefile b/Makefile @@ -7,6 +7,9 @@ VERSION = 1.1 # path PREFIX = /usr/local MANPREFIX = ${PREFIX}/share/man +CONF = ~/.config/sbrc + +all: options build options: @echo Installation options for sb @@ -14,10 +17,17 @@ options: @echo MANPREFIX = ${MANPREFIX} @echo VERSION = ${VERSION} -install: - @echo Installing sb to ${DESTDIR}${PREFIX}/bin +build: + @echo Generating sb from sb.in + @rm -f sb + @sed "s#vnumber#${VERSION}#g" sb.in > sb + @sed -i "s#conffile#${CONF}#g" sb + @chmod +x sb + +install: all + @echo Installing sb ${VERSION} to ${DESTDIR}${PREFIX}/bin @mkdir -p ${DESTDIR}${PREFIX}/bin - @sed "s#getfunctionpath#${PREFIX}/share/sb-func#g" < sb | sed "s#vnumber#${VERSION}#g" > ${DESTDIR}${PREFIX}/bin/sb + @sed "s#getfunctionpath#${PREFIX}/share/sb-func#g" < sb > ${DESTDIR}${PREFIX}/bin/sb @chmod 755 ${DESTDIR}${PREFIX}/bin/sb @echo Installing sb function modules to ${DESTDIR}${PREFIX}/share/sb-func @mkdir -p ${DESTDIR}${PREFIX}/share/sb-func @@ -45,4 +55,8 @@ uninstall: @echo Removing ${DESTDIR}${PREFIX}/share/sb @rm -rf ${DESTDIR}${PREFIX}/share/sb -.PHONY: options install uninstall +clean: + @echo Removing sb + @rm -f sb + +.PHONY: all options build install uninstall clean diff --git a/sb b/sb @@ -1,61 +0,0 @@ -#!/usr/bin/env sh -# See the LICENSE file for copyright and license details. - -FUNCPATH="getfunctionpath" -VERSION="vnumber" - -usage() { - cat <<EOF -${0##*/} [options] - - Options: - -n Print to stdout instead of the bar - -x Kill existing sb instance - -h Print this help and exit - -v Print version number and exit - -${0##*/}-$VERSION -2019 (c) Cem Keylan -EOF -exit 0 -} - -if [ "$1" = "-v" ] || [ "$1" = "--version" ]; then printf "${0##*/}-$VERSION\\n"; exit 0 -elif [ "$1" = "-h" ] || [ "$1" = "--help" ]; then usage -elif [ "$1" = "-n" ]; then nobar=1 -elif [ "$1" = "-x" ]; then - ! [ -e "/tmp/sb-$USER.pid" ] && printf "There is no running instance of sb\\n" && exit 1 - kill "$(cat "/tmp/sb-$USER.pid")"; rm "/tmp/sb-$USER.pid"; exit 0 -fi - - -[ -e "$HOME/.config/sbrc" ] && . "$HOME/.config/sbrc" -[ -z "$DELIMETER" ] && DELIMETER="|" -[ -z "$SLEEPTIME" ] && SLEEPTIME="1" - -for func in "$FUNCPATH/"* ; do . "$func"; done -if [ -z "$nobar" ]; then - if [ -e "/tmp/sb-$USER.pid" ] ; then - [ -z "$KILLEXISTING" ] && printf "ERROR: sb is already running\\nIf you think otherwise, remove /tmp/sb-$USER.pid manually.\\n" && exit 1 - kill "$(cat "/tmp/sb-$USER.pid")" 2>/dev/null - fi - printf "$$\\n" > "/tmp/sb-$USER.pid" -fi - -if ! command -V bar >/dev/null 2>&1; then - bar() { - brightness - pulseaudio - battery - DELIMETER=";" datetime - storage - storage /home - ram - nightmode - gethostname - showmpd - } -fi - -[ -z "$nobar" ] && while true; do xsetroot -name " $(bar)"; sleep "$SLEEPTIME"; done && exit 0 -while true; do bar; sleep "$SLEEPTIME"; clear; done diff --git a/sb.in b/sb.in @@ -0,0 +1,61 @@ +#!/usr/bin/env sh +# See the LICENSE file for copyright and license details. + +FUNCPATH="getfunctionpath" +VERSION="vnumber" + +usage() { + cat <<EOF +${0##*/} [options] + + Options: + -n Print to stdout instead of the bar + -x Kill existing sb instance + -h Print this help and exit + -v Print version number and exit + +${0##*/}-$VERSION +2019 (c) Cem Keylan +EOF +exit 0 +} + +if [ "$1" = "-v" ] || [ "$1" = "--version" ]; then printf "${0##*/}-$VERSION\\n"; exit 0 +elif [ "$1" = "-h" ] || [ "$1" = "--help" ]; then usage +elif [ "$1" = "-n" ]; then nobar=1 +elif [ "$1" = "-x" ]; then + ! [ -e "/tmp/sb-$USER.pid" ] && printf "There is no running instance of sb\\n" && exit 1 + kill "$(cat "/tmp/sb-$USER.pid")"; rm "/tmp/sb-$USER.pid"; exit 0 +fi + + +[ -e "conffile" ] && . "conffile" +[ -z "$DELIMETER" ] && DELIMETER="|" +[ -z "$SLEEPTIME" ] && SLEEPTIME="1" + +for func in "$FUNCPATH/"* ; do . "$func"; done +if [ -z "$nobar" ]; then + if [ -e "/tmp/sb-$USER.pid" ] ; then + [ -z "$KILLEXISTING" ] && printf "ERROR: sb is already running\\nIf you think otherwise, remove /tmp/sb-$USER.pid manually.\\n" && exit 1 + kill "$(cat "/tmp/sb-$USER.pid")" 2>/dev/null + fi + printf "$$\\n" > "/tmp/sb-$USER.pid" +fi + +if ! command -V bar >/dev/null 2>&1; then + bar() { + brightness + pulseaudio + battery + DELIMETER=";" datetime + storage + storage /home + ram + nightmode + gethostname + showmpd + } +fi + +[ -z "$nobar" ] && while true; do xsetroot -name " $(bar)"; sleep "$SLEEPTIME"; done && exit 0 +while true; do bar; sleep "$SLEEPTIME"; clear; done