ags icon indicating copy to clipboard operation
ags copied to clipboard

Add Get IPV4/6 from Network service

Open Lanpingner opened this issue 1 year ago • 6 comments

This PR simply add IP info that can be collected from the Network service both from WiFi or Wired

How to Implement to your code

const { wifi } = await Service.import("network")
Widget.Box({
class_name: "ipcontainer",
expand: true,
children: [
    Widget.Label({
        class_name: "iplabel",
        label: network.wifi.nmDevice.bind("ipv4_address").as(ipv4_address => ipv4_address || "No wifi IP")
    }),
    Widget.Label({ label: " " }),
    Widget.Label({
        class_name: "iplabel",
        label: network.wired.nmDevice.bind("ipv4_address").as(ipv4_address => ipv4_address || "No wired IP"),

    }),
]}),

Lanpingner avatar Feb 28 '24 22:02 Lanpingner

they should be defined as gobject properties and they should connect to the ip config object to listen for changes

Aylur avatar Feb 29 '24 16:02 Aylur

I am not sure if this is what you meant, sorry very new to Typescript, i am open for suggestions. If this is not what you meant, could you please provide me with an example or a docs

Lanpingner avatar Feb 29 '24 21:02 Lanpingner

is it possible for the ip4 and ip6 config objects to change on the device? should be handled if they can the network service really needs some work, maybe we should make a base class for Wired and Wifi, but thats for another PR

Aylur avatar Mar 07 '24 00:03 Aylur

Yes the ips can change on a device, i know its quite rare. For me its a huge help Example, i am software developer and a network engineer daily i am going to different places which each has a different networks and also when i am connecting my laptop to a router, switch or ap i can get different ips. Thats the reasons i created this PR maybe someone else also need this and using ags for daily

Lanpingner avatar Mar 07 '24 07:03 Lanpingner

Came here to request this feature or potentially contribute, glad to see this already being pursued :+1:

topaxi avatar Mar 16 '24 16:03 topaxi

We should have a Device subclass, to avoid code repetition

Device extends Service
Wifi extends Device
Wired extends Device

I will see what i can come up with

Lanpingner avatar Mar 27 '24 20:03 Lanpingner