-
-
Notifications
You must be signed in to change notification settings - Fork 717
Add mac address option #2569
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 mac address option #2569
Conversation
src/adapters/net.cpp
Outdated
@@ -160,6 +162,8 @@ namespace net { | |||
continue; | |||
} | |||
} | |||
|
|||
m_status.mac = file_util::contents(NET_PATH + m_interface + "/address"); |
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.
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.
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.
This does not need to be inside of the loop. Also, maybe add some error handling and set
NO_MAC
in casefile_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
That was fast 😃 |
CI should pass now, I forgot to commit .hpp file |
Codecov Report
@@ 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
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report at Codecov.
|
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.
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)
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.
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
Alright all done. Also, Thank you very much for helping me through this @patrick96 |
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.
Cool, everything looks good now 😃
Thanks a lot! 🚀
What type of PR is this? (check all applicable)
Description
This PR adds the %mac% option to the internal network interface modul
Related Issues & Documents
Closes #2568
Documentation (check all applicable)