feat: add monitor picker to the GUI settings
Enumerate monitors via hyprctl (Hyprland) and present them as a dropdown in the settings window instead of a raw index. The picker is enabled only for the screen source and persists the selected monitor as stream_index. Falls back to a single indexed option when enumeration is unavailable (non-Hyprland).
This commit is contained in:
@@ -0,0 +1,42 @@
|
||||
package capture
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"testing"
|
||||
)
|
||||
|
||||
// TestHyprctlMonitors parses a representative `hyprctl monitors -j` payload.
|
||||
func TestHyprctlMonitors(t *testing.T) {
|
||||
payload := `[
|
||||
{
|
||||
"id": 0,
|
||||
"name": "eDP-1",
|
||||
"description": "BOE 0x094C",
|
||||
"width": 1920,
|
||||
"height": 1200,
|
||||
"focused": true
|
||||
},
|
||||
{
|
||||
"id": 1,
|
||||
"name": "HDMI-A-1",
|
||||
"description": "Samsung",
|
||||
"width": 2560,
|
||||
"height": 1440,
|
||||
"focused": false
|
||||
}
|
||||
]`
|
||||
|
||||
var raw []hyprctlMonitor
|
||||
if err := json.Unmarshal([]byte(payload), &raw); err != nil {
|
||||
t.Fatalf("unmarshal: %v", err)
|
||||
}
|
||||
if len(raw) != 2 {
|
||||
t.Fatalf("got %d monitors, want 2", len(raw))
|
||||
}
|
||||
if raw[0].ID != 0 || raw[0].Name != "eDP-1" || raw[0].Width != 1920 {
|
||||
t.Errorf("monitor 0 wrong: %+v", raw[0])
|
||||
}
|
||||
if raw[1].ID != 1 || raw[1].Focused {
|
||||
t.Errorf("monitor 1 wrong: %+v", raw[1])
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user