Signed-off-by: Hadi <[email protected]>
This commit is contained in:
Hadi
2026-08-13 00:58:37 +02:00
commit 59b31e5ca3
103 changed files with 8577 additions and 0 deletions
+54
View File
@@ -0,0 +1,54 @@
// Package bluetooth provides the "Bluetooth" TUI page: a thin wrapper
// around bluetoothctl covering controller power and device
// pairing/connection, in the same spirit as the network page's Wi-Fi tab.
package bluetooth
import (
"charm.land/bubbles/v2/help"
tea "charm.land/bubbletea/v2"
ilovetui "github.com/anotherhadi/ilovetui"
"github.com/anotherhadi/settuings/internal/bluetooth"
)
type Model struct {
width int
height int
help help.Model
checkErr error // reason bluetoothctl is unusable; nil once confirmed OK
checked bool
controller bluetooth.ControllerInfo
list deviceListState
detail deviceDetailState
}
func New() Model {
return Model{
help: ilovetui.NewHelp(),
list: newDeviceListState(),
}
}
func (m Model) Init() tea.Cmd {
return nil
}
// Activate is called every time the user navigates onto this page. It
// re-checks bluetoothctl availability, fetches controller + device state,
// and starts the periodic auto-refresh loop.
func (m *Model) Activate() tea.Cmd {
return tea.Batch(checkCmd(), fetchControllerCmd(), fetchDevicesCmd(), tickCmd())
}
func (m Model) IsEditing() bool {
return m.list.confirmRemove
}
func (m *Model) SetSize(w, h int) {
m.width = w
m.height = h
m.help.SetWidth(w - 2)
m.resizeDetail()
}