diff --git a/modules/menus/energy/profiles/index.ts b/modules/menus/energy/profiles/index.ts index f06dd73..72b2824 100644 --- a/modules/menus/energy/profiles/index.ts +++ b/modules/menus/energy/profiles/index.ts @@ -1,12 +1,20 @@ const powerProfiles = await Service.import('powerprofiles'); import { PowerProfile, PowerProfileObject, PowerProfiles } from 'lib/types/powerprofiles.js'; -import icons from '../../../icons/index.js'; import { BoxWidget } from 'lib/types/widget.js'; +import icons from '../../../icons/index.js'; +import { uptime } from 'lib/variables.js'; const EnergyProfiles = (): BoxWidget => { const isValidProfile = (profile: string): profile is PowerProfile => 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({ class_name: 'menu-section-container energy', vertical: true, @@ -14,12 +22,19 @@ const EnergyProfiles = (): BoxWidget => { Widget.Box({ class_name: 'menu-label-container', hpack: 'fill', - child: Widget.Label({ - class_name: 'menu-label', - hexpand: true, - hpack: 'start', - label: 'Power Profile', - }), + children: [ + Widget.Label({ + class_name: 'menu-label', + hexpand: true, + hpack: 'start', + label: 'Power Profile', + }), + Widget.Label({ + class_name: 'menu-label uptime', + label: uptime.bind().as(renderUptime), + tooltipText: 'Uptime', + }), + ], }), Widget.Box({ class_name: 'menu-items-section', diff --git a/scss/style/menus/energy.scss b/scss/style/menus/energy.scss index a798b2a..45648f3 100644 --- a/scss/style/menus/energy.scss +++ b/scss/style/menus/energy.scss @@ -22,6 +22,9 @@ background: if($bar-menus-monochrome, $bar-menus-cards, $bar-menus-menu-battery-card-color); } + .uptime { + font-size: 0.92em; + } .menu-items-section { background: if($bar-menus-monochrome, $bar-menus-cards, $bar-menus-menu-battery-card-color);