feat: UI for changing display orientation

* Added UI for changing display orientation.

* Fixed lint issue.
This commit is contained in:
Peder Toftegaard Olsen
2025-05-11 17:17:41 +02:00
committed by GitHub
parent d79f359c43
commit 5a4f1766b7
5 changed files with 75 additions and 0 deletions

View File

@@ -38,6 +38,10 @@ type JSONRPCEvent struct {
Params interface{} `json:"params,omitempty"`
}
type DisplayRotationSettings struct {
Rotation string `json:"rotation"`
}
type BacklightSettings struct {
MaxBrightness int `json:"max_brightness"`
DimAfter int `json:"dim_after"`
@@ -280,6 +284,24 @@ func rpcTryUpdate() error {
return nil
}
func rpcSetDisplayRotation(params DisplayRotationSettings) error {
var err error
_, err = lvDispSetRotation(params.Rotation)
if err == nil {
config.DisplayRotation = params.Rotation
if err := SaveConfig(); err != nil {
return fmt.Errorf("failed to save config: %w", err)
}
}
return err
}
func rpcGetDisplayRotation() (*DisplayRotationSettings, error) {
return &DisplayRotationSettings{
Rotation: config.DisplayRotation,
}, nil
}
func rpcSetBacklightSettings(params BacklightSettings) error {
blConfig := params
@@ -1012,6 +1034,8 @@ var rpcHandlers = map[string]RPCHandler{
"getWakeOnLanDevices": {Func: rpcGetWakeOnLanDevices},
"setWakeOnLanDevices": {Func: rpcSetWakeOnLanDevices, Params: []string{"params"}},
"resetConfig": {Func: rpcResetConfig},
"setDisplayRotation": {Func: rpcSetDisplayRotation, Params: []string{"params"}},
"getDisplayRotation": {Func: rpcGetDisplayRotation},
"setBacklightSettings": {Func: rpcSetBacklightSettings, Params: []string{"params"}},
"getBacklightSettings": {Func: rpcGetBacklightSettings},
"getDCPowerState": {Func: rpcGetDCPowerState},