sb

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

commit 0512c5837c399c51b28680b827ccd6996641b284
parent 6dcae8d66c9461bce1d88925f12a798fbcb2a35b
Author: Cem Keylan <cem@ckyln.com>
Date:   Wed, 12 Feb 2020 14:49:19 +0300

simplify program

Diffstat:
MMakefile | 11+----------
Asb | 59+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Dsb.in | 61-------------------------------------------------------------
3 files changed, 60 insertions(+), 71 deletions(-)

diff --git a/Makefile b/Makefile @@ -5,18 +5,9 @@ BINDIR = ${PREFIX}/bin MANPREFIX = ${PREFIX}/share/man CONF = \$$HOME/.config/sbrc -all: sb - -sb: - sed 's#conffile#${CONF}#g;s#VERSION="git"#VERSION="${VERSION}"#g' sb.in > sb - chmod +x sb - -clean: - rm -f sb - install: all mkdir -p ${DESTDIR}${BINDIR} - sed 's#FUNCPATH="./func"#FUNCPATH="${PREFIX}/share/sb-func"#g' < sb > ${DESTDIR}${BINDIR}/sb + sed 's#FUNCPATH="./func"#FUNCPATH="${PREFIX}/share/sb-func"#g;s#VERSION="git"#VERSION="${VERSION}"#g' < sb > ${DESTDIR}${BINDIR}/sb chmod +x ${DESTDIR}${BINDIR}/sb install -Dm644 -t ${DESTDIR}${PREFIX}/share/sb-func func/* mkdir -p ${DESTDIR}${MANPREFIX}/man1 diff --git a/sb b/sb @@ -0,0 +1,59 @@ +#!/usr/bin/env sh +# See the LICENSE file for copyright and license details. + +FUNCPATH="./func" +VERSION="git" + +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-2020 (c) Cem Keylan +EOF +exit 0 +} + +case "$1" in v) printf '%s\n' "${0##*/}-$VERSION"; exit 0 ;; h|help|-h|--help) usage ;; n) nobar=1 ;; x) + ! [ -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 ;; esac + + +[ -e "$HOME/.config/sbrc" ] && . "$HOME/.config/sbrc" +[ -z "$DELIMETER" ] && DELIMETER="|" +[ -z "$SLEEPTIME" ] && SLEEPTIME="1" + +for func in "$FUNCPATH/"* ; do [ -f "$func" ] && . "$func"; done +for func in "$HOME/.config/sbfunc/"* ; do + [ -f "$func" ] && . "$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 @@ -1,61 +0,0 @@ -#!/usr/bin/env sh -# See the LICENSE file for copyright and license details. - -FUNCPATH="./func" -VERSION="git" - -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-2020 (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