Xfce Forum

Sub domains
 

You are not logged in.

#1 2020-10-11 12:37:20

xfce456
Member
Registered: 2020-10-11
Posts: 6

Please test my network monitor code.

I just created network monitor shell script for generic monitor, please I need someone to test it. It automatically assign an interface, and also nothing else.
Current issue:
- Can't add a tooltip somehow (I badly wanna add vnstat to tooltip, lol).
- Possible inaccuracy.
ss
Link

Offline

#2 2020-10-11 14:23:58

ToZ
Administrator
From: Canada
Registered: 2011-06-02
Posts: 11,485

Re: Please test my network monitor code.

Your code works for me.

To get tooltips to work, you need to echo <tool>tooltip text</tool>. The genmon documentation is located here.


Please remember to mark your thread [SOLVED] to make it easier for others to find
--- How To Ask For Help | FAQ | Developer Wiki  |  Community | Contribute ---

Offline

#3 2020-10-11 18:58:32

xfce456
Member
Registered: 2020-10-11
Posts: 6

Re: Please test my network monitor code.

ToZ wrote:

Your code works for me.

To get tooltips to work, you need to echo <tool>tooltip text</tool>. The genmon documentation is located here.

I see, but it sometime shows me 1 MiB/s when I only have 5Mbps wifi. The tooltip is working now, I changes the period to 0.5. I just found that 0.25 prevent tooltip from showing?

Offline

#4 2020-10-11 19:23:52

xfce456
Member
Registered: 2020-10-11
Posts: 6

Re: Please test my network monitor code.

Also, why can't I have something like this:

#!/bin/bash
e=0
while (true);do
	e=$(($e+1))
	printf "\033c$e"
	sleep 0.1
done

Last edited by xfce456 (2020-10-11 19:30:04)

Offline

#5 2020-10-11 20:37:32

ToZ
Administrator
From: Canada
Registered: 2011-06-02
Posts: 11,485

Re: Please test my network monitor code.

xfce456 wrote:

Also, why can't I have something like this:

#!/bin/bash
e=0
while (true);do
	e=$(($e+1))
	printf "\033c$e"
	sleep 0.1
done

A couple of reasons:

  1. genmon has a built-in timer that acts like a "while(true); do sleep x" loop, where the x is the period. You only need to echo/print the output - don't include a forever loop in the code.

  2. It's not a bash shell so it doesn't process escape codes.

xfce456 wrote:

I just found that 0.25 prevent tooltip from showing?

Perhaps its a GTK3 thing where if the tooltip takes longer than the refresh cycle it doesn't display (perpetual state of updating).


Please remember to mark your thread [SOLVED] to make it easier for others to find
--- How To Ask For Help | FAQ | Developer Wiki  |  Community | Contribute ---

Offline

#6 2020-10-12 02:23:19

xfce456
Member
Registered: 2020-10-11
Posts: 6

Re: Please test my network monitor code.

ToZ wrote:

genmon has a built-in timer that acts like a "while(true); do sleep x" loop, where the x is the period. You only need to echo/print the output - don't include a forever loop in the code.

I guess, this is a ok.

ToZ wrote:

It's not a bash shell so it doesn't process escape codes.

How about clearing the output? Is there a way to do that?

ToZ wrote:

Perhaps its a GTK3 thing where if the tooltip takes longer than the refresh cycle it doesn't display (perpetual state of updating).

I don't really understand about this one big_smile. I'll just stick with 0.5 period.

Offline

#7 2020-10-12 12:09:56

ToZ
Administrator
From: Canada
Registered: 2011-06-02
Posts: 11,485

Re: Please test my network monitor code.

xfce456 wrote:
ToZ wrote:

It's not a bash shell so it doesn't process escape codes.

How about clearing the output? Is there a way to do that?

echo ""

Please remember to mark your thread [SOLVED] to make it easier for others to find
--- How To Ask For Help | FAQ | Developer Wiki  |  Community | Contribute ---

Offline

#8 2020-10-12 13:39:54

xfce456
Member
Registered: 2020-10-11
Posts: 6

Re: Please test my network monitor code.

ToZ wrote:
echo ""

Not working sad. I wan't to clear all of the previous output.
ssdsa.png

Offline

#9 2020-10-12 16:23:30

ToZ
Administrator
From: Canada
Registered: 2011-06-02
Posts: 11,485

Re: Please test my network monitor code.

I think you are mis-understanding the purpose of the genmon plugin. It simply outputs the result of a command. To clear a previous result, it is simply overwritten by the next period execute of the command.

Your first network script does this properly. It outputs the results of your commands. On every iteration of the script (based on the period setting in genmon), it overwrites the previous result with the new result.

With your last script, you are in fact displaying 3 outputs "1", "", and "2" - as is intended by the script and as processed by genmon. From your previous comments I gather you are trying to erase a genmon displayed value and again, genmon doesn't work like that. The previous value will be overwritten (erased) on the next iteration of the script.


Please remember to mark your thread [SOLVED] to make it easier for others to find
--- How To Ask For Help | FAQ | Developer Wiki  |  Community | Contribute ---

Offline

Registered users online in this topic: 0, guests: 1
[Bot] ClaudeBot

Board footer

Powered by FluxBB
Modified by Visman

[ Generated in 0.010 seconds, 7 queries executed - Memory usage: 556.77 KiB (Peak: 573.61 KiB) ]