haimgel / display-switch

Turn a $30 USB switch into a full-featured multi-monitor KVM switch
https://haim.dev/posts/2020-07-28-dual-monitor-kvm/
MIT License
2.83k stars 110 forks source link

failed to load configuration #76

Closed ziobbe closed 2 years ago

ziobbe commented 2 years ago

Hello, thanks for putting the time into this project, it is the simplest setup I've seen for this purpose.

I'm having issues starting the service: even if I have theese config files set up: $cat ~/.config/display-switch/display-switch.ini

usb_device = "04d9:a0cd"
monitor_id = "ViewSonic"
on_usb_connect = "DisplayPort1"
on_usb_disconnect ="Hdmi1"
on_usb_connect_execute = "echo connected"
on_usb_disconnect_execute = "echo disconnected"

$ cat /etc/display-switch.ini

usb_device = "04d9:a0cd"
monitor_id = "ViewSonic"
on_usb_connect = "DisplayPort1"
on_usb_disconnect ="Hdmi1"
on_usb_connect_execute = "echo connected"
on_usb_disconnect_execute = "echo disconnected"

I get this error:

Dec 13 18:35:43 Hoggrs-endevour display_switch[94911]: Error: failed to load configuration
Dec 13 18:35:43 Hoggrs-endevour display_switch[94911]: Caused by:
Dec 13 18:35:43 Hoggrs-endevour display_switch[94911]:     missing field `usb_device`
Dec 13 18:35:43 Hoggrs-endevour systemd[1]: display_switch.service: Main process exited, code=exited, status=1/FAILURE
Dec 13 18:35:43 Hoggrs-endevour systemd[1]: display_switch.service: Failed with result 'exit-code'.
jordevorstenbosch commented 2 years ago

The ini loads fine for me on Windows, have you tried using only 1 ini file?

Try to place the monitor_id under a [monitor#] header.

Like so:

usb_device = "04d9:a0cd"

[monitor1]
monitor_id = "ViewSonic"
on_usb_connect = "DisplayPort1"
on_usb_disconnect ="Hdmi1"
on_usb_connect_execute = "echo connected"
on_usb_disconnect_execute = "echo disconnected"