diff --git a/config/astal/components/bar/modules/QuickView.tsx b/config/astal/components/bar/modules/QuickView.tsx index 9aacd28..f3f7243 100644 --- a/config/astal/components/bar/modules/QuickView.tsx +++ b/config/astal/components/bar/modules/QuickView.tsx @@ -1,4 +1,5 @@ import { bind } from "astal"; +import { execAsync } from "astal"; import AstalBattery from "gi://AstalBattery"; import AstalBluetooth from "gi://AstalBluetooth"; import AstalNetwork from "gi://AstalNetwork"; @@ -120,6 +121,8 @@ const BluetoothWidget = () => { ); }; + +let hasSentNotification = false; const BatteryWidget = () => { const battery = AstalBattery.get_default(); if (battery.get_is_present()) { @@ -127,7 +130,14 @@ const BatteryWidget = () => { icon)} cssClasses={["quick-view-symbol"]} - tooltipText={bind(battery, 'percentage').as(p => `Battery Level: ${Math.round(p * 100)}%`)} + tooltipText={bind(battery, 'percentage').as(p => { + const level = Math.round(p * 100) + if ( level < 20 && !hasSentNotification ) { + hasSentNotification = true; + execAsync( 'bash -c "notify-send \'Battery level below 20%\'"' ); + } + return `Battery Level: ${level}%` + })} > ); } else {