Xfce Forum

Sub domains
 

You are not logged in.

#1 2019-05-28 11:13:43

zorrohere
Member
Registered: 2019-05-28
Posts: 2

[Solved]Display active network in Network Monitor

I am recently installed Manjaro 18.2 with XFCE. I have low internet speed and like to monitor my internet. I liked the fact that Panel comes with Network Monitor plugin but I have to manually add which network to display.

Problem is, I often plug my phone for USB Tethering and I have to switch network being displayed. Is there any solution to display currently active network in Network Monitor? Can I write a script to switch it automatically?

Last edited by zorrohere (2019-05-29 18:47:10)

Offline

#2 2019-05-28 16:08:19

CwF
Member
Registered: 2018-01-28
Posts: 290

Re: [Solved]Display active network in Network Monitor

Instead of editing the monitor, set it to a name, like "internet". Using network, systemd, or udev rules, then rename the interface itself to 'internet' or whatever.

Yes, no specifics! Just advice to flip perspective. I use interface naming to allow a single image and desktop configuration to operate the same on physically different computers, so all my tweaks are not dynamic like your use case. Some sort of hotplug udev rule should be able to rename interfaces dynamically and allow the desktop configuration to stay static.

So, when you plug in the phone, its rule should first down the existing interface, then rename it, then bring up the usb link interface, and name it. Unplugging is the reverse....sounds possible.

Offline

#3 2019-05-29 18:10:00

zorrohere
Member
Registered: 2019-05-28
Posts: 2

Re: [Solved]Display active network in Network Monitor

Hi,

Thanks for the idea, I managed to do it.

First I wrote udev rule to permanently rename my motherboard network interface. And then I added two more rules on add, remove actions of usb tethering device that will trigger scripts.

SUBSYSTEM=="net", ACTION=="add", ATTR{address}=="40:8d:5c:67:66:30", NAME="displaynet"

SUBSYSTEM=="net", ENV{ID_BUS}=="usb", ENV{ID_USB_DRIVER}=="rndis_host", ACTION=="add", NAME="usbnet", RUN{program}+="/usr/local/bin/usb-add.sh"                 

SUBSYSTEM=="net", ENV{ID_BUS}=="usb", ENV{ID_USB_DRIVER}=="rndis_host", ACTION=="remove", RUN{program}+="/usr/local/bin/usb-remove.sh"

Inside those scripts I have written commands that will live rename interfaces.

Script in usb-add.sh

#!/bin/bash

ip link set displaynet down
ip link set displaynet name mobodown

ip link set $INTERFACE down
ip link set $INTERFACE name displaynet
ip link set displaynet up

Script in usb-remove.sh

#!/bin/bash

ip link set displaynet down
ip link set displaynet name usbdown

ip link set mobodown down
ip link set mobodown name displaynet
ip link set displaynet up

It also resolves my issue when sometimes even though I turn on tethering, ethernet stays connected. Now I don't have to manually disconnect anymore. Thanks.

Last edited by zorrohere (2019-05-29 18:16:18)

Offline

#4 2019-05-29 20:34:13

CwF
Member
Registered: 2018-01-28
Posts: 290

Re: [Solved]Display active network in Network Monitor

Very good!

Offline

Board footer

Powered by FluxBB