Make xdotool optional.

develop
Icedream Jenkins 2015-11-02 12:18:36 +01:00
parent 82c19a2196
commit f650c3296b
2 changed files with 21 additions and 5 deletions

View File

@ -2,7 +2,9 @@ which = require("which").sync
path = require "path"
log = require("./logger")("RequireBin")
module.exports = (binName) =>
module.exports = (binName, doErrorIfNotFound) =>
doErrorIfNotFound = true unless doErrorIfNotFound?
# check if xvfb is findable from here
if path.resolve(binName) == path.normalize(binName)
# this is an absolute path
@ -14,5 +16,9 @@ module.exports = (binName) =>
log.debug "#{binName} detected:", binPath
return binPath
catch err
log.error "#{binName} could not be found.", err
throw new Error "#{binName} could not be found."
if doErrorIfNotFound
log.error "#{binName} could not be found."
throw new Error "#{binName} could not be found."
else
log.warn "#{binName} could not be found."
return null

View File

@ -6,13 +6,18 @@ services = require("./services")
StreamSplitter = require("stream-splitter")
require_bin = require("./require_bin")
xdotoolBinPath = require_bin "xdotool"
xdotoolBinPath = require_bin "xdotool", false
# Just some tools to work with the X11 windows
module.exports =
getWindowIdByProcessId: (pid, cb) =>
wid = null
# Return null instantly if xdotool is not available
if not xdotoolBinPath?
cb? new Error "xdotool is not available"
return
# We provide --name due to the bug mentioned at https://github.com/jordansissel/xdotool/issues/14
xdoproc = spawn xdotoolBinPath, [ "search", "--any", "--pid", pid, "--name", "xdosearch" ],
env:
@ -43,6 +48,11 @@ module.exports =
getWindowIdByProcessIdSync: (pid) => Sync() => @getWindowIdByProcessId.sync @, pid
sendKeys: (wid, keys, cb) =>
# Do not bother trying if xdotool is not available
if not xdotoolBinPath?
cb? new Error "xdotool not available."
return
# blackbox needs to be running for windowactivate to work
blackboxService = services.find("BlackBox")
if blackboxService.state != "started"