Skip to content

Commit

Permalink
ui, theme: Show alias name as well if device name is different
Browse files Browse the repository at this point in the history
  • Loading branch information
darkhz committed Dec 27, 2023
1 parent 28c0a9f commit af177f8
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
2 changes: 2 additions & 0 deletions theme/themeconfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ const (
ThemeAdapterPairable ThemeContext = "AdapterPairable"
ThemeDevice ThemeContext = "Device"
ThemeDeviceType ThemeContext = "DeviceType"
ThemeDeviceAlias ThemeContext = "DeviceAlias"
ThemeDeviceConnected ThemeContext = "DeviceConnected"
ThemeDeviceDiscovered ThemeContext = "DeviceDiscovered"
ThemeDeviceProperty ThemeContext = "DeviceProperty"
Expand Down Expand Up @@ -52,6 +53,7 @@ var ThemeConfig = map[ThemeContext]string{

ThemeDevice: "white",
ThemeDeviceType: "white",
ThemeDeviceAlias: "white",
ThemeDeviceConnected: "white",
ThemeDeviceDiscovered: "white",
ThemeDeviceProperty: "grey",
Expand Down
12 changes: 11 additions & 1 deletion ui/device.go
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ func getDeviceInfo() {

props := [][]string{
{"Name", device.Name},
{"Alias", device.Alias},
{"Address", device.Address},
{"Class", strconv.FormatUint(uint64(device.Class), 10)},
{"Adapter", filepath.Base(device.Adapter)},
Expand Down Expand Up @@ -245,11 +246,20 @@ func getDeviceFromSelection(lock bool) bluez.Device {
func setDeviceTableInfo(row int, device bluez.Device) {
var props string

data := []string{
theme.ColorWrap(theme.ThemeDeviceType, device.Type),
}
name := device.Name
if name == "" {
name = device.Address
}
name += theme.ColorWrap(theme.ThemeDeviceType, " ("+device.Type+")")
if device.Alias != device.Name {
data = append(
[]string{theme.ColorWrap(theme.ThemeDeviceAlias, device.Alias)},
data...,
)
}
name += " (" + strings.Join(data, ", ") + ")"

nameColor := theme.ThemeDevice
propColor := theme.ThemeDeviceProperty
Expand Down

0 comments on commit af177f8

Please sign in to comment.