xaizek / d2if (License: GPLv2+) (since 2018-12-07)
Simple dzen2 input formatter, which is supposed to not waste CPU time for nothing and provides a number of builtin "widgets" for displaying system information.
Commit 032ba36f519699964568bc92be0d11652866706c

Parse battery info from /sys/class/power_supply
Using /proc/acpi/battery is probably an outdated method, but keep it
anyway.
Author: xaizek
Author date (UTC): 2024-04-09 14:46
Committer name: xaizek
Committer date (UTC): 2024-04-09 14:46
Parent(s): c93bc86b5fba7a16ef66a5dad862ef02e97e04c6
Signing key: 99DC5E4DB05F6BE2
Tree: 96f63cb19225e26f2f63b52eee18c20ef5856aa5
File Lines added Lines deleted
src/Battery.cpp 16 2
File src/Battery.cpp changed (mode: 100644) (index c631cdf..943b32b)
... ... std::pair<bool, int> Battery::getBatteryState() const
86 86 return { return {
87 87 charged == "charged" || charged == "charging", (remaining*100)/full charged == "charged" || charged == "charging", (remaining*100)/full
88 88 }; };
89 } else {
90 return { false, -1 };
91 89 } }
90
91 std::ifstream capacity { "/sys/class/power_supply/BAT0/capacity" };
92 std::ifstream status { "/sys/class/power_supply/BAT0/status" };
93 if (capacity.is_open() && status.is_open()) {
94 int level;
95 std::string state;
96
97 capacity >> level;
98 status >> state;
99
100 return {
101 state != "Discharging", level
102 };
103 }
104
105 return { false, -1 };
92 106 } }
Hints

Before first commit, do not forget to setup your git environment:
git config --global user.name "your_name_here"
git config --global user.email "your@email_here"

Clone this repository using HTTP(S):
git clone https://code.reversed.top/user/xaizek/d2if

Clone this repository using ssh (do not forget to upload a key first):
git clone ssh://rocketgit@code.reversed.top/user/xaizek/d2if

You are allowed to anonymously push to this repository.
This means that your pushed commits will automatically be transformed into a pull request:
... clone the repository ...
... make some changes and some commits ...
git push origin master