Conversation
|
Do you only malloc |
|
Is this ready to pull right now? |
|
It works for me |
Yes, it's ready to pull |
Yea, based on the research I've done, the longest string that it can possibly be is "100% [Discharging]", which is 19 bytes counting the null character. I kept the size at BUF_SIZE / 2 just to be safe, but I believe that it can be reduced to 19 without any risk. |
|
Just a couple nitpicks:
|
Oh cool, I didn't know about that! I just added a commit that got rid of the extra header file, but I kept the shell script as is because I felt that it was too long for the Do you think the script should be inlined?
I also did not know about this! I added a commit getting rid of the "-1" argument.
I had a feeling I was overcomplicating this. One of the reasons for why I did all of the micro-management was because when I used I'd look to hear your thoughts on this, though. Do you think that the performance bottleneck that Regardless, I will revert the optimization commits and use the Thanks for the feedback! |
I think this makes a lot of sense. 👍 No need to inline it, seeing as how it'd be a bit much to be interested in the performance of the Makefile. You weren't necessarily over-complicating, and I figured you had good intentions, but—as you point out—
Your code certainly does the job and doesn't incur any noteworthy performance penalty (at least on my machine), so it could totally be merged as-is, but the "cleaner" approach would make it a little easier to modify in future. We might, for instance, want to use In any event, thanks for taking the initiative in seeing this added to |
Thanks for your explanation! I will definitely install
That makes a lot of sense. I'll make sure to keep that in mind in the future.
That's an interesting idea! Maybe we could have this as a config option?
Hmm, I hadn't considered that. I have some ideas on how we could potentially make that work, but they may not be optimal. I'll open up an issue for it after these changes are pulled and we can talk about it there.
Once again, thanks for the feedback! |
|
This looks to have been a very productive discussion- I'll go ahead and pull this. |
I added a "Battery" field to the output that mirrors that of neofetch. I wrote a shell script to find the directory of the computer's battery by finding the first entry in /sys/class/power_supply that starts with "bat." I looked online and saw that some people's battery directories are named "battery" and not "BAT," so this was done to make the battery functionality compatible with those systems as well. The script is invoked at compile time in the Makefile, so the user does not have to run the script themselves. The directory is echo'd into a separate config header which defines "BATTERY_DIRECTORY" as the path to the battery. This is then used in the source file.
The output differs from neofetch in that the battery field in the output is labelled "Battery" regardless of the name of the actual battery. This could easily be changed by using sed to replace "Battery" in config.h with the name of the battery.