Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Get IPV4/6 from Network service #327

Open
wants to merge 17 commits into
base: main
Choose a base branch
from
Open

Conversation

Lanpingner
Copy link

@Lanpingner Lanpingner commented Feb 28, 2024

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
Copy link
Owner

Aylur commented Feb 29, 2024

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

@Lanpingner
Copy link
Author

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
Copy link
Owner

Aylur commented Mar 7, 2024

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
Copy link
Author

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
Copy link
Contributor

topaxi commented Mar 16, 2024

Came here to request this feature or potentially contribute, glad to see this already being pursued 👍

src/service/network.ts Outdated Show resolved Hide resolved
src/service/network.ts Outdated Show resolved Hide resolved
src/service/network.ts Outdated Show resolved Hide resolved
Copy link
Owner

@Aylur Aylur left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should have a Device subclass, to avoid code repetition

Device extends Service
Wifi extends Device
Wired extends Device

@Lanpingner
Copy link
Author

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

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.

None yet

3 participants