Compare commits
2
Commits
v1.0
..
8a459996ea
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8a459996ea | ||
|
|
baf2021aa9 |
No files matched your search
+16
-2
@@ -1,7 +1,7 @@
|
||||
@use "/tmp/ags-colors.scss" as wal;
|
||||
|
||||
$fg-color: wal.$foreground;
|
||||
$bg-color: rgba(wal.$background, 0.8);
|
||||
$bg-color: rgba(wal.$background, 1.0);
|
||||
|
||||
$btn-height: 30px;
|
||||
$btn-radius: 8px;
|
||||
@@ -14,7 +14,7 @@ window.Bar {
|
||||
font-weight: bold;
|
||||
|
||||
> centerbox {
|
||||
background: $bg-color;
|
||||
background: rgba(wal.$background, 1.0);
|
||||
border-radius: 10px;
|
||||
margin: 4px 8px;
|
||||
padding: 0 8px;
|
||||
@@ -201,6 +201,20 @@ window.PowerMenu {
|
||||
background: rgba(wal.$foreground, 0.1);
|
||||
}
|
||||
}
|
||||
|
||||
.qs-device-name {
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.qs-device-status {
|
||||
font-size: 0.9em;
|
||||
opacity: 0.7;
|
||||
}
|
||||
|
||||
.qs-battery {
|
||||
font-size: 0.9em;
|
||||
opacity: 0.7;
|
||||
}
|
||||
}
|
||||
|
||||
slider {
|
||||
|
||||
@@ -2,6 +2,7 @@ import { Gtk } from "ags/gtk4"
|
||||
import AstalNetwork from "gi://AstalNetwork?version=0.1"
|
||||
import AstalBluetooth from "gi://AstalBluetooth?version=0.1"
|
||||
import AstalWp from "gi://AstalWp?version=0.1"
|
||||
import AstalPowerProfiles from "gi://AstalPowerProfiles?version=0.1"
|
||||
import { createBinding, createComputed, createState, For } from "ags"
|
||||
import { interval } from "ags/time"
|
||||
import { exec, execAsync } from "ags/process"
|
||||
@@ -41,6 +42,23 @@ interval(2000, () => setVpns(fetchVpns()))
|
||||
|
||||
const vpnActive = vpns((list) => list.some((c) => c.active))
|
||||
|
||||
const POWER_PROFILE_ICONS: Record<string, string> = {
|
||||
"power-saver": "power-profile-power-saver-symbolic",
|
||||
balanced: "power-profile-balanced-symbolic",
|
||||
performance: "power-profile-performance-symbolic",
|
||||
}
|
||||
|
||||
const POWER_PROFILE_LABELS: Record<string, string> = {
|
||||
"power-saver": "Power Saver",
|
||||
balanced: "Balanced",
|
||||
performance: "Performance",
|
||||
}
|
||||
|
||||
const powerprofiles = AstalPowerProfiles.get_default()
|
||||
const activeProfile = createBinding(powerprofiles, "active-profile")
|
||||
const powerProfiles = powerprofiles.get_profiles().map((p) => p.profile)
|
||||
const hasPowerProfiles = powerProfiles.length > 0
|
||||
|
||||
function NetworkItem() {
|
||||
const network = AstalNetwork.Network.get_default()
|
||||
const primary = createBinding(network, "primary")
|
||||
@@ -190,6 +208,58 @@ function VpnList() {
|
||||
)
|
||||
}
|
||||
|
||||
function PowerProfileItem() {
|
||||
return (
|
||||
<menubutton cssClasses={["qs-item"]} hexpand>
|
||||
<box spacing={12} valign={Gtk.Align.CENTER}>
|
||||
<image
|
||||
iconName={activeProfile(
|
||||
(p) => POWER_PROFILE_ICONS[p] ?? "power-profile-balanced-symbolic",
|
||||
)}
|
||||
cssClasses={["qs-icon"]}
|
||||
/>
|
||||
<label
|
||||
label={activeProfile((p) => POWER_PROFILE_LABELS[p] ?? p)}
|
||||
halign={Gtk.Align.START}
|
||||
hexpand
|
||||
/>
|
||||
<image iconName="pan-down-symbolic" />
|
||||
</box>
|
||||
<popover>
|
||||
<box orientation={Gtk.Orientation.VERTICAL} spacing={4}>
|
||||
{powerProfiles.map((name) => (
|
||||
<button
|
||||
cssClasses={["qs-item"]}
|
||||
onClicked={(btn) => {
|
||||
powerprofiles.set_active_profile(name)
|
||||
const popover = btn.get_ancestor(
|
||||
Gtk.Popover.$gtype,
|
||||
) as Gtk.Popover | null
|
||||
popover?.popdown()
|
||||
}}
|
||||
>
|
||||
<box spacing={12} valign={Gtk.Align.CENTER}>
|
||||
<image
|
||||
iconName={
|
||||
POWER_PROFILE_ICONS[name] ??
|
||||
"power-profile-balanced-symbolic"
|
||||
}
|
||||
cssClasses={["qs-icon"]}
|
||||
/>
|
||||
<label
|
||||
label={POWER_PROFILE_LABELS[name] ?? name}
|
||||
halign={Gtk.Align.START}
|
||||
hexpand
|
||||
/>
|
||||
</box>
|
||||
</button>
|
||||
))}
|
||||
</box>
|
||||
</popover>
|
||||
</menubutton>
|
||||
)
|
||||
}
|
||||
|
||||
export default function QuickSettings() {
|
||||
return (
|
||||
<menubutton
|
||||
@@ -213,6 +283,18 @@ export default function QuickSettings() {
|
||||
<BluetoothItem />
|
||||
</box>
|
||||
<VpnList />
|
||||
<box
|
||||
orientation={Gtk.Orientation.VERTICAL}
|
||||
spacing={8}
|
||||
visible={hasPowerProfiles}
|
||||
>
|
||||
<label
|
||||
label="Power Profile"
|
||||
cssClasses={["qs-title"]}
|
||||
halign={Gtk.Align.START}
|
||||
/>
|
||||
<PowerProfileItem />
|
||||
</box>
|
||||
<box orientation={Gtk.Orientation.VERTICAL} spacing={8}>
|
||||
<button
|
||||
cssClasses={["qs-title"]}
|
||||
|
||||
Reference in new issue
Block a user