Browse Source

Fixed battery icon and other things

sisyphus
JezerM 3 years ago
parent
commit
9bdc01483f
No known key found for this signature in database
GPG Key ID: 66BBC5D01388C6B5
  1. 3
      themes/dracula/css/style.css
  2. 6
      themes/dracula/index.html
  3. 5
      themes/dracula/js/battery.js
  4. 77
      themes/dracula/js/layouts.js
  5. 6
      themes/dracula/js/power.js
  6. 5
      themes/gruvbox/js/battery.js
  7. 3
      themes/gruvbox/js/power.js

3
themes/dracula/css/style.css vendored

@ -130,6 +130,9 @@ body {
font-weight: bold; font-weight: bold;
cursor: default; cursor: default;
} }
#cover:focus {
outline: 0 !important;
}
/* Login form */ /* Login form */

6
themes/dracula/index.html vendored

@ -8,7 +8,7 @@
<link rel="stylesheet" href="css/style.css" class="style"> <link rel="stylesheet" href="css/style.css" class="style">
<link rel="stylesheet" href="../../_vendor/material-icons/css/materialdesignicons.min.css" onerror="this.href='../_vendor/material-icons/css/materialdesignicons.min.css'" class="style"> <link rel="stylesheet" href="../../_vendor/material-icons/css/materialdesignicons.min.css" onerror="this.href='../_vendor/material-icons/css/materialdesignicons.min.css'" class="style">
<script src="../_vendor/js/mock.js"></script> <!--<script src="..//js/mock.js"></script>-->
</head> </head>
<body> <body>
@ -18,9 +18,9 @@
<img src="./assets/dracula.png" alt=""> <img src="./assets/dracula.png" alt="">
</div> </div>
<div id="cover" class="hide"> <button id="cover" class="hide">
<div id="message"></div> <div id="message"></div>
</div> </button>
<div id="screen"> <div id="screen">

5
themes/dracula/js/battery.js vendored

@ -9,14 +9,15 @@ class Battery {
this._info = lightdm.batteryData this._info = lightdm.batteryData
var level = this._info.level var level = this._info.level
var state = this._info.state var state = this._info.state
var ac = this._info.ac_status
var icon = 0 var icon = 0
var charging = "" var charging = ""
var blevel = Math.floor(level / 10) * 10 var blevel = Math.floor(level / 10) * 10
icon = `-${blevel}` icon = `-${blevel}`
charging = state == "Charging" ? "-charging" : "" charging = ac == 1 ? "-charging" : ""
if (blevel < 10) icon = "-outline" if (blevel < 10) icon = "-outline"
if (state == "Full" ) { icon = ""; charging = ""} if (level == 100 && ac == 0) {icon = ""}
if (level >= 0) { if (level >= 0) {
this._battery.style.visibility = "visible" this._battery.style.visibility = "visible"
this._battery.innerHTML = `<span class="mdi mdi-battery${charging}${icon}"></span> ${level}%` this._battery.innerHTML = `<span class="mdi mdi-battery${charging}${icon}"></span> ${level}%`

77
themes/dracula/js/layouts.js vendored

@ -0,0 +1,77 @@
class Layouts {
constructor() {
this._layoutList = document.querySelector("#layouts-list")
this._dropdown = document.querySelector("#layouts-dropdown")
this._button = document.querySelector("#layouts-button")
this._layouts = []
this.layout = {}
this._init()
}
_setDefault() {
let name = this.layout.name
let description = this.layout.description
let short = this.layout.short_description
this._button.innerHTML = name.toUpperCase() + (short ? ` (${short})` : "")
//this._button.name = description
}
_setLayoutList() {
let dropdown = this._dropdown
dropdown.innerHTML = ""
for (let i = 0; i < this._layouts.length; i++) {
let name = this._layouts[i].name
let description = this._layouts[i].description
let short = this._layouts[i].short_description
let li = document.createElement("li")
let button = document.createElement("button")
button.innerHTML = name + (short ? ` (${short})` : "")
button.name = description
button.addEventListener("click", () => {
this.layout = this._layouts[i]
this._setDefault()
lightdm.layout = this.layout
})
li.appendChild(button)
dropdown.appendChild(li)
}
}
_setKeydown() {
let dropdown = this._dropdown
dropdown.addEventListener("keydown", (ev) => {
if (ev.keyCode == 27) {
dropdown.classList.add("hide")
this._button.focus()
}
})
}
_setButton() {
let dropdown = this._dropdown
document.querySelector("#screen").addEventListener("click", (ev) => {
if (ev.target == this._button || ev.target.parentElement == this._button) {
dropdown.classList.toggle("hide")
} else
if (ev.target != dropdown && ev.target.closest(".dropdown") == null) {
dropdown.classList.add("hide")
}
})
document.querySelector("#screen").addEventListener("focusin", (ev) => {
if (!dropdown.contains(document.activeElement) && document.activeElement != this._button) {
dropdown.classList.add("hide")
}
})
}
_init() {
this.layout = lightdm.layout
this._layouts = greeter_config.layouts
this._setDefault()
this._setLayoutList()
this._setButton()
this._setKeydown()
}
}

6
themes/dracula/js/power.js vendored

@ -12,6 +12,9 @@ class Power {
_show_message(text) { _show_message(text) {
this._covermsg.innerHTML = text this._covermsg.innerHTML = text
this._cover.classList.remove("hide") this._cover.classList.remove("hide")
wait(500).then(() => {
this._cover.focus()
})
} }
async _do_shutdown() { async _do_shutdown() {
@ -67,6 +70,9 @@ class Power {
this._cover.addEventListener("click", () => { this._cover.addEventListener("click", () => {
this._cover.classList.add("hide") this._cover.classList.add("hide")
}) })
this._cover.addEventListener("keydown", () => {
this._cover.classList.add("hide")
})
} }
_setButtons() { _setButtons() {

5
themes/gruvbox/js/battery.js vendored

@ -9,14 +9,15 @@ class Battery {
this._info = lightdm.batteryData this._info = lightdm.batteryData
var level = this._info.level var level = this._info.level
var state = this._info.state var state = this._info.state
var ac = this._info.ac_status
var icon = 0 var icon = 0
var charging = "" var charging = ""
var blevel = Math.floor(level / 10) * 10 var blevel = Math.floor(level / 10) * 10
icon = `-${blevel}` icon = `-${blevel}`
charging = state == "Charging" ? "-charging" : "" charging = ac == 1 ? "-charging" : ""
if (blevel < 10) icon = "-outline" if (blevel < 10) icon = "-outline"
if (state == "Full" ) { icon = ""; charging = ""} if (level == 100 && ac == 0) {icon = ""}
if (level >= 0) { if (level >= 0) {
this._battery.style.visibility = "visible" this._battery.style.visibility = "visible"
this._battery.innerHTML = `<span class="mdi mdi-battery${charging}${icon}"></span> ${level}%` this._battery.innerHTML = `<span class="mdi mdi-battery${charging}${icon}"></span> ${level}%`

3
themes/gruvbox/js/power.js vendored

@ -70,6 +70,9 @@ class Power {
this._cover.addEventListener("click", () => { this._cover.addEventListener("click", () => {
this._cover.classList.add("hide") this._cover.classList.add("hide")
}) })
this._cover.addEventListener("keydown", () => {
this._cover.classList.add("hide")
})
} }
_setButtons() { _setButtons() {

Loading…
Cancel
Save