added Batterymenu and refactor
This commit is contained in:
1 parent
0bcecde4c7
commit
a7824e0128
14 files changed
+230
-36
No files matched your search
+2
-1
@@ -1,4 +1,5 @@
|
|||||||
@use "./widget/modules/modules.scss";
|
@use "./modules/modules.scss";
|
||||||
|
@use "./menus/menus.scss";
|
||||||
|
|
||||||
window.Bar {
|
window.Bar {
|
||||||
background: transparent;
|
background: transparent;
|
||||||
|
|||||||
+3
-6
@@ -1,6 +1,5 @@
|
|||||||
import { App, Astal, Gtk, Gdk } from "astal/gtk3";
|
import { App, Astal, Gtk, Gdk } from "astal/gtk3";
|
||||||
import {
|
import {
|
||||||
PowerMenu,
|
|
||||||
Cpu,
|
Cpu,
|
||||||
BatteryLevel,
|
BatteryLevel,
|
||||||
Ram,
|
Ram,
|
||||||
@@ -9,18 +8,15 @@ import {
|
|||||||
// FocusedClient,
|
// FocusedClient,
|
||||||
Time,
|
Time,
|
||||||
SysTray,
|
SysTray,
|
||||||
Media,
|
|
||||||
LauncherButton,
|
LauncherButton,
|
||||||
PowerMenuButton,
|
PowerMenuButton,
|
||||||
MediaPlayerButton,
|
MediaPlayerButton,
|
||||||
Volume,
|
Volume,
|
||||||
} from "./modules/export";
|
} from "./modules/export";
|
||||||
// import Wp from "gi://AstalWp";
|
import { BatteryMenu, MediaMenu, PowerMenu } from "./menus/menus";
|
||||||
// import { bind } from "astal";
|
|
||||||
|
|
||||||
export default function Bar(gdkmonitor: Gdk.Monitor) {
|
export default function Bar(gdkmonitor: Gdk.Monitor) {
|
||||||
const { TOP, LEFT, RIGHT } = Astal.WindowAnchor;
|
const { TOP, LEFT, RIGHT } = Astal.WindowAnchor;
|
||||||
// const speaker = Wp.get_default()?.audio.defaultSpeaker!;
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<window
|
<window
|
||||||
@@ -53,7 +49,8 @@ export default function Bar(gdkmonitor: Gdk.Monitor) {
|
|||||||
</centerbox>
|
</centerbox>
|
||||||
</window>
|
</window>
|
||||||
<PowerMenu />
|
<PowerMenu />
|
||||||
<Media />
|
<MediaMenu />
|
||||||
|
<BatteryMenu />
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,38 @@
|
|||||||
|
.Batterymenu {
|
||||||
|
background-color: transparent;
|
||||||
|
padding: 10px;
|
||||||
|
box {
|
||||||
|
margin: 5px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.BatteryMainBox {
|
||||||
|
background-color: black;
|
||||||
|
border-radius: 25px;
|
||||||
|
padding: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
icon {
|
||||||
|
font-size: 25px;
|
||||||
|
padding: 0 2px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.BatteryTopTitle {
|
||||||
|
font-weight: bold;
|
||||||
|
font-size: 15px;
|
||||||
|
padding: 0 2px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.BatteryInfoTable {
|
||||||
|
padding: 10px;
|
||||||
|
background-color: rgb(55, 55, 55);
|
||||||
|
border-radius: 25px;
|
||||||
|
min-width: 300px;
|
||||||
|
label {
|
||||||
|
font-size: 15px;
|
||||||
|
}
|
||||||
|
|
||||||
|
label.BatteryInfoTableRowTitle {
|
||||||
|
color: rgb(170, 170, 170);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,93 @@
|
|||||||
|
import { Astal, App, Gtk } from "astal/gtk3";
|
||||||
|
import Battery from "gi://AstalBattery";
|
||||||
|
import { bind } from "astal";
|
||||||
|
|
||||||
|
const BatteryMenu = () => {
|
||||||
|
const { TOP, RIGHT } = Astal.WindowAnchor;
|
||||||
|
const { START, END } = Gtk.Align;
|
||||||
|
const bat = Battery.get_default();
|
||||||
|
console.log(
|
||||||
|
bat.charging,
|
||||||
|
bat.capacity,
|
||||||
|
bat.energyFull,
|
||||||
|
bat.energy_full_design,
|
||||||
|
);
|
||||||
|
return (
|
||||||
|
<window
|
||||||
|
anchor={TOP | RIGHT}
|
||||||
|
name="batterymenu"
|
||||||
|
className="Batterymenu"
|
||||||
|
application={App}
|
||||||
|
visible={false}
|
||||||
|
>
|
||||||
|
<box vertical className="BatteryMainBox">
|
||||||
|
<box className="Top">
|
||||||
|
<icon icon={bind(bat, "batteryIconName")} />
|
||||||
|
<box vertical>
|
||||||
|
<label
|
||||||
|
className="BatteryTopTitle"
|
||||||
|
label={bind(bat, "percentage").as(
|
||||||
|
(p) => `Battery ${Math.floor(p * 100)} %`,
|
||||||
|
)}
|
||||||
|
/>
|
||||||
|
</box>
|
||||||
|
</box>
|
||||||
|
<box vertical className="BatteryInfoTable">
|
||||||
|
<box>
|
||||||
|
<label
|
||||||
|
className="BatteryInfoTableRowTitle"
|
||||||
|
hexpand
|
||||||
|
halign={START}
|
||||||
|
label="Status:"
|
||||||
|
/>
|
||||||
|
<label
|
||||||
|
hexpand
|
||||||
|
halign={END}
|
||||||
|
label={bind(bat, "charging").as((p) =>
|
||||||
|
p ? "CHARGING" : "PENDING_CHARGE",
|
||||||
|
)}
|
||||||
|
/>
|
||||||
|
</box>
|
||||||
|
<box>
|
||||||
|
<label
|
||||||
|
className="BatteryInfoTableRowTitle"
|
||||||
|
hexpand
|
||||||
|
halign={START}
|
||||||
|
label="Health:"
|
||||||
|
/>
|
||||||
|
<label hexpand halign={END} label="92.5 %" />
|
||||||
|
</box>
|
||||||
|
<box>
|
||||||
|
<label
|
||||||
|
className="BatteryInfoTableRowTitle"
|
||||||
|
hexpand
|
||||||
|
halign={START}
|
||||||
|
label="Charge cycles:"
|
||||||
|
/>
|
||||||
|
<label hexpand halign={END} label="325" />
|
||||||
|
</box>
|
||||||
|
<box>
|
||||||
|
<label
|
||||||
|
className="BatteryInfoTableRowTitle"
|
||||||
|
hexpand
|
||||||
|
halign={START}
|
||||||
|
label="Power draw:"
|
||||||
|
/>
|
||||||
|
<label hexpand halign={END} label="0.0 W" />
|
||||||
|
</box>
|
||||||
|
<box>
|
||||||
|
<label
|
||||||
|
className="BatteryInfoTableRowTitle"
|
||||||
|
hexpand
|
||||||
|
halign={START}
|
||||||
|
label="Voltage:"
|
||||||
|
/>
|
||||||
|
<label hexpand halign={END} label="12.1 V" />
|
||||||
|
</box>
|
||||||
|
</box>
|
||||||
|
</box>
|
||||||
|
</window>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default BatteryMenu;
|
||||||
File renamed without changes.
@@ -10,7 +10,7 @@ function lengthStr(length: number) {
|
|||||||
return `${min}:${sec0}${sec}`;
|
return `${min}:${sec0}${sec}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
export default function Media() {
|
export default function MediaMenu() {
|
||||||
const { TOP, RIGHT } = Astal.WindowAnchor;
|
const { TOP, RIGHT } = Astal.WindowAnchor;
|
||||||
const mpris = Mpris.get_default();
|
const mpris = Mpris.get_default();
|
||||||
|
|
||||||
@@ -0,0 +1,22 @@
|
|||||||
|
window.Powermenu {
|
||||||
|
margin: 5px;
|
||||||
|
background-color: transparent;
|
||||||
|
box {
|
||||||
|
margin: 5px;
|
||||||
|
background-color: black;
|
||||||
|
border-radius: 25px;
|
||||||
|
button {
|
||||||
|
all: unset;
|
||||||
|
margin: 2px;
|
||||||
|
padding: 5px 15px 5px 13px;
|
||||||
|
background-color: black;
|
||||||
|
border-radius: 25px;
|
||||||
|
transition: 300ms;
|
||||||
|
background-color: rgb(70, 70, 70);
|
||||||
|
|
||||||
|
&:hover {
|
||||||
|
background-color: gray;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,26 @@
|
|||||||
|
import { Astal, App } from "astal/gtk3";
|
||||||
|
|
||||||
|
export default function PowerMenu() {
|
||||||
|
const { TOP, RIGHT } = Astal.WindowAnchor
|
||||||
|
const powermenulist = [
|
||||||
|
{action: "/home/tola/.config/ags/scripts/powermenu lock", label: ""},
|
||||||
|
{action: "/home/tola/.config/ags/scripts/powermenu suspend", label: ""},
|
||||||
|
{action: "/home/tola/.config/ags/scripts/powermenu logout", label: ""},
|
||||||
|
{action: "/home/tola/.config/ags/scripts/powermenu reboot", label: ""},
|
||||||
|
{action: "/home/tola/.config/ags/scripts/powermenu poweroff", label: ""}
|
||||||
|
]
|
||||||
|
|
||||||
|
return <window
|
||||||
|
anchor={TOP | RIGHT}
|
||||||
|
name="powermenu"
|
||||||
|
className="Powermenu"
|
||||||
|
application={App}
|
||||||
|
visible={false}
|
||||||
|
>
|
||||||
|
<box>
|
||||||
|
{powermenulist.map(data => (
|
||||||
|
<button onClicked={data.action}>{data.label}</button>
|
||||||
|
))}
|
||||||
|
</box>
|
||||||
|
</window>
|
||||||
|
}
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
@use "./BatteryMenu/BatteryMenu.scss";
|
||||||
|
@use "./MediaMenu/MediaMenu.scss";
|
||||||
|
@use "./Powermenu/PowerMenu.scss";
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
import BatteryMenu from "./BatteryMenu/BatteryMenu";
|
||||||
|
import MediaMenu from "./MediaMenu/MediaMenu";
|
||||||
|
import PowerMenu from "./Powermenu/PowerMenu";
|
||||||
|
|
||||||
|
export { BatteryMenu, MediaMenu, PowerMenu };
|
||||||
@@ -1,12 +1,16 @@
|
|||||||
.Battery {
|
.Battery {
|
||||||
background-color: rgb(70, 70, 70);
|
background-color: rgb(70, 70, 70);
|
||||||
border-radius: 25px;
|
border-radius: 25px;
|
||||||
border: 3pt solid black;
|
border: 3pt solid black;
|
||||||
padding: 0 5px;
|
padding: 0 5px;
|
||||||
icon {
|
transition: 300ms;
|
||||||
margin: 0 5px;
|
&:hover {
|
||||||
}
|
background-color: gray;
|
||||||
label {
|
}
|
||||||
margin: 0 5px 0 0;
|
icon {
|
||||||
}
|
margin: 0 5px;
|
||||||
|
}
|
||||||
|
label {
|
||||||
|
margin: 0 5px 0 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -1,15 +1,26 @@
|
|||||||
import { bind } from "astal"
|
import { bind } from "astal";
|
||||||
import Battery from "gi://AstalBattery"
|
import Battery from "gi://AstalBattery";
|
||||||
|
import { close_all_menus } from "../../utils/windows";
|
||||||
|
import { App } from "astal/gtk3";
|
||||||
|
|
||||||
export default function BatteryLevel() {
|
export default function BatteryLevel() {
|
||||||
const bat = Battery.get_default()
|
const bat = Battery.get_default();
|
||||||
console.log(bat.charging, bat.capacity, bat.energyFull, bat.energy_full_design)
|
|
||||||
|
|
||||||
return <box className="Battery"
|
return (
|
||||||
visible={bind(bat, "isPresent")}>
|
<button
|
||||||
|
onClicked={() => {
|
||||||
|
close_all_menus("batterymenu");
|
||||||
|
App.toggle_window("batterymenu");
|
||||||
|
}}
|
||||||
|
className="Battery"
|
||||||
|
visible={bind(bat, "isPresent")}
|
||||||
|
>
|
||||||
|
<box>
|
||||||
<icon icon={bind(bat, "batteryIconName")} />
|
<icon icon={bind(bat, "batteryIconName")} />
|
||||||
<label label={bind(bat, "percentage").as(p =>
|
<label
|
||||||
`${Math.floor(p * 100)} %`
|
label={bind(bat, "percentage").as((p) => `${Math.floor(p * 100)} %`)}
|
||||||
)} />
|
/>
|
||||||
</box>
|
</box>
|
||||||
}
|
</button>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -1,13 +1,11 @@
|
|||||||
import BatteryLevel from "./Battery/Battery";
|
import BatteryLevel from "./Battery/Battery";
|
||||||
import Cpu from "./Cpu/Cpu";
|
import Cpu from "./Cpu/Cpu";
|
||||||
import FocusedClient from "./FocusedClient/FocusedClient";
|
import FocusedClient from "./FocusedClient/FocusedClient";
|
||||||
import PowerMenu from "./Powermenu/PowerMenu";
|
|
||||||
import Ram from "./Ram/Ram";
|
import Ram from "./Ram/Ram";
|
||||||
import Storage from "./Storage/Storage";
|
import Storage from "./Storage/Storage";
|
||||||
import SysTray from "./SysTray/SysTray";
|
import SysTray from "./SysTray/SysTray";
|
||||||
import Time from "./Time/Time";
|
import Time from "./Time/Time";
|
||||||
import Workspaces from "./Workspaces/Workspaces";
|
import Workspaces from "./Workspaces/Workspaces";
|
||||||
import Media from "./Media/Media";
|
|
||||||
import LauncherButton from "./LauncherButton";
|
import LauncherButton from "./LauncherButton";
|
||||||
import PowerMenuButton from "./PowerMenuButton";
|
import PowerMenuButton from "./PowerMenuButton";
|
||||||
import MediaPlayerButton from "./MediaPlayerButton";
|
import MediaPlayerButton from "./MediaPlayerButton";
|
||||||
@@ -17,13 +15,11 @@ export {
|
|||||||
BatteryLevel,
|
BatteryLevel,
|
||||||
Cpu,
|
Cpu,
|
||||||
FocusedClient,
|
FocusedClient,
|
||||||
PowerMenu,
|
|
||||||
Ram,
|
Ram,
|
||||||
Storage,
|
Storage,
|
||||||
SysTray,
|
SysTray,
|
||||||
Time,
|
Time,
|
||||||
Workspaces,
|
Workspaces,
|
||||||
Media,
|
|
||||||
LauncherButton,
|
LauncherButton,
|
||||||
PowerMenuButton,
|
PowerMenuButton,
|
||||||
MediaPlayerButton,
|
MediaPlayerButton,
|
||||||
|
|||||||
@@ -1,5 +1,3 @@
|
|||||||
@use "./Media/Media.scss";
|
|
||||||
@use "./Powermenu/PowerMenu.scss";
|
|
||||||
@use "./Cpu/Cpu.scss";
|
@use "./Cpu/Cpu.scss";
|
||||||
@use "./Ram/Ram.scss";
|
@use "./Ram/Ram.scss";
|
||||||
@use "./Time/Time.scss";
|
@use "./Time/Time.scss";
|
||||||
@@ -8,4 +6,4 @@
|
|||||||
@use "./Workspaces/Workspaces.scss";
|
@use "./Workspaces/Workspaces.scss";
|
||||||
@use "./FocusedClient/FocusedClient.scss";
|
@use "./FocusedClient/FocusedClient.scss";
|
||||||
@use "./Volume/Volume.scss";
|
@use "./Volume/Volume.scss";
|
||||||
@use "./Battery/Battery.scss"
|
@use "./Battery/Battery.scss";
|
||||||
Reference in new issue
Block a user