1

I'm looking at AppJS as a possible candidate to build a cross-browser application. AppJS runs HTML5 content with a Chromium window with hooks to NodeJS.

Is there a NodeJS module that can give me an enumeration of displays currently active? I need to support dual-monitor setups and knowing the bounds of each display is required.

I've search the Node npm directory with no luck so far.

Update:

Based on sihorton's answer, I'm playing with a javascript approach. Browser security prohibits my first approach from working in normal Chrome, but I will try this on AppJS chromium when I get home. Code here and here.

The basic approach is running code like:

OpenWindow('http://jsbin.com/axiwad/3/','test',400,500);

and then the opened window runs:

  window.moveTo(screen.width+2, 0);

  setTimeout(function(){
    $(".s2w").html(screen.width+2);
    $(".s2h").html(screen.height);
  }, 500);

The issue of course, is that browser do not allow a moveTo outside the active screen boundary. It remains to be seen if AppJS chromium fork allows this.

Andrew Grothe
  • 2,562
  • 1
  • 32
  • 48

1 Answers1

1

If you are running AppJS then you can do the screen detection using tricks in javascript running in the chromium window part of AppJS. I quick google search found the following link, I am sure there are others and if you experiment enough then hopefully you will get a cross platform solution:-

http://archive.cpradio.org/code/javascript/dual-monitors-and-windowopen/

An alternative approach if you want to stay node-native is to implement a common api and then implement separate code behind that for each platform. I don't personally know of any better solution at the moment, and obviously this is less preferable to the javascript solution above. However if you must go this route then there is node edge:

http://tjanczuk.github.io/edge

This lets you run .net code from nodejs so you should be able to cover windows machines with that api. For linux you could then look into connecting into dbus:

https://github.com/sidorares/node-dbus https://npmjs.org/package/dbus-native

Hopefully you can find appropriate sample code on the internet to get display properties using dbus and .net and then just plug it together and go from there.

sihorton
  • 416
  • 2
  • 3