chocobar-x11/ui/battery-widget.slint
Candifloss b0eaa42063 Add BatteryWidget
- Working battery icon
- Read from `sys` files
- Calculate values in Rust and pass it to Slint
2025-11-20 22:44:56 +05:30

36 lines
1017 B
Plaintext

export component BatteryWidget {
in property <int> bar_height;
in property <string> battery_status; // charging / discharging / notcharging / unknown
in property <int> battery_capacity; // numeric percentage
in property <string> battery_capacity_level; // critical / low / normal / high / full
in property <string> battery_icon;
callback show_battery();
height: bar_height * 1px;
width: bar_height * 1px;
Rectangle {
background: touch_area.pressed ? #4a5f70
: touch_area.has-hover ? #6d8a4d
: #8e9162;
border-radius: 3px;
HorizontalLayout {
padding-left: 3px;
padding-right: 3px;
Text {
text: battery_icon;
color: white;
vertical-alignment: center;
horizontal-alignment: center;
}
}
touch_area := TouchArea {
clicked => { show_battery(); }
}
}
}