aboutsummaryrefslogtreecommitdiff
path: root/src/utils
diff options
context:
space:
mode:
Diffstat (limited to 'src/utils')
-rw-r--r--src/utils/mod.rs1
-rw-r--r--src/utils/pub_ip.rs15
2 files changed, 16 insertions, 0 deletions
diff --git a/src/utils/mod.rs b/src/utils/mod.rs
index 3b4eb7b..e70cf88 100644
--- a/src/utils/mod.rs
+++ b/src/utils/mod.rs
@@ -5,6 +5,7 @@ pub mod load_average;
pub mod memory;
pub mod mpd;
pub mod netspeed;
+pub mod pub_ip;
pub mod spotify;
pub mod time;
pub mod uptime;
diff --git a/src/utils/pub_ip.rs b/src/utils/pub_ip.rs
new file mode 100644
index 0000000..ce2da92
--- /dev/null
+++ b/src/utils/pub_ip.rs
@@ -0,0 +1,15 @@
+use crate::config::CONFIG;
+
+pub fn get_pub_ip() -> String {
+ let url = format!("http://api.ipify.org");
+ let err_string = String::from("Error");
+ let res = match minreq::get(url).send() {
+ Ok(resp) => match resp.as_str() {
+ Ok(res_str) => res_str.trim().to_string(),
+ Err(_) => err_string,
+ },
+ Err(_) => err_string,
+ };
+
+ format!(" {} {} {}", CONFIG.pub_ip.icon, res, CONFIG.seperator)
+}