| 
          var app = require('app');  // Module to control application life. | 
        
        
           | 
          var BrowserWindow = require('browser-window');  // Module to create native browser window. | 
        
        
           | 
          var x11 = require('x11'); | 
        
        
           | 
          var x11_prop = require('x11-prop'); | 
        
        
           | 
          // Report crashes to our server. | 
        
        
           | 
          //require('crash-reporter').start(); | 
        
        
           | 
          
 | 
        
        
           | 
          // Keep a global reference of the window object, if you don't, the window will | 
        
        
           | 
          // be closed automatically when the JavaScript object is garbage collected. | 
        
        
           | 
          var mainWindow = null; | 
        
        
           | 
          
 | 
        
        
           | 
          
 | 
        
        
           | 
          // This method will be called when Electron has finished | 
        
        
           | 
          // initialization and is ready to create browser windows. | 
        
        
           | 
          app.on('ready', function() { | 
        
        
           | 
              var screen = require('screen'); | 
        
        
           | 
              var size = screen.getPrimaryDisplay().workAreaSize; | 
        
        
           | 
              console.log(screen.getAllDisplays()); | 
        
        
           | 
              // Create the browser window. | 
        
        
           | 
              mainWindow = new BrowserWindow({ | 
        
        
           | 
                  width: size.width, height: size.height - 20, type: 'desktop', frame: false, x: 0, y: 20, | 
        
        
           | 
                  resizable: false | 
        
        
           | 
              }); | 
        
        
           | 
          
 | 
        
        
           | 
              // and load the index.html of the app. | 
        
        
           | 
              mainWindow.loadUrl('file://' + __dirname + '/index.html'); | 
        
        
           | 
          
 | 
        
        
           | 
              // Open the DevTools. | 
        
        
           | 
              mainWindow.webContents.openDevTools(); | 
        
        
           | 
          
 | 
        
        
           | 
              // Emitted when the window is closed. | 
        
        
           | 
              mainWindow.on('closed', function() { | 
        
        
           | 
                  mainWindow = null; | 
        
        
           | 
              }); | 
        
        
           | 
              mainWindow.setVisibleOnAllWorkspaces(true); | 
        
        
           | 
              console.log(mainWindow.id, process.pid); | 
        
        
           | 
              setTimeout(scan_windows, 100); | 
        
        
           | 
          }); | 
        
        
           | 
          
 | 
        
        
           | 
          function for_all_windows(X, root, fn) { | 
        
        
           | 
              X.QueryTree(root, function(err, tree) { | 
        
        
           | 
                  tree.children.forEach(function(wid) { | 
        
        
           | 
                      fn(wid); | 
        
        
           | 
                      for_all_windows(X, wid, fn); | 
        
        
           | 
                  }); | 
        
        
           | 
              }); | 
        
        
           | 
          } | 
        
        
           | 
          function scan_windows() { | 
        
        
           | 
              x11.createClient(function(err, display) { | 
        
        
           | 
                  X = display.client; | 
        
        
           | 
                  root = display.screen[0].root; | 
        
        
           | 
          
 | 
        
        
           | 
                  X.InternAtom(false, "_NET_WM_WINDOW_TYPE_DESKTOP", function(err, _NET_WM_WINDOW_TYPE_DESKTOP) { | 
        
        
           | 
          
 | 
        
        
           | 
          
 | 
        
        
           | 
                      for_all_windows(X, root, function(wid) { | 
        
        
           | 
                          x11_prop.get_property(X, wid, "_NET_WM_PID", 'CARDINAL', function(err, data) { | 
        
        
           | 
                              if (data == process.pid) { | 
        
        
           | 
                                  x11_prop.get_property(X, wid, "_NET_WM_WINDOW_TYPE", 'ATOM', function(err, data) { | 
        
        
           | 
                                      if (!err) { | 
        
        
           | 
                                          if (data.some(function(x) { return x == _NET_WM_WINDOW_TYPE_DESKTOP; })) { | 
        
        
           | 
                                              console.log("FOUND", wid) | 
        
        
           | 
                                              set_state(X, wid); | 
        
        
           | 
                                          } | 
        
        
           | 
                                          console.log(wid, '_NET_WM_WINDOW_TYPE: ' + data); | 
        
        
           | 
                                      } | 
        
        
           | 
                                  }); | 
        
        
           | 
          
 | 
        
        
           | 
                                  if (!err) { | 
        
        
           | 
                                      console.log(wid, '_NET_WM_PID: ' + data); | 
        
        
           | 
                                  } | 
        
        
           | 
                              } | 
        
        
           | 
                          }); | 
        
        
           | 
                      }); | 
        
        
           | 
                  }); | 
        
        
           | 
          }); | 
        
        
           | 
          } | 
        
        
           | 
          function set_state(X, wid) { | 
        
        
           | 
              X.LowerWindow(wid); | 
        
        
           | 
          } |