Code Monkey home page Code Monkey logo

leechbar's Introduction

[DEPRECATED]

This project never reached a usable state and is not developed anymore.

leechbar's People

Contributors

chrisduerr avatar adamniederer avatar

Stargazers

Angel Pons avatar Hirokazu Hata avatar Mitchell Garvin avatar NightYagi avatar  avatar  avatar Ayose C. avatar QuietMisdreavus avatar  avatar

Watchers

James Cloos avatar  avatar  avatar

Forkers

txuritan lroobrou

leechbar's Issues

Update documentation

The performance rework has changed the API quite a bit. All the docs should be re-checked and stuff that is new/changed should be fixed.

Simple example panics

Hey, thanks for making this library! I'm encountering a panic when I try to run any examples.

thread 'main' panicked at 'Unable to get primary output crtc information: Error { ptr: 0x7f977da454b0 }', libcore/result.rs:945:5
stack backtrace:
   0:     0x564aff54689b - std::sys::unix::backtrace::tracing::imp::unwind_backtrace::h085b5cb2919943dc
                               at libstd/sys/unix/backtrace/tracing/gcc_s.rs:49
   1:     0x564aff54d280 - std::sys_common::backtrace::print::he25c82f98f7aac81
                               at libstd/sys_common/backtrace.rs:71
                               at libstd/sys_common/backtrace.rs:59
   2:     0x564aff53d500 - std::panicking::default_hook::{{closure}}::hc30a4462d8c591a0
                               at libstd/panicking.rs:380
   3:     0x564aff53d257 - std::panicking::default_hook::hcb9c5feec9166013
                               at libstd/panicking.rs:396
   4:     0x564aff53d94b - std::panicking::rust_panic_with_hook::h9f5570af4bf0234b
                               at libstd/panicking.rs:576
   5:     0x564aff53d80e - std::panicking::begin_panic::hc973540f5677dae3
                               at libstd/panicking.rs:537
   6:     0x564aff53d70a - std::panicking::begin_panic_fmt::habd3beed8a63031a
                               at libstd/panicking.rs:521
   7:     0x564aff53d6a2 - rust_begin_unwind
                               at libstd/panicking.rs:497
   8:     0x564aff58ffb0 - core::panicking::panic_fmt::hc0bf389917b16633
                               at libcore/panicking.rs:71
   9:     0x564aff429c38 - core::result::unwrap_failed::h393f698bfb8cccb1
                               at /checkout/src/libcore/macros.rs:23
  10:     0x564aff428d3d - <core::result::Result<T, E>>::expect::hedaa7ff381d77d38
                               at /checkout/src/libcore/result.rs:809
  11:     0x564aff418120 - leechbar::bar::primary_screen_info::hc0b8df8c6c679a04
                               at src/bar.rs:408
  12:     0x564aff417449 - leechbar::bar::screen_info::hf2927b171988f0cb
                               at src/bar.rs:340
  13:     0x564aff414892 - leechbar::bar::Bar::new::h8015909145a37f91
                               at src/bar.rs:54
  14:     0x564aff413ff9 - leechbar::builder::BarBuilder::spawn::h2fef54c5fb31fda4
                               at src/builder.rs:223
  15:     0x564aff401b88 - simple::main::hf3b013c8a12622df
                               at examples/simple.rs:26
  16:     0x564aff401788 - std::rt::lang_start::{{closure}}::haa29a9e489c2bc6c
                               at /checkout/src/libstd/rt.rs:74
  17:     0x564aff53d607 - std::panicking::try::do_call::hb11c25abdfc27ad2
                               at libstd/rt.rs:59
                               at libstd/panicking.rs:479
  18:     0x564aff55520e - __rust_maybe_catch_panic
                               at libpanic_unwind/lib.rs:102
  19:     0x564aff541c83 - std::rt::lang_start_internal::ha082c8a960712b5c
                               at libstd/panicking.rs:458
                               at libstd/panic.rs:358
                               at libstd/rt.rs:58
  20:     0x564aff401774 - std::rt::lang_start::hd8ed062ce71df610
                               at /checkout/src/libstd/rt.rs:74
  21:     0x7f9780ec9f49 - __libc_start_main
  22:     0x564aff3f8e89 - _start
  23:                0x0 - <unknown>

xrandr output:

HDMI-A-3 connected 1920x1080+0+0 (0xa8) normal (normal left inverted right x axis y axis) 509mm x 286mm
	Subpixel:   horizontal rgb
	Gamma:      1.0:1.0:1.0
	Brightness: 1.0
	Clones:    
	CRTC:       0
	CRTCs:      0 1 2 3 4 5

library versions:

libxcb 1.12-1
libxrandr 1.5.1-2
xorg-server 1.19.6+13+gd0d1a694f-1

Let me know if I can provide any other info that might assist in debugging.

Flickering

With components that redraw frequently there seems to be some flickering. It might be a good idea to not clear components when the background doesn't change.

Remove ordinal

It's intuitive that components are added to the bar in the order of the bar::add call in the source. It's not necessary to have the ordinal exposed to the user, this is just confusing and unintuitive.

The ordinal should probably still be used internally, but it should be calculated automatically when calling bar::add.

Add layers

Being able to use multiple pictures and compose them together could significantly lower the cost of creating images for the user.

This could be done with a layers system that renders in order. Every time Background::image is called, a new layer is added that is drawn above the previous layers.

Expand examples

Getting started with a library like leechbar can be quite complicated, because everything is specific to the library itself. However examples have a high value because they are easy to reuse and expand. This is why it should be a priority to cover most common tasks with examples.

Some examples that should be added are:

  • Time component
  • Volume component

Background Color broken

Background color does not work anymore. It only sets a color for all components, instead of setting a color for the whole bar.

Global yoffset

If the user has an underline below the whole bar, he might just want to set the yoffset once. It's probably a good idea to allow a global yoffset. And when the yoffset of a component is set, the global one should be ignored completely and the component offset should be used.

This should make it easy to do BarBuilder::new().yoffset(-5.) without having to worry about the offset of anything else.

Improve mouse events

Right now mouse events only allow checking if a button has been clicked, it is not possible to detect a button that is being held down.

It should be possible to detect this. The easiest way to do so is having two separate events, one for button down, one for button up.

Improve logging

A proper logging system is setup already, but it's barely used. There should be messages for stuff like events received, component redrawn etc.
This would probably make debugging easier and just helps figuring out what's going on right now.

Update method on the component struct

Right now every call can update the component, so the order in which functions like background and foreground are called is important. This might make it harder for the user to expect what will happen when modifying self in these methods.

As a possible solution having an update method that is run as the first thing with access to &mut self and every other method only having access to &self would be one viable option. Like that, the state of a component can't be changed in unexpected ways (unless the user really wants to go for it with stuff like lazy static).

Spawning multiple bars

Spawning multiple bars doesn't seem to work properly. Right now it is required to start the binary multiple times if you want to have multiple bars.

Performance

Right now the bar works, but the price for that is incredibly hight. For a normal setup the CPU might be going up to 20% on two threads.

This should be fixed to reduce the CPU usage to an unnoticable amount. RAM usage can also be optimized, seems to be non-critical tho, because even with images the peak memory usage does not exceed a few MBs.

Rework documentation

Curretly the documentation mainly has one central example block on each page. Instead of documenting everything in one example, the documentation should provide examples for as many methods as possible.

The ideal would be to have a specialized example for every method.

Unable to get primary output

thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: Error(PrimaryScreenInfoError(147), State { next_error: None, backtrace: None })', /checkout/src/libcore/result.rs:906:4 note: Run with `RUST_BACKTRACE=1` for a backtrace.

This happens on some broken i3 machine. It fails at randr::get_output_info. Fails at getting the primary screen info with no output set. Works when output is set manually.

Add text offset

Currently the text height is always calculated automatically. This is a good idea and supporting bottom/top alignment is probably not needed.

However when setting an underline with the beckground image, it might be nice to offset the text by a bit, so it is centered when ignoring the line.

Something like this:

let text = Text::new("Hello, World").y_offset(-3)

Implement basic traits for public structs

Simple structs like MouseButton should implement every basic trait that comes with std, so people can do with them whatever they want.

These are a few of the traits that should be considered for every public type from leechbar:

  • Clone
  • Copy
  • Debug
  • Eq
  • Hash
  • Ord
  • PartialEq
  • PartialOrd

Fixed width bigger than screen width

If fixed width is bigger than screen width, it will fail. The default behavior should probably be to clamp the fixed width in between 0 and the screen width.

It might be worth exploring other Width configurations that could potentially fail.

Event-based updates

Using timers for updates works in a lot of cases, but introduces some overhead and doesn't allow to interrupt it once the timer is sleeping.

As an alternative to a timer, it should be possible to use events to signal that an update is required.

Component background image

If a component background image is bigger than the component text, it might just lead to a massive image. It should be possible to add a background image, but still have the text width as width.

Mouse Click Events

Mouse events are essential for making a bar interactive.

For this first version the bar should be able to propagate mouse click events to the component that has been interacted with.

Improve Errors

Right now errors are utterly terrible. They don't help fixing bugs in the bar and they don't help the user with what he needs to fix if it's his fault.

It would probably be a good idea to completely redesign the approach taken to handling XCB errors.

Text not rendering

With some configurations there is an issue that the text in center isn't rendering when text on the right is being rendered.

Add option to not update component

Currently whenever the timeout runs out, the component is redrawn no matter what. It should be possible for the user to return a "No Redraw" response where no matter what else is received, the component is not redrawn.
This would probably reduce resource usage dramatically in some cases.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.