0

With Go, how can i detect if the Windows or Mac PC is in landscape or portrait mode please? here is a following example where i need to read the action for layout if its landscape or portrait.

package main

import "os/exec"
import "runtime"
import "fmt"

const url = "http://localhost:8080/demo1?action=landscape"


func main() {      
  myos := runtime.GOOS
  /////------------------> Detect the landscape or portrait of the screen???


  if myos == "windows" {
    chrome := "C:/Program Files/Google/Chrome/Application/chrome.exe"
    cmd := exec.Command(chrome, "--chrome-frame", "--kiosk", url)
    err := cmd.Start()
    if err != nil {
      // 64-bit
      //println("Failed to start chrome:", err)
      chrome := "C:/Program Files (x86)/Google/Chrome/Application/chrome.exe"
      cmd := exec.Command(chrome, "--chrome-frame", "--kiosk", url)
      cmd.Start()       
    } 

  } else if myos == "darwin" {
    // open -b com.google.Chrome --args <which args to pass to Chrome>
    // "/Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome"
    //chrome := "/Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome"
    cmd := exec.Command("open", "-b" , "com.google.Chrome", "--args", "--chrome-frame", "--kiosk", url)
    err := cmd.Start()
    if err != nil {
      fmt.Println("failed")
    } 

  } else {
    //Linux    
    chrome := "google-chrome"
    cmd := exec.Command(chrome, "--chrome-frame", "--kiosk", url)
    err := cmd.Start()
    if err != nil {
      fmt.Println("failed")
    }

  }

}
  • 1
    On Windows, the question is answered here: http://stackoverflow.com/questions/4631292/how-detect-current-screen-resolution – selbie Jan 28 '14 at 06:34

1 Answers1

0

Once again, not a direct answer to your question, but may solve your problem.

See this for a description. All you really need to do is check the dimensions of the window via javascript and reload the page with the correct args.

if height > width, it's portrait mode, otherwise it's landscape

Community
  • 1
  • 1
David Budworth
  • 11,248
  • 1
  • 36
  • 45
  • Then there is a problem with rotation , flipping the image etc if its not accurately identified of the original os settings. you can also manually with custom tool increase the height of a window to unlimited . –  Jan 31 '14 at 07:17
  • ahh, never mind then. I assumed that since you were using kiosk mode, you wouldn't have that issue – David Budworth Feb 02 '14 at 03:30