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 EWW_IPV4/6 magic variable #930

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open

Conversation

Lanpingner
Copy link

Description

This PR creates 2 magic variables that can retrieve all IPV4/6 addresses on all interfaces

Usage

To retrieve all IPV4 address
(label :text EWW_IPV4)

To retrieve all IPV6 address
(label :text EWW_IPV6)

Checklist

Please make sure you can check all the boxes that apply to this PR.

  • [✓] All widgets I've added are correctly documented.
  • [✓] I added my changes to CHANGELOG.md, if appropriate.
  • [✓] The documentation in the docs/content/main directory has been adjusted to reflect my changes.
  • [✓] I used cargo fmt to automatically format all code before committing

@Lanpingner Lanpingner closed this Oct 14, 2023
@Lanpingner Lanpingner reopened this Oct 14, 2023
@Lanpingner
Copy link
Author

Hi @elkowar
Could you please help me why does github not trigger the build.yml workflow

@Lanpingner Lanpingner closed this Oct 14, 2023
@Lanpingner Lanpingner reopened this Oct 14, 2023
@Lanpingner
Copy link
Author

Hi @elkowar
I know its a big thing to ask could you please merge the pull request as i have another pull request which close this
String Methods issue but by accident i created this pull request from the master breach which means i can't open a pull request as the new pull request will also include the changes of this.

Copy link
Contributor

@w-lfchen w-lfchen left a comment

Choose a reason for hiding this comment

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

2 notes:

  1. it is good practice to create a new branch for every pr you want to open
  2. you can cherry-pick commits.

i'm thinking about picking this idea up in a new pr, if you're okay with that.

@@ -34,6 +34,43 @@ gtk-layer-shell = { version = "0.6.1", optional = true }
gdkx11 = { version = "0.17", optional = true }
x11rb = { version = "0.11.1", features = ["randr"], optional = true }

regex = "1.9.3"
Copy link
Contributor

Choose a reason for hiding this comment

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

why are you adding all of these dependencies?
that's unnecessary

@@ -64,6 +64,12 @@ define_builtin_vars! {

// @desc EWW_TIME - the current UNIX timestamp
"EWW_TIME" [1] => || Ok(DynVal::from(get_time())) ,

// @desc EWW_IPV4 - Information about the IPv4 address on all interfaces except "lo"
"EWW_IPV4" [1] => || Ok(DynVal::from(get_ipv4())),
Copy link
Contributor

Choose a reason for hiding this comment

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

duration should be 2 seconds as with every other variable except time
i'm not sure whether running this that often is even needed

@@ -229,3 +231,17 @@ pub fn net() -> String {
pub fn get_time() -> String {
chrono::offset::Utc::now().timestamp().to_string()
}

pub fn get_ipv4() -> String {
let ifas = list_afinet_netifas().unwrap();
Copy link
Contributor

Choose a reason for hiding this comment

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

please don't crash the application.
make use of the error the function returns.

Comment on lines +237 to +239
let joined =
ifas.iter().filter(|ipv| ipv.1.is_ipv4() && ipv.0 != "lo").map(|ip| format!("{}", ip.1)).collect::<Vec<_>>().join(", ");
joined
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
let joined =
ifas.iter().filter(|ipv| ipv.1.is_ipv4() && ipv.0 != "lo").map(|ip| format!("{}", ip.1)).collect::<Vec<_>>().join(", ");
joined
ifas.iter().filter(|ipv| ipv.1.is_ipv4() && ipv.0 != "lo").map(|ip| format!("{}", ip.1)).collect::<Vec<_>>().join(", ")

jsut return this directly

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.

2 participants