feat: add uptime on power profile (#349)
* feat: add uptime on power profile * feat: add uptime on power profile * feat: add uptime on power profile * feat: add uptime on power profile * Update modules/menus/energy/profiles/index.ts Co-authored-by: Jas Singh <jaskiratpal.singh@outlook.com> * Update modules/menus/energy/profiles/index.ts Co-authored-by: Jas Singh <jaskiratpal.singh@outlook.com> * Update modules/menus/energy/profiles/index.ts * Update modules/menus/energy/profiles/index.ts --------- Co-authored-by: Jas Singh <jaskiratpal.singh@outlook.com>
This commit is contained in:
@@ -1,12 +1,20 @@
|
|||||||
const powerProfiles = await Service.import('powerprofiles');
|
const powerProfiles = await Service.import('powerprofiles');
|
||||||
import { PowerProfile, PowerProfileObject, PowerProfiles } from 'lib/types/powerprofiles.js';
|
import { PowerProfile, PowerProfileObject, PowerProfiles } from 'lib/types/powerprofiles.js';
|
||||||
import icons from '../../../icons/index.js';
|
|
||||||
import { BoxWidget } from 'lib/types/widget.js';
|
import { BoxWidget } from 'lib/types/widget.js';
|
||||||
|
import icons from '../../../icons/index.js';
|
||||||
|
import { uptime } from 'lib/variables.js';
|
||||||
|
|
||||||
const EnergyProfiles = (): BoxWidget => {
|
const EnergyProfiles = (): BoxWidget => {
|
||||||
const isValidProfile = (profile: string): profile is PowerProfile =>
|
const isValidProfile = (profile: string): profile is PowerProfile =>
|
||||||
profile === 'power-saver' || profile === 'balanced' || profile === 'performance';
|
profile === 'power-saver' || profile === 'balanced' || profile === 'performance';
|
||||||
|
|
||||||
|
function renderUptime(curUptime: number): string {
|
||||||
|
const days = Math.floor(curUptime / (60 * 24));
|
||||||
|
const hours = Math.floor((curUptime % (60 * 24)) / 60);
|
||||||
|
const minutes = Math.floor(curUptime % 60);
|
||||||
|
return ` : ${days}d ${hours}h ${minutes}m`;
|
||||||
|
}
|
||||||
|
|
||||||
return Widget.Box({
|
return Widget.Box({
|
||||||
class_name: 'menu-section-container energy',
|
class_name: 'menu-section-container energy',
|
||||||
vertical: true,
|
vertical: true,
|
||||||
@@ -14,12 +22,19 @@ const EnergyProfiles = (): BoxWidget => {
|
|||||||
Widget.Box({
|
Widget.Box({
|
||||||
class_name: 'menu-label-container',
|
class_name: 'menu-label-container',
|
||||||
hpack: 'fill',
|
hpack: 'fill',
|
||||||
child: Widget.Label({
|
children: [
|
||||||
class_name: 'menu-label',
|
Widget.Label({
|
||||||
hexpand: true,
|
class_name: 'menu-label',
|
||||||
hpack: 'start',
|
hexpand: true,
|
||||||
label: 'Power Profile',
|
hpack: 'start',
|
||||||
}),
|
label: 'Power Profile',
|
||||||
|
}),
|
||||||
|
Widget.Label({
|
||||||
|
class_name: 'menu-label uptime',
|
||||||
|
label: uptime.bind().as(renderUptime),
|
||||||
|
tooltipText: 'Uptime',
|
||||||
|
}),
|
||||||
|
],
|
||||||
}),
|
}),
|
||||||
Widget.Box({
|
Widget.Box({
|
||||||
class_name: 'menu-items-section',
|
class_name: 'menu-items-section',
|
||||||
|
|||||||
@@ -22,6 +22,9 @@
|
|||||||
background: if($bar-menus-monochrome, $bar-menus-cards, $bar-menus-menu-battery-card-color);
|
background: if($bar-menus-monochrome, $bar-menus-cards, $bar-menus-menu-battery-card-color);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.uptime {
|
||||||
|
font-size: 0.92em;
|
||||||
|
}
|
||||||
|
|
||||||
.menu-items-section {
|
.menu-items-section {
|
||||||
background: if($bar-menus-monochrome, $bar-menus-cards, $bar-menus-menu-battery-card-color);
|
background: if($bar-menus-monochrome, $bar-menus-cards, $bar-menus-menu-battery-card-color);
|
||||||
|
|||||||
Reference in New Issue
Block a user