diff --git a/modules/home/ags/app/style.scss b/modules/home/ags/app/style.scss index efe11ec..1359db9 100644 --- a/modules/home/ags/app/style.scss +++ b/modules/home/ags/app/style.scss @@ -91,8 +91,7 @@ $module-bg: transparentize($base02, 0.4); color: $base00; } -.ws:hover, -.battery:hover { +.ws:hover { background: transparentize($base05, 0.88); } @@ -254,14 +253,23 @@ $module-bg: transparentize($base02, 0.4); background: transparentize($base05, 0.88); } -.battery-percent { - font-size: 1.6em; - font-weight: bold; -} - .battery-level { font-size: 0.85em; - margin-left: 3px; +} + +.battery-section { + margin-top: 10px; + border-top: 1px solid $base02; + padding-top: 8px; + + icon { + font-size: 16px; + } +} + +.battery-percent { + font-weight: bold; + margin: 0 6px; } .battery-status { @@ -269,6 +277,49 @@ $module-bg: transparentize($base02, 0.4); opacity: 0.7; } +.notif-section { + margin-top: 10px; + border-top: 1px solid $base02; + padding-top: 8px; +} + +.notif-toggle { + padding: 4px 6px; + border-radius: 6px; + + label { + font-weight: bold; + margin: 0 2px; + } + + &:hover { + background: transparentize($base05, 0.88); + } +} + +.notif-clear { + padding: 4px 10px; + border-radius: 6px; + font-size: 0.85em; + + &:hover { + background: transparentize($base05, 0.88); + } +} + +.notif-empty { + font-size: 0.85em; + opacity: 0.7; +} + +.quicksettings .notif-count { + font-size: 0.8em; +} + +.notif-section .notif { + background: $base02; +} + .notifications { .notif { background: $base01; diff --git a/modules/home/ags/app/widget/Bar.tsx b/modules/home/ags/app/widget/Bar.tsx index e5e4c93..273b670 100644 --- a/modules/home/ags/app/widget/Bar.tsx +++ b/modules/home/ags/app/widget/Bar.tsx @@ -2,7 +2,6 @@ import { App, Astal, Gdk, Gtk } from "astal/gtk3" import Workspaces from "./Workspaces" import Logo from "./Logo" import Clock from "./Clock" -import { BatteryWidget } from "./Battery" import QuickSettings from "./QuickSettings" const RADIUS = 12 @@ -54,16 +53,11 @@ function Corner({ side }: { side: "left" | "right" }) { export default function Bar(gdkmonitor: Gdk.Monitor) { const { TOP, LEFT, RIGHT } = Astal.WindowAnchor - const battery = BatteryWidget(gdkmonitor) const quicksettings = QuickSettings(gdkmonitor) - const right: Array = [] - if (battery.button) right.push(battery.button) - right.push(quicksettings.button) + const right: Array = [quicksettings.button] - const popups: Array = [] - if (battery.popup) popups.push(battery.popup) - popups.push(quicksettings.popup) + const popups: Array = [quicksettings.popup] return [ ( diff --git a/modules/home/ags/app/widget/Battery.tsx b/modules/home/ags/app/widget/Battery.tsx index 51da56e..94ec201 100644 --- a/modules/home/ags/app/widget/Battery.tsx +++ b/modules/home/ags/app/widget/Battery.tsx @@ -1,6 +1,6 @@ +import Gtk from "gi://Gtk?version=3.0" import AstalBattery from "gi://AstalBattery" -import { Variable, bind } from "astal" -import Dropdown from "./Dropdown" +import { type Binding, Variable, bind } from "astal" const battery = AstalBattery.get_default() @@ -31,28 +31,20 @@ const status = Variable.derive( }, ) -export function BatteryWidget(gdkmonitor: Gdk.Monitor) { - if (!battery.isBattery) return { button: null, popup: null } +export const batteryIcon: Binding | null = battery.isBattery + ? bind(battery, "icon-name") + : null - const open = Variable(false) +export const batteryPercent: Binding | null = battery.isBattery + ? bind(battery, "percentage").as((p) => `${Math.round(p * 100)}%`) + : null - const button = ( - - ) +export function BatterySection() { + if (!battery.isBattery) return - const popup = ( - + return ( + + + ) - - return { button, popup } } \ No newline at end of file diff --git a/modules/home/ags/app/widget/Notifications.tsx b/modules/home/ags/app/widget/Notifications.tsx index 07242fe..2f4b240 100644 --- a/modules/home/ags/app/widget/Notifications.tsx +++ b/modules/home/ags/app/widget/Notifications.tsx @@ -32,7 +32,7 @@ function formatTime(n: Notifd.Notification) { return GLib.DateTime.new_from_unix_local(n.time).format("%H:%M")! } -function NotificationCard(n: Notifd.Notification) { +export function NotificationCard(n: Notifd.Notification) { const critical = n.urgency === Notifd.Urgency.CRITICAL return ( diff --git a/modules/home/ags/app/widget/QuickSettings.tsx b/modules/home/ags/app/widget/QuickSettings.tsx index e718a5c..f6162e3 100644 --- a/modules/home/ags/app/widget/QuickSettings.tsx +++ b/modules/home/ags/app/widget/QuickSettings.tsx @@ -1,10 +1,17 @@ +import Gtk from "gi://Gtk?version=3.0" import AstalWp from "gi://AstalWp" +import Notifd from "gi://AstalNotifd" import { execAsync, Variable, bind } from "astal" import Dropdown from "./Dropdown" import { wifiIcon, WifiSection } from "./Wifi" +import { batteryIcon, batteryPercent, BatterySection } from "./Battery" +import { NotificationCard } from "./Notifications" const speaker = AstalWp.get_default().audio.default_speaker! const mic = AstalWp.get_default().audio.default_microphone +const notifd = Notifd.get_default() + +const notifCount = bind(notifd, "notifications").as((ns) => ns.length) const speakerIcon = Variable.derive( [bind(speaker, "volume"), bind(speaker, "mute")], @@ -34,6 +41,11 @@ const actions = [ export default function QuickSettings(gdkmonitor: Gdk.Monitor) { const open = Variable(false) + const notifOpen = Variable(false) + + open.subscribe((v) => { + if (!v) notifOpen.set(false) + }) const button = ( ) @@ -98,6 +124,51 @@ export default function QuickSettings(gdkmonitor: Gdk.Monitor) { )} + + + + + + + + + + + )