diff --git a/modules/menus/bluetooth/devices/devicelist.ts b/modules/menus/bluetooth/devices/devicelist.ts index e1fdcc9..d701a81 100644 --- a/modules/menus/bluetooth/devices/devicelist.ts +++ b/modules/menus/bluetooth/devices/devicelist.ts @@ -4,6 +4,9 @@ import { connectedControls } from './connectedControls.js'; import { getBluetoothIcon } from '../utils.js'; import Gtk from 'types/@girs/gtk-3.0/gtk-3.0.js'; import { Attribute, Child } from 'lib/types/widget.js'; +import options from 'options'; + +const { showBattery, batteryIcon } = options.menus.bluetooth; const devices = (bluetooth: Bluetooth, self: Box): Box => { return self.hook(bluetooth, () => { @@ -101,10 +104,57 @@ const devices = (bluetooth: Bluetooth, self: Box): Box { + if (!showBat) { + return [ + Widget.Label({ + hpack: 'start', + class_name: 'connection-status dim', + label: device.connected + ? 'Connected' + : 'Paired', + }), + ]; + } + + return [ + Widget.Label({ + hpack: 'start', + class_name: 'connection-status dim', + label: device.connected + ? 'Connected' + : 'Paired', + }), + Widget.Box({ + children: + typeof device.battery_percentage === + 'number' && + device.battery_percentage >= 0 + ? [ + Widget.Separator({ + class_name: + 'menu-separator', + }), + Widget.Label({ + class_name: + 'connection-status txt-icon', + label: `${batIcon}`, + }), + Widget.Label({ + class_name: + 'connection-status battery', + label: `${device.battery_percentage}%`, + }), + ] + : [], + }), + ]; + }, + ), }), }), ], diff --git a/options.ts b/options.ts index 855351b..f7f1b7d 100644 --- a/options.ts +++ b/options.ts @@ -1054,6 +1054,10 @@ const options = mkOptions(OPTIONS, { menus: { transition: opt('crossfade'), transitionTime: opt(200), + bluetooth: { + showBattery: opt(false), + batteryIcon: opt('󰥉'), + }, volume: { raiseMaximumVolume: opt(false), }, diff --git a/scss/style/menus/bluetooth.scss b/scss/style/menus/bluetooth.scss index 19dd17c..9ea32b7 100644 --- a/scss/style/menus/bluetooth.scss +++ b/scss/style/menus/bluetooth.scss @@ -111,6 +111,9 @@ color: if($bar-menus-monochrome, $bar-menus-text, $bar-menus-menu-bluetooth-text); opacity: 0.4; } + .battery{ + opacity: 0.6; + } } spinner { diff --git a/widget/settings/pages/config/index.ts b/widget/settings/pages/config/index.ts index db212f0..c6dcf9b 100644 --- a/widget/settings/pages/config/index.ts +++ b/widget/settings/pages/config/index.ts @@ -7,6 +7,7 @@ import { OSDSettings } from './osd/index'; import { CustomModuleSettings } from 'customModules/config'; import { PowerMenuSettings } from './menus/power'; import { GBox } from 'lib/types/widget'; +import { BluetoothMenuSettings } from './menus/bluetooth'; import { VolumeMenuSettings } from './menus/volume'; type Page = @@ -15,6 +16,7 @@ type Page = | 'Clock Menu' | 'Dashboard Menu' | 'Power Menu' + | 'Bluetooth Menu' | 'Volume' | 'Notifications' | 'OSD' @@ -28,6 +30,7 @@ const pagerMap: Page[] = [ 'Notifications', 'OSD', 'Power Menu', + 'Bluetooth Menu', 'Volume', 'Clock Menu', 'Dashboard Menu', @@ -64,6 +67,7 @@ export const SettingsMenu = (): GBox => { 'Clock Menu': ClockMenuSettings(), 'Dashboard Menu': DashboardMenuSettings(), 'Custom Modules': CustomModuleSettings(), + 'Bluetooth Menu': BluetoothMenuSettings(), 'Power Menu': PowerMenuSettings(), }, shown: CurrentPage.bind('value'), diff --git a/widget/settings/pages/config/menus/bluetooth.ts b/widget/settings/pages/config/menus/bluetooth.ts new file mode 100644 index 0000000..7bfeb1c --- /dev/null +++ b/widget/settings/pages/config/menus/bluetooth.ts @@ -0,0 +1,29 @@ +import { Option } from 'widget/settings/shared/Option'; +import { Header } from 'widget/settings/shared/Header'; + +import options from 'options'; +import Scrollable from 'types/widgets/scrollable'; +import { Attribute, Child } from 'lib/types/widget'; + +export const BluetoothMenuSettings = (): Scrollable => { + return Widget.Scrollable({ + vscroll: 'automatic', + child: Widget.Box({ + class_name: 'bar-theme-page paged-container', + vertical: true, + children: [ + Header('Bluetooth'), + Option({ + opt: options.menus.bluetooth.showBattery, + title: 'Show Battery Percentage for Connected Devices (If Supported)', + type: 'boolean', + }), + Option({ + opt: options.menus.bluetooth.batteryIcon, + title: 'Battery Icon', + type: 'string', + }), + ], + }), + }); +};