Skip to content

Conversation

Camerooooon
Copy link
Contributor

What type of PR is this? (check all applicable)

  • Refactor
  • Feature
  • Bug Fix
  • Optimization
  • Documentation Update
  • Other: Replace this with a description of the type of this PR

Description

This PR adds the %mac% option to the internal network interface modul

Related Issues & Documents

Closes #2568

Documentation (check all applicable)

  • This PR requires changes to the Wiki documentation (describe the changes) (token should be added to wiki page https://github.com/polybar/polybar/wiki/Module:-network)
  • This PR requires changes to the documentation inside the git repo (please add them to the PR).
  • Does not require documentation changes

@@ -160,6 +162,8 @@ namespace net {
continue;
}
}

m_status.mac = file_util::contents(NET_PATH + m_interface + "/address");
Copy link
Member

Choose a reason for hiding this comment

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

This does not need to be inside of the loop. Also, maybe add some error handling and set NO_MAC in case file_util::contents returns an empty string.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This does not need to be inside of the loop. Also, maybe add some error handling and set NO_MAC in case file_util::contents returns an empty string.

Ok, I made it check the mac address on initialization since it cannot change without the network interface going down which reinitializes the network. If it doesn't exist then it throws an error

@patrick96
Copy link
Member

That was fast 😃

@Camerooooon
Copy link
Contributor Author

CI should pass now, I forgot to commit .hpp file

@codecov
Copy link

codecov bot commented Jan 13, 2022

Codecov Report

Merging #2569 (e11e853) into master (f488a88) will decrease coverage by 0.00%.
The diff coverage is 0.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #2569      +/-   ##
==========================================
- Coverage   10.84%   10.83%   -0.01%     
==========================================
  Files         149      149              
  Lines       10774    10779       +5     
==========================================
  Hits         1168     1168              
- Misses       9606     9611       +5     
Flag Coverage Δ
unittests 10.83% <0.00%> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
include/adapters/net.hpp 0.00% <ø> (ø)
src/adapters/net.cpp 0.00% <0.00%> (ø)
src/modules/network.cpp 0.00% <0.00%> (ø)
src/adapters/mpd.cpp 0.00% <0.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update f488a88...e11e853. Read the comment docs.

Copy link
Member

@patrick96 patrick96 left a comment

Choose a reason for hiding this comment

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

I have also found an issue with reading the MAC address. The string returned contains a newline character which can mess up the rendering or throw a warning. You should remove any whitespace at the beginning and end of the address with string_util::trim(..., isspace)

Copy link
Member

@patrick96 patrick96 left a comment

Choose a reason for hiding this comment

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

Last round of reviews I think.

All the code seems to be working fine, changing the MAC address also works now. Just some minor changes.

Please also add an entry to the changelog in the "Added" section: https://github.com/polybar/polybar/blob/master/CONTRIBUTING.md#changelog

@Camerooooon
Copy link
Contributor Author

Alright all done. Also, Thank you very much for helping me through this @patrick96

Copy link
Member

@patrick96 patrick96 left a comment

Choose a reason for hiding this comment

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

Cool, everything looks good now 😃

Thanks a lot! 🚀

@patrick96 patrick96 added this to the 3.6.0 milestone Jan 16, 2022
@patrick96 patrick96 merged commit 195a0d9 into polybar:master Jan 16, 2022
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.

Mac Address in Network Module
2 participants