Skip to content

networking: add traffic statistics to NetworkDevice - #958

Draft
cpwrs wants to merge 3 commits into
quickshell-mirror:masterfrom
cpwrs:network-device-speed
Draft

networking: add traffic statistics to NetworkDevice#958
cpwrs wants to merge 3 commits into
quickshell-mirror:masterfrom
cpwrs:network-device-speed

Conversation

@cpwrs

@cpwrs cpwrs commented Aug 16, 2026

Copy link
Copy Markdown
Contributor

Adds these properties to NetworkDevice:

  • rxBytes: Number of received bytes
  • txBytes: Number of transmitted bytes
  • refreshRate: How often to refresh rxBytes and txBytes in milliseconds

Useful for upload/download speed

@outfoxxed

outfoxxed commented Aug 26, 2026

Copy link
Copy Markdown
Member

What do the traffic statistics actually mean in absence of a refresh period? Seems like deriving any useful metric about speed would be hard unless theres an expected way to do that. When we do have a time frame, do you think normalizing it to bytes/sec seems like a good idea?

@cpwrs

cpwrs commented Aug 26, 2026

Copy link
Copy Markdown
Contributor Author

Seems like deriving any useful metric about speed would be hard unless theres an expected way to do that.

Yeah.. this is a bad API from NM. I didn't consider that you can't count the # of refreshes and calculate speed from that. There's no update signal to count if no bytes are rx/txed.

When we do have a time frame, do you think normalizing it to bytes/sec seems like a good idea?

Yes that'd be better. I could add an internal timer however you can't easily ensure it's synced with NMs. Polling /sys is easy, more accurate, and needed for other backends to support speed anyway.

@cpwrs
cpwrs marked this pull request as draft August 26, 2026 16:56
@outfoxxed

outfoxxed commented Aug 27, 2026

Copy link
Copy Markdown
Member

Rather than keeping a separate timer you could just use rate to multiply bytes if nonzero, and probably just 0 out tx/rx if rate is 0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants