Waybar icon indicating copy to clipboard operation
Waybar copied to clipboard

[Feature Request] Add customgraph module

Open otaj opened this issue 2 years ago • 12 comments

Hi, thank you for the awesome bar!

I was wondering, would it be possible to add a module creating a graph such as for example CPUGraph from QTile or Graph from eww. Ideally of course with being able to feed it custom data through continuous script similarly as custom module works.

I can now simulate it with the help of Sparks font, but it's a bit janky and it doesn't support all possible styling option.

I can help out a bit, however my C++ is very rusty so I wouldn't be the best help :)

Thank you!

otaj avatar Nov 22 '23 09:11 otaj

that would be nice

vincentaxhe avatar Oct 14 '24 11:10 vincentaxhe

Hello, I've started to experiment to add support for real graphs (for now line only), this is how the CPU usage looks like:

Image

You can check the code at https://github.com/Gazer/Waybar/tree/feat/basic-cpu-graph

Gazer avatar Sep 12 '25 22:09 Gazer

@Gazer That looks great! Would you be willing to create a PR for it?

And, more importantly, would @Alexays be interested in merging it?

imiric avatar Oct 09 '25 12:10 imiric

@imiric the idea is to end with a PR, right now I´m exploring to add a custom-graph similar to the custom module so you can use an external script to draw a graph and I want to add two more types: gauge and bars. E.g. for temperature a gauge has more sense a disk usage with bars or something like that.

Gazer avatar Oct 10 '25 23:10 Gazer

@Gazer I'm interested in your work, the new module and how to configure it.

vincentaxhe avatar Oct 11 '25 05:10 vincentaxhe

@Gazer any progress on this?

Yilmaz4 avatar Oct 24 '25 08:10 Yilmaz4

I'm doing the final testing and polish but I may be able to do a PR to get feedback next week. I've working three graph types with native or custom modules.

This config:

"custom-graph/memory": {
    "interval": 60,
    "graph_type": "gauge",
    "width": 52,
    "exec": "/home/gazer/mem.sh",
    "signal": 8,
    "return-type": "json"
  },
  "custom-graph/disk": {
    "interval": 2,
    "graph_type": "bar",
    "width": 10,
    "exec": "/home/gazer/disk.sh",
    "signal": 8,
    "return-type": "json"
  },
  cpu_graph": {
    "interval": 2,
    "graph_type": "line",
    "y_offset": 4,
    "width": 50,
    "on-click": "$TERMINAL -e btop"
  },

creates

Image

Missing things:

  • man pages
  • gauge and bar customization (right now the colors are hard-coded)

Gazer avatar Oct 24 '25 09:10 Gazer

PR created, I've drop the idea of the rainbown colors since do not match the style. Instead played with the alpha to create a shades of the main color

Image Image Image

Gazer avatar Oct 24 '25 22:10 Gazer

@Gazer did the graph scale automatically,for example custom a network traffic line graph, when traffic change from 10k - 1M to 1M - 10M?

vincentaxhe avatar Oct 28 '25 13:10 vincentaxhe

Hi , no, this initial version just allow you to render values from 0 to 100, so the scale change is not implemented. It should work mostly for any value that can be mapped to a percentage for now since that's what was available in the custom json format.

A native network module may do some work to support re-scaling by recalculating all the values in the vector but I did not take the time to try it since I focused on the disk, memory and cpu.

Gazer avatar Oct 28 '25 15:10 Gazer

@Gazer graph should implement something to indicate different scale, line color changed or vertical marks or fill density, so script can pass more data to scale.

vincentaxhe avatar Oct 30 '25 10:10 vincentaxhe

@vincentaxhe I agree, but since this is an initial implementation I rather prefer to keep it simple for now. I use this gist to monitor network with autocale and work decently:

Image
  "custom-graph/net-up": {
    "exec": "$HOME/netp.sh up",
    "width": 5,
    "graph_type": "bar",
    "return-type": "json"
  },
  "custom-graph/net-down": {
    "exec": "$HOME/netp.sh down",
    "width": 5,
    "graph_type": "bar",
    "return-type": "json"
  }

and the style:

#custom-graph-net-up {
    color: #fa7070;
}

#custom-graph-net-down {
    color: #0080c0;
}

Gazer avatar Nov 17 '25 07:11 Gazer