Skip to content
This repository has been archived by the owner on Jul 5, 2024. It is now read-only.

Add config.go #3

Closed
Sacules opened this issue Jan 14, 2019 · 6 comments
Closed

Add config.go #3

Sacules opened this issue Jan 14, 2019 · 6 comments

Comments

@Sacules
Copy link

Sacules commented Jan 14, 2019

I'd suggest a file with some customizable values in the same vein of suckless programs, for example:

const (
	barX = 0
	barY = 0
	barW = 200
	barH = 15
	font = "FuraMono Nerd Font Mono:pixelsize=11.5:antialias=true:autohint=true:width=1"
)
@CamilleScholtz
Copy link
Owner

CamilleScholtz commented Jan 14, 2019

There are other such values (see: #1), I'll try creating something like this.

I'm still not sure what the best format would be, would individual blocks (their colors and such) also be configurable ins such a way?

@CamilleScholtz
Copy link
Owner

CamilleScholtz commented Jan 14, 2019

Furthermore should it be possible to disable entire blocks from this config file? Example, what if someone doesn't use mpd and wants to disable the music bar (#2).

@Sacules
Copy link
Author

Sacules commented Jan 14, 2019

I think that'd be the best approach, although it'd be simpler if we change the bar's sync.Map to a slice of blocks like this (which can be placed in config.go), for example:

var blocks = []*Block{
	&Block{
		txt:   "foo",
		w:     10,
		align: 'r',
		xoff:  2,
		bg:    "#445967",
		fg:    "#CCCCCC",
		actions: map[string]func() error{
			"button1": func() error { return foo() },
			"button2": func() error { return bar() },
		},
	},
	&Block{
		txt:   "biz",
		w:     15,
		align: 'a',
		xoff:  0,
		bg:    "#3C4F5B",
		fg:    "#CCCCCC",
		actions: map[string]func() error{
			"button1": func() error { return foo() },
			"button2": func() error { return bar() },
		},
	},
}

which then each can be moved around and put together with a simpler initBlock method and drawn when initializing the bar. foo() and bar() can be declared at the bottom of the file or maybe in a actions.go file.

@CamilleScholtz
Copy link
Owner

I've been working on something like this, an example of the "clock block":

	blocks.Set("clock", &Block{
		txt:   "?",
		w:     799,
		align: 'a',
		xoff:  0,
		bg:    xgraphics.BGRA{B: 103, G: 89, R: 68, A: 0xFF},
		fg:    xgraphics.BGRA{B: 204, G: 204, R: 204, A: 0xFF},

		update: func() {
			for {
				block, _ := blocks.Get("clock")
				block.(*Block).txt = time.Now().Format(
					"Monday, January 2th 03:04 PM")

				// Redraw the block.
				bar.redraw <- block.(*Block)

				// Update every 45 seconds.
				time.Sleep(45 * time.Second)
			}
		},
	})

@alexmozaidze
Copy link

And there's still no config.go. Reality is cruel.

@CamilleScholtz
Copy link
Owner

it's just under a different name: https://github.com/onodera-punpun/melonbar/blob/master/blocks.go

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants