hbspbar

[WIP] bspwm status bar
git clone https://hhvn.uk/hbspbar
git clone git://hhvn.uk/hbspbar
Log | Files | Refs

commit 0e385d244de19900df25f1c88f29c3cece6106cb
parent 17227e7c4be855b3129d58918e59594a2980e2fc
Author: hhvn <dev@hhvn.uk>
Date:   Sat, 30 Dec 2023 14:16:02 +0000

Create bspc.Cmd() function

Diffstat:
Mbspc/bspc.go | 44+++++++++++++++++++++++++-------------------
1 file changed, 25 insertions(+), 19 deletions(-)

diff --git a/bspc/bspc.go b/bspc/bspc.go @@ -1,8 +1,9 @@ package bspc // import "hhvn.uk/hbspbar/bspc" import ( - "fmt" "io" + "fmt" + "time" "bufio" "strings" "os/exec" @@ -36,24 +37,8 @@ type Monitor struct { } func (m *Monitor) TopPadding(px uint) { - cmd := exec.Command("bspc", "config", - "-m", fmt.Sprintf("%d", m.ID), - "top_padding", fmt.Sprintf("%d", px)) - - pipe, _ := cmd.StderrPipe() - scan := bufio.NewScanner(pipe) - - cmd.Start() - - for scan.Scan() { - common.Error("%s\n", scan.Text()) - } - - if err := scan.Err(); err != nil { - common.Perror("scan.Err", err) - } - - cmd.Wait() + Cmd("config", "-m", fmt.Sprintf("%d", m.ID), + "top_padding", fmt.Sprintf("%d", px)) } type Rect struct { @@ -207,6 +192,27 @@ func init() { }}() } +func Cmd(args ...string) { + cmd := exec.Command("bspc", args...) + + pipe, _ := cmd.StderrPipe() + scan := bufio.NewScanner(pipe) + startt := time.Now() + + cmd.Start() + + for scan.Scan() { + common.Error("[Started %v] `bspc %v`: %v\n", + startt.Format("15:04:05.00"), args, scan.Text()) + } + + if err := scan.Err(); err != nil { + common.Perror("scan.Err", err) + } + + cmd.Wait() +} + func Cleanup() { Handle.cmd.Process.Kill() }