diff --git a/nixosModules/ags/v2/widgets/bar/items/current-client.tsx b/nixosModules/ags/v2/widgets/bar/items/current-client.tsx index 6b39ee28..751dd1f3 100644 --- a/nixosModules/ags/v2/widgets/bar/items/current-client.tsx +++ b/nixosModules/ags/v2/widgets/bar/items/current-client.tsx @@ -16,7 +16,7 @@ export default () => { let lastFocused: string | undefined; const updateVars = ( - client: AstalHyprland.Client | null | undefined = Hyprland.get_focused_client(), + client: AstalHyprland.Client | null = Hyprland.get_focused_client(), ) => { lastFocused = client?.get_address(); const app = Applications.query( diff --git a/nixosModules/ags/v2/widgets/bar/items/tray.tsx b/nixosModules/ags/v2/widgets/bar/items/tray.tsx new file mode 100644 index 00000000..67f98c30 --- /dev/null +++ b/nixosModules/ags/v2/widgets/bar/items/tray.tsx @@ -0,0 +1,77 @@ +import { App, bind, Gdk, Gtk, idle, Widget } from 'astal'; + +import AstalTray from 'gi://AstalTray'; +const Tray = AstalTray.get_default(); + + +const SKIP_ITEMS = ['.spotify-wrapped']; + +const TrayItem = (item: AstalTray.TrayItem) => { + if (item.iconThemePath) { + App.add_icons(item.iconThemePath); + } + + const menu = item.create_menu(); + + return ( + + + + ); +}; + +export default () => { + const itemMap = new Map(); + + return ( + items.length !== 0)} + setup={(self) => { + self + .hook(Tray, 'item-added', (_, item: string) => { + if (itemMap.has(item) || SKIP_ITEMS.includes(Tray.get_item(item).title)) { + return; + } + + const widget = TrayItem(Tray.get_item(item)) as Widget.Revealer; + + itemMap.set(item, widget); + + self.add(widget); + + idle(() => { + widget.set_reveal_child(true); + }); + }) + + .hook(Tray, 'item-removed', (_, item: string) => { + if (!itemMap.has(item)) { + return; + } + + const widget = itemMap.get(item); + + widget?.set_reveal_child(false); + + setTimeout(() => { + widget?.destroy(); + }, 1000); + }); + }} + /> + ); +}; diff --git a/nixosModules/ags/v2/widgets/bar/style.scss b/nixosModules/ags/v2/widgets/bar/style.scss index 59cb985e..1a85e4af 100644 --- a/nixosModules/ags/v2/widgets/bar/style.scss +++ b/nixosModules/ags/v2/widgets/bar/style.scss @@ -1,4 +1,6 @@ .bar { + margin-bottom: 13px; + .bar-item { padding: 5px 10px 5px 10px; border-radius: 7px; @@ -6,7 +8,7 @@ font-size: 20px; min-height: 35px; - .battery icon { + &.battery icon { &.charging { color: green; } @@ -42,5 +44,19 @@ transition: margin-left 0.5s cubic-bezier(0.34, 1.56, 0.64, 1); } } + + &.system-tray { + .tray-item { + all: unset; + font-size: 30px; + min-width: 36px; + border-radius: 100%; + transition: background-color 300ms; + + &:hover { + background: $window_bg_color; + } + } + } } } diff --git a/nixosModules/ags/v2/widgets/bar/wim.tsx b/nixosModules/ags/v2/widgets/bar/wim.tsx index 28ddf1b6..84092642 100644 --- a/nixosModules/ags/v2/widgets/bar/wim.tsx +++ b/nixosModules/ags/v2/widgets/bar/wim.tsx @@ -3,6 +3,7 @@ import { Astal, Gtk } from 'astal'; import Battery from './items/battery'; import Clock from './items/clock'; import CurrentClient from './items/current-client'; +import SysTray from './items/tray'; import Workspaces from './items/workspaces'; import BarRevealer from './fullscreen'; @@ -24,7 +25,13 @@ export default () => ( + + + + + +