diff --git a/config.go b/config.go index f1b72d7..e1ec895 100644 --- a/config.go +++ b/config.go @@ -2,6 +2,7 @@ package xrandr import ( "bytes" + "encoding/json" "os/exec" "git.milar.in/milarin/bufr" @@ -31,3 +32,8 @@ func GetCurrentConfig() (*Config, error) { return &Config{configs}, nil } + +func (c *Config) String() string { + data, _ := json.MarshalIndent(c, "", "\t") + return string(data) +} diff --git a/config_test.go b/config_test.go deleted file mode 100644 index 2adf268..0000000 --- a/config_test.go +++ /dev/null @@ -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) - } -} diff --git a/display_config.go b/display_config.go index 580a4aa..414bac2 100644 --- a/display_config.go +++ b/display_config.go @@ -54,7 +54,7 @@ func parseDisplayConfig(r *bufr.Reader) (*DisplayConfig, error) { Primary: strings.TrimSpace(matches[3]) == "primary", Resolution: NewResolutionFromString(matches[4], matches[5]), Position: NewPositionFromString(matches[6], matches[7]), - Rotation: MakeRotation(matches[8]), + Rotation: makeRotation(matches[8]), Reflection: MakeReflection(matches[9]), DimensionsMillimeter: NewResolutionFromString(matches[11], matches[12]), ActiveMode: active, diff --git a/rotation.go b/rotation.go index b89a0f1..0cd238d 100644 --- a/rotation.go +++ b/rotation.go @@ -9,7 +9,7 @@ const ( RotationRight Rotation = "right" ) -func MakeRotation(rot string) Rotation { +func makeRotation(rot string) Rotation { switch rot { case "normal":