mirror of
https://github.com/gen2brain/cam2ip.git
synced 2026-07-08 23:35:07 +00:00
feat(linux): Show device path in --list-devices
This commit is contained in:
@@ -20,6 +20,8 @@ type Options struct {
|
||||
type DeviceInfo struct {
|
||||
Index int
|
||||
Name string
|
||||
// Path is the OS device path (e.g. /dev/video0); Linux only, empty elsewhere.
|
||||
Path string
|
||||
}
|
||||
|
||||
// Info describes the negotiated capture format.
|
||||
|
||||
@@ -261,7 +261,7 @@ func Devices() ([]DeviceInfo, error) {
|
||||
name = d.Path
|
||||
}
|
||||
|
||||
devices = append(devices, DeviceInfo{Index: i, Name: name})
|
||||
devices = append(devices, DeviceInfo{Index: i, Name: name, Path: d.Path})
|
||||
}
|
||||
|
||||
return devices, nil
|
||||
|
||||
@@ -103,7 +103,11 @@ func main() {
|
||||
}
|
||||
|
||||
for _, d := range devices {
|
||||
fmt.Printf("%d: %s\n", d.Index, d.Name)
|
||||
if d.Path != "" {
|
||||
fmt.Printf("%d: %s (%s)\n", d.Index, d.Name, d.Path)
|
||||
} else {
|
||||
fmt.Printf("%d: %s\n", d.Index, d.Name)
|
||||
}
|
||||
}
|
||||
|
||||
os.Exit(0)
|
||||
|
||||
Reference in New Issue
Block a user