refactored code
This commit is contained in:
parent
413cc87706
commit
e281188f01
@ -2,6 +2,7 @@ package xrandr
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
|
"encoding/json"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
|
|
||||||
"git.milar.in/milarin/bufr"
|
"git.milar.in/milarin/bufr"
|
||||||
@ -31,3 +32,8 @@ func GetCurrentConfig() (*Config, error) {
|
|||||||
|
|
||||||
return &Config{configs}, nil
|
return &Config{configs}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (c *Config) String() string {
|
||||||
|
data, _ := json.MarshalIndent(c, "", "\t")
|
||||||
|
return string(data)
|
||||||
|
}
|
||||||
|
@ -1,17 +0,0 @@
|
|||||||
package xrandr
|
|
||||||
|
|
||||||
import (
|
|
||||||
"fmt"
|
|
||||||
"testing"
|
|
||||||
)
|
|
||||||
|
|
||||||
func TestConfig(t *testing.T) {
|
|
||||||
configs, err := GetCurrentConfig()
|
|
||||||
if err != nil {
|
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
|
|
||||||
for _, config := range configs.Displays {
|
|
||||||
fmt.Println(config)
|
|
||||||
}
|
|
||||||
}
|
|
@ -54,7 +54,7 @@ func parseDisplayConfig(r *bufr.Reader) (*DisplayConfig, error) {
|
|||||||
Primary: strings.TrimSpace(matches[3]) == "primary",
|
Primary: strings.TrimSpace(matches[3]) == "primary",
|
||||||
Resolution: NewResolutionFromString(matches[4], matches[5]),
|
Resolution: NewResolutionFromString(matches[4], matches[5]),
|
||||||
Position: NewPositionFromString(matches[6], matches[7]),
|
Position: NewPositionFromString(matches[6], matches[7]),
|
||||||
Rotation: MakeRotation(matches[8]),
|
Rotation: makeRotation(matches[8]),
|
||||||
Reflection: MakeReflection(matches[9]),
|
Reflection: MakeReflection(matches[9]),
|
||||||
DimensionsMillimeter: NewResolutionFromString(matches[11], matches[12]),
|
DimensionsMillimeter: NewResolutionFromString(matches[11], matches[12]),
|
||||||
ActiveMode: active,
|
ActiveMode: active,
|
||||||
|
@ -9,7 +9,7 @@ const (
|
|||||||
RotationRight Rotation = "right"
|
RotationRight Rotation = "right"
|
||||||
)
|
)
|
||||||
|
|
||||||
func MakeRotation(rot string) Rotation {
|
func makeRotation(rot string) Rotation {
|
||||||
switch rot {
|
switch rot {
|
||||||
|
|
||||||
case "normal":
|
case "normal":
|
||||||
|
Loading…
Reference in New Issue
Block a user