JezerM
3 years ago
7 changed files with 131 additions and 27 deletions
@ -0,0 +1,37 @@ |
|||||||
|
class Battery { |
||||||
|
constructor() { |
||||||
|
this._battery = document.querySelector("#battery-label") |
||||||
|
this._info = {} |
||||||
|
this._init() |
||||||
|
} |
||||||
|
|
||||||
|
_updateData() { |
||||||
|
this._info = lightdm.batteryData |
||||||
|
var level = this._info.level |
||||||
|
var state = this._info.state |
||||||
|
var icon = 0 |
||||||
|
var charging = "" |
||||||
|
var blevel = Math.floor(level / 10) * 10 |
||||||
|
icon = `-${blevel}` |
||||||
|
charging = state == "Charging" ? "-charging" : "" |
||||||
|
|
||||||
|
if (blevel < 10) icon = "-outline" |
||||||
|
if (state == "Full" ) { icon = ""; charging = ""} |
||||||
|
if (level >= 0) { |
||||||
|
this._battery.style.visibility = "visible" |
||||||
|
this._battery.innerHTML = `<span class="mdi mdi-battery${charging}${icon}"></span> ${level}%` |
||||||
|
} else { |
||||||
|
this._battery.innerHTML = "" |
||||||
|
this._battery.style.visibility = "hidden" |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
_setTimer() { |
||||||
|
if (!lightdm.can_access_battery) return |
||||||
|
this._updateData() |
||||||
|
} |
||||||
|
|
||||||
|
_init() { |
||||||
|
this._setTimer() |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,28 @@ |
|||||||
|
class Brightness { |
||||||
|
constructor() { |
||||||
|
this._brightness = document.querySelector("#brightness-label") |
||||||
|
this._level = 0 |
||||||
|
this._init() |
||||||
|
} |
||||||
|
|
||||||
|
_updateData() { |
||||||
|
this._level = lightdm.brightness |
||||||
|
if (this._level >= 0) { |
||||||
|
this._brightness.style.visibility = "visible" |
||||||
|
var icon = this._level > 50 ? 7: this._level > 10 ? 6 : 5 |
||||||
|
this._brightness.innerHTML = `<span class="mdi mdi-brightness-${icon}"></span> ${this._level}%` |
||||||
|
} else { |
||||||
|
this._brightness.innerHTML = "" |
||||||
|
this._brightness.style.visibility = "hidden" |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
_setTimer() { |
||||||
|
if (!lightdm.can_access_brightness) return |
||||||
|
this._updateData() |
||||||
|
} |
||||||
|
|
||||||
|
_init() { |
||||||
|
this._setTimer() |
||||||
|
} |
||||||
|
} |
Loading…
Reference in new issue