summaryrefslogtreecommitdiff
path: root/main.go
blob: dfaad2a7f26cc16e8c8bbe288f8e2689b791d660 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
package main

/*
	Author: Jackson Taylor
	Date: 3/28/2020
	Description: This is Jackson's Awesome Status Bar for suckless', very nice, dwm.
*/

import (
	"fmt"
	// "os"
	"os/exec"
	// "time"
)

// Bar is the struct that holds each of the modules and displays the data from them
type Bar struct {
	Modules []Module
}

type Module interface {
	GetInfo() (string, error)
}

var BarModules = []Module{
	DateModule{},
	BatteryModule{},
}

func main() {

	main := Bar{
		Modules: BarModules,
	}
	fmt.Println("Bar Started")

	var value string

	for {
		value = ""
		for _, b := range main.Modules {
			p1, err := b.GetInfo()
			if err != nil {
				fmt.Println(err)
				continue
			}
			value += "[" + p1 + "]"
		}

		setBar(value)
	}
}

func getBattery() string {
	return "100 %"
}

func setBar(value string) (err error) {
	err = exec.Command("xsetroot", "-name", value).Run()
	return err
}