forked from external/yambar
module/backlight: don't divide by zero
This commit is contained in:
parent
bc62843c91
commit
f952347c84
1 changed files with 7 additions and 3 deletions
|
@ -41,11 +41,15 @@ content(struct module *mod)
|
||||||
const struct private *m = mod->private;
|
const struct private *m = mod->private;
|
||||||
|
|
||||||
mtx_lock(&mod->lock);
|
mtx_lock(&mod->lock);
|
||||||
|
|
||||||
|
const long current = m->current_brightness;
|
||||||
|
const long max = m->max_brightness;
|
||||||
|
const long percent = max > 0 ? 100 * current / max : 0;
|
||||||
|
|
||||||
struct tag_set tags = {
|
struct tag_set tags = {
|
||||||
.tags = (struct tag *[]){
|
.tags = (struct tag *[]){
|
||||||
tag_new_int_range(
|
tag_new_int_range(mod, "brightness", current, 0, max),
|
||||||
mod, "brightness", m->current_brightness, 0, m->max_brightness),
|
tag_new_int_range(mod, "percent", percent, 0, 100),
|
||||||
tag_new_int_range(mod, "percent", 100 * m->current_brightness / m->max_brightness, 0, 100),
|
|
||||||
},
|
},
|
||||||
.count = 2,
|
.count = 2,
|
||||||
};
|
};
|
||||||
|
|
Loading…
Add table
Reference in a new issue