soumya92 / barista

An i3status alternative in golang
Apache License 2.0
302 stars 44 forks source link

Keyboard layout indicator \ switching implementation [RFC] #16

Closed glebtv closed 6 years ago

glebtv commented 6 years ago

I've implemented a keyboard layout indicator via XGB

https://github.com/glebtv/custom_barista/tree/master/kbdlayout

It includes proper layout change notifications via xevent and switching layout on indicator click.

I do not feel it is good enough quality to send it as a pull request here (XGB does not include XKEYBOARD extension, I had to implement it, and it includes raw x server protocol messages sniffed via x11trace from other keyboard utilities etc - might have been better with using xkeyboard.cpp via cgo...), but I want to post it here so someone interested in this might use it or even make it better.

Thank you for a great i3status replacement by the way :)

soumya92 commented 6 years ago

You don't need to send a pull request, because if someone is interested in trying out your module, they can directly import it into their bar:

import "github.com/glebtv/custom_barista/kbdlayout"
// ...
keyboard = kbdlayout.New()
// ...
bar.Run(..., keyboard, ...)

I'm glad you found this project useful. One of my goals was to make it easy(-ish) for people to write their own modules, so I'd appreciate any feedback you have about your experience in doing that.

glebtv commented 6 years ago

Making a custom module was pretty easy for me, but more advanced configuration (pango, colors, etc) was not very easy as there are lots of types it's not obvious which types can be added to what (bar.Segment, bar.Output, pango.element, pango.text, outputs.Composite)

Some modules lack examples or readme (disk, diskio) and it's not obvious that you need to add to the bar not diskio.New() but diskio.New().Disk(name) (and I think they do not show any errors if you add diskio itself but show nothing), probably will be useful to add a debug flag to show all errors and modules with no output with debug output.

Loading icons is not straightforward, it shows no errors and I had to find proper file names for symbols index files from the code.

Also would be nice to have a default implementation that can read some config file to show a useful bar without any code (and provide a compiled release of it via github releases).

For what I mean about examples/readme/config file take a look at i3status-rust docs https://github.com/greshake/i3status-rust/wiki/Development https://github.com/greshake/i3status-rust/blob/master/blocks.md

soumya92 commented 6 years ago

That's great feedback! I've opened issues/project items to track them. The sample bar is intended to run out of the box and provide a sane default implementation, so maybe I just need to add a quickstart section to the documentation.

soumya92 commented 6 years ago

Quickstart is live, sample-bar is trying to be increasingly more usable without any configuration (e.g. pick default network interface, check for battery existence, geolocate weather).

Examples are up for most of the barista packages, providing examples of how to use the pango functionality. It's also slightly easier to use now.

The modules have also been changed to be a consistent export interface (no more "New().Disk()", which was objectively terrible). There are also examples of how to construct each module on the docs website.