Aylur / ags

A customizable and extensible shell
GNU General Public License v3.0
1.75k stars 94 forks source link

Add Get IPV4/6 from Network service #327

Open Lanpingner opened 4 months ago

Lanpingner commented 4 months ago

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"),

    }),
]}),
Aylur commented 4 months ago

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

Lanpingner commented 4 months ago

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

Aylur commented 4 months ago

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

Lanpingner commented 4 months ago

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

topaxi commented 3 months ago

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

Lanpingner commented 3 months ago

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