-
-
Notifications
You must be signed in to change notification settings - Fork 394
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
base: master
Are you sure you want to change the base?
Conversation
Hi @elkowar |
Hi @elkowar |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
2 notes:
- it is good practice to create a new branch for every pr you want to open
- 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" |
There was a problem hiding this comment.
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())), |
There was a problem hiding this comment.
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(); |
There was a problem hiding this comment.
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.
let joined = | ||
ifas.iter().filter(|ipv| ipv.1.is_ipv4() && ipv.0 != "lo").map(|ip| format!("{}", ip.1)).collect::<Vec<_>>().join(", "); | ||
joined |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
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.
docs/content/main
directory has been adjusted to reflect my changes.cargo fmt
to automatically format all code before committing