rkeys
Advanced tools
Comparing version 0.8.2 to 0.9.0
@@ -15,2 +15,3 @@ // Generated by LiveScript 1.3.0 | ||
C.option('-v, --verbosity <level>', "verbosity 0=min 2=max (default:" + VERBOSITY + ")", VERBOSITY); | ||
C.allowUnknownOption(); | ||
C.parse(process.argv); | ||
@@ -17,0 +18,0 @@ C.dirs = C.args.length ? C.args : APPS; |
// Generated by LiveScript 1.3.0 | ||
(function(){ | ||
var _, Io, Cmd, Actw, Fc, Rks, Sc, split$ = ''.split; | ||
var _, Io, Awin, D, Rkey, Rks; | ||
_ = require('lodash'); | ||
Io = require('socket.io'); | ||
Cmd = require('./command'); | ||
Actw = require('./x11/active-window'); | ||
Fc = require('./filter-chain'); | ||
Awin = require('./x11/active-window'); | ||
D = require('./rkey/constants').directions; | ||
Rkey = require('./rkey'); | ||
Rks = require('./rkeystrokes'); | ||
Sc = require('./side-chain'); | ||
module.exports.init = function(http){ | ||
module.exports = function(http){ | ||
var io; | ||
Actw.on('changed', function(){ | ||
return io.emit('active-window-changed', Actw.title); | ||
Awin.on('changed', function(){ | ||
return io.emit('active-window-changed', Awin.title); | ||
}); | ||
@@ -24,45 +23,11 @@ return (io = Io(http)).on('connection', function(socket){ | ||
x$.on('rkeydown', function(it){ | ||
return applyFilters(0, it); | ||
return Rkey(it, D.DOWN, io); | ||
}); | ||
x$.on('rkeyup', function(it){ | ||
return applyFilters(1, it); | ||
return Rkey(it, D.UP, io); | ||
}); | ||
x$.on('rkeystrokes', Rks); | ||
Actw.emit('changed'); | ||
function applyFilters(direction, act){ | ||
var ref$, id, command; | ||
ref$ = parseAct(act), id = ref$[0], command = ref$[1]; | ||
Sc(direction, id, command, io, act); | ||
return Fc(direction, id, command, io); | ||
} | ||
function parseAct(act){ | ||
var ref$, id, pStr, cmd, pArr; | ||
ref$ = act === ':' | ||
? [':', ''] | ||
: split$.call(act, ':'), id = ref$[0], pStr = ref$[1]; | ||
cmd = Cmd.getCommand(id); | ||
if (!(pStr != null && pStr.length)) { | ||
return [id, cmd]; | ||
} | ||
pArr = split$.call(pStr, ','); | ||
if (!_.isArray(cmd)) { | ||
return [id, replaceParams(cmd, pArr)]; | ||
} | ||
return [id, [replaceParams(cmd[0], pArr), replaceParams(cmd[1], pArr)]]; | ||
} | ||
function replaceParams(s, pArr){ | ||
var i$, len$, i, p; | ||
if (!_.isString(s)) { | ||
return s; | ||
} | ||
for (i$ = 0, len$ = pArr.length; i$ < len$; ++i$) { | ||
i = i$; | ||
p = pArr[i$]; | ||
s = s.replace("$" + i, p); | ||
} | ||
return s; | ||
} | ||
return replaceParams; | ||
return Awin.emit('changed'); | ||
}); | ||
}; | ||
}).call(this); |
// Generated by LiveScript 1.3.0 | ||
(function(){ | ||
var Evem, X11, Root, X, me, ref$; | ||
var Evem, X11, Root, X, me; | ||
Evem = require('events').EventEmitter; | ||
@@ -8,42 +8,50 @@ X11 = require('x11'); | ||
X = require('./helper').x; | ||
module.exports = me = (ref$ = clone$(new Evem()), ref$.title = '', ref$); | ||
X.InternAtom(false, '_NET_ACTIVE_WINDOW', function(err, atom){ | ||
if (err) { | ||
return log("X.InternAtom _NET_ACTIVE_WINDOW failed", err); | ||
} | ||
X.ChangeWindowAttributes(Root, { | ||
eventMask: X11.eventMask.PropertyChange | ||
}); | ||
X.on('event', function(it){ | ||
if (it.atom !== X.atoms._NET_ACTIVE_WINDOW) { | ||
module.exports = me = import$(clone$(new Evem()), { | ||
init: function(){ | ||
return X.InternAtom(false, '_NET_ACTIVE_WINDOW', function(err, atom){ | ||
if (err) { | ||
return log("X.InternAtom _NET_ACTIVE_WINDOW failed", err); | ||
} | ||
X.ChangeWindowAttributes(Root, { | ||
eventMask: X11.eventMask.PropertyChange | ||
}); | ||
X.on('event', function(it){ | ||
if (it.atom !== X.atoms._NET_ACTIVE_WINDOW) { | ||
return; | ||
} | ||
return readActiveWindowTitle(function(){ | ||
return me.emit('changed'); | ||
}); | ||
}); | ||
return readActiveWindowTitle(); | ||
}); | ||
}, | ||
title: '' | ||
}); | ||
function readActiveWindowTitle(cb){ | ||
return X.GetProperty(0, Root, X.atoms._NET_ACTIVE_WINDOW, 0, 0, 10000000, function(err, p){ | ||
var wid; | ||
if (err) { | ||
return log("X.GetProperty _NET_ACTIVE_WINDOW failed", err); | ||
} | ||
if (!(wid = p.data.readUInt32LE(0))) { | ||
return; | ||
} | ||
return readActiveWindowTitle(function(){ | ||
return me.emit('changed'); | ||
}); | ||
}); | ||
readActiveWindowTitle(); | ||
function readActiveWindowTitle(cb){ | ||
return X.GetProperty(0, Root, X.atoms._NET_ACTIVE_WINDOW, 0, 0, 10000000, function(err, p){ | ||
var wid; | ||
return X.GetProperty(0, wid, X.atoms.WM_NAME, 0, 0, 10000000, function(err, p){ | ||
if (err) { | ||
return log("X.GetProperty _NET_ACTIVE_WINDOW failed", err); | ||
return log("X.GetProperty WM_NAME failed: wid=" + wid, err); | ||
} | ||
if (!(wid = p.data.readUInt32LE(0))) { | ||
return; | ||
me.title = p.data.toString(); | ||
log(2, "read-active-window-title=" + me.title); | ||
if (cb) { | ||
return cb(); | ||
} | ||
return X.GetProperty(0, wid, X.atoms.WM_NAME, 0, 0, 10000000, function(err, p){ | ||
if (err) { | ||
return log("X.GetProperty WM_NAME failed: wid=" + wid, err); | ||
} | ||
me.title = p.data.toString(); | ||
log(2, "read-active-window-title=" + me.title); | ||
if (cb) { | ||
return cb(); | ||
} | ||
}); | ||
}); | ||
} | ||
return readActiveWindowTitle; | ||
}); | ||
}); | ||
} | ||
function import$(obj, src){ | ||
var own = {}.hasOwnProperty; | ||
for (var key in src) if (own.call(src, key)) obj[key] = src[key]; | ||
return obj; | ||
} | ||
function clone$(it){ | ||
@@ -50,0 +58,0 @@ function fun(){} fun.prototype = it; |
// Generated by LiveScript 1.3.0 | ||
(function(){ | ||
var X11, W4m, display, root, x, xtest, i$, ref$, len$, sig; | ||
var X11, W4m, me, i$, ref$, len$, sig; | ||
X11 = require('x11'); | ||
W4m = require('wait.for').forMethod; | ||
display = W4m(X11, 'createClient'); | ||
root = display.screen[0].root; | ||
x = display.client.on('error', function(it){ | ||
return log('error', it); | ||
}); | ||
xtest = W4m(x, 'require', 'xtest'); | ||
module.exports = { | ||
display: display, | ||
root: root, | ||
x: x, | ||
xtest: xtest | ||
module.exports = me = { | ||
init: function(){ | ||
me.display = W4m(X11, 'createClient'); | ||
me.root = me.display.screen[0].root; | ||
me.x = me.display.client.on('error', function(it){ | ||
return log('error', it); | ||
}); | ||
return me.xtest = W4m(me.x, 'require', 'xtest'); | ||
} | ||
}; | ||
@@ -18,0 +16,0 @@ for (i$ = 0, len$ = (ref$ = ['SIGINT', 'SIGHUP', 'SIGTERM']).length; i$ < len$; ++i$) { |
// Generated by LiveScript 1.3.0 | ||
(function(){ | ||
var _, W4m, X11, H, ks2kc; | ||
var _, W4m, X11, H, PREFIX, ks2kc, me; | ||
_ = require('lodash'); | ||
@@ -8,4 +8,10 @@ W4m = require('wait.for').forMethod; | ||
H = require('./helper'); | ||
ks2kc = getKeysymToKeycodeMapping(); | ||
module.exports = { | ||
PREFIX = 'XK_'; | ||
module.exports = me = { | ||
init: function(){ | ||
return ks2kc = getKeysymToKeycodeMapping(); | ||
}, | ||
isKeysym: function(it){ | ||
return _.isString(it) && it.substring(0, PREFIX.length) === PREFIX; | ||
}, | ||
getKeycodes: function(key){ | ||
@@ -24,8 +30,7 @@ var keysym, kc; | ||
function getKeysym(key){ | ||
var PREFIX; | ||
PREFIX = 'XK_'; | ||
if (key.substring(0, PREFIX.length) === PREFIX) { | ||
if (me.isKeysym(key)) { | ||
return key; | ||
} else { | ||
return PREFIX + "" + key; | ||
} | ||
return PREFIX + "" + key; | ||
} | ||
@@ -32,0 +37,0 @@ function getKeysymToKeycodeMapping(){ |
{ | ||
"name": "rkeys", | ||
"version": "0.8.2", | ||
"version": "0.9.0", | ||
"description": "A platform for creating tablet/HTML5 virtual-keyboard apps to send keystrokes to remote X11", | ||
@@ -49,10 +49,14 @@ "keywords": [ | ||
"wait.for": "0.6.3", | ||
"x11": "1.0.3" | ||
"x11": "1.0.3", | ||
"moment": "2.10.3" | ||
}, | ||
"devDependencies": { | ||
"chai": "~3.0.0", | ||
"chalk": "~0.4.0", | ||
"chokidar": "~1.0.1", | ||
"cron": "~1.0.3", | ||
"gntp": "~0.1.1" | ||
"gntp": "~0.1.1", | ||
"lolex": "~1.2.1", | ||
"mocha": "~2.2.5" | ||
} | ||
} |
@@ -59,2 +59,3 @@ ## rkeys | ||
a [chord] denoted by infix `+` symbols, | ||
a comma-delimited sequence of keysyms and/or chords, | ||
or a [command id](#command.yaml) with optional parameters. | ||
@@ -86,2 +87,3 @@ The label text is displayed inside the key unless it contains [font awesome] | ||
on touchstart, followed by KeyRelease sequence in the same order on touchend. | ||
Specify `S+` for **Shift_L**+, `C+` for **Control_L**+ and `A+` for **Alt_L**+. | ||
Press and hold for native auto-repeat. | ||
@@ -93,2 +95,15 @@ * `+key('C+S+A+F12 fold all')`: | ||
and an icon. | ||
* <a name="sequences"></a>`+key('a,b,3')`: | ||
emit the keystroke sequence `a` `b` `3` on touchstart with no auto-repeat. | ||
A keystroke is a KeyPress immediately followed by a KeyRelease. | ||
* `+key('a,b,3,1000')`: | ||
as above but auto-repeating every second until touchend. | ||
Integers `0` to `9` denote digits whereas longer integers denote time | ||
delay in milliseconds. Here the trailing delay indicates time to auto-repeat. | ||
* `+key('a,500,b,500,3,1000')`: | ||
as above but with interim pauses of 0.5 seconds. | ||
This might be necessary if a sequence is firing too quickly for all keystrokes | ||
to take effect, for example if a slow application needs more time to react. | ||
* `+key('C+A+F3,05,Super_L+a fa-gear')`: | ||
emit two chords separated by a 5 millisecond delay. | ||
* `+key('button:3')`: | ||
@@ -103,3 +118,4 @@ invoke the [button](#button) command with parameter `3` | ||
* `+key('layout:fn-keys')`: | ||
switch the [layout](#layout) to `fn-keys` across all connected clients. | ||
switch the [layout](#layout) to `fn-keys` across all connected clients on | ||
touchstart, reverting back to the default layout on touchend. | ||
@@ -154,4 +170,4 @@ ### +keys mixin | ||
otherwise. Applying this class to a key allows it to remain **down** | ||
even when you're not touching it, by dragging your finger off the key | ||
before you release it. Then simply tap the key to unlatch it. | ||
even when you're not touching it, by dragging your finger sideways away from | ||
the key before releasing it. Then simply tap the key to unlatch it. | ||
A latchable `shift` key behaves rather like CapsLock on a traditional keyboard. | ||
@@ -187,32 +203,6 @@ | ||
You can get more fancy than single-keys and chords by defining commands | ||
You can get more fancy by defining commands | ||
in a [yaml] file (typically `command.yaml`) placed in the app's directory. | ||
Each definition has format `id: command` where `id` is a unique identifier | ||
and `command` is a string specifying what to do. | ||
### <a name="sequences"></a>keystroke sequences | ||
To define a sequence of keystrokes simply list them in order separated by spaces. | ||
Sometimes a sequence might fire too quickly for all keystrokes to take effect, | ||
for example if a slow application needs time to react. | ||
The solution is to introduce a short pause between keystrokes, specified in milliseconds. | ||
Examples: | ||
* `abc: a b c`: | ||
emit the keystroke sequence `a` `b` `c` on rkeydown with no auto-repeat. | ||
* `abc-slow: a 500 b 500 c`: | ||
as above but with interim pauses of 0.5 seconds. | ||
* `abc-repeat: a b c 1000`: | ||
emit the keystroke sequence `a` `b` `c` on rkeydown, repeating | ||
every second until rkeyup. | ||
* `abc-repeat-slow: a 500 b 500 c 1000`: | ||
as above but with interim pauses of 0.5 seconds. | ||
* `HelloWorld: [ H e l l o, +Shift_L w -Shift_L o r l d ]`: | ||
emit the keystroke sequence `H` `e` `l` `l` `o` on rkeydown and | ||
`W` `o` `r` `l` `d` on rkeyup. | ||
Explicit Keypress/KeyRelease events are denoted by prefixes `+` and `-` respectively. | ||
### directives | ||
The first word of a command can specify a **directive** to alter the functionality: | ||
@@ -233,2 +223,7 @@ | ||
execute shell command *cmd* on rkeydown. | ||
* *id*: **javascript** *script* : | ||
dynamically generate a command at runtime using [JavaScript]. | ||
The *script* must evaluate to an action or command string. | ||
* *id*: **livescript** *script* : | ||
As above but using [LiveScript]. | ||
* *id*: **nop** : | ||
@@ -239,2 +234,13 @@ no-operation. Useful as a placeholder to be redefined at runtime. | ||
* `abc: a b c`: | ||
A sequence can be delimited by spaces or commas. | ||
* `on: +c -d`: | ||
emit KeyPress `c` and KeyRelease `d` on rkeydown. | ||
Explicit KeyPress/KeyRelease events are denoted by prefixes `+` and `-` respectively. | ||
* `HelloWorld: [H e l l o, +Shift_L w -Shift_L o r l d]`: | ||
emit the keystroke sequence `H` `e` `l` `l` `o` on rkeydown and | ||
`W` `o` `r` `l` `d` on rkeyup. | ||
The square-bracket array has format | ||
**[** *rkeydown-sequence*, *rkeyup-sequence* **]**, | ||
where each sequence is delimited by spaces. | ||
* <a name="VBOX-HOST"></a>`VBOX-HOST: alias Super_R`: | ||
@@ -252,2 +258,6 @@ define an alias for the [VirtualBox] host key. | ||
pause the [Simon] speech recognition engine. | ||
* `type: javascript '$0'.split('').join(',')`: | ||
Convert a string into a sequence of keystrokes and emit them. | ||
* `now: livescript (require \moment)!format 'DD/MM/YYYY_HH:mm:ss' .split '' .join ','`: | ||
Type the current date and time. | ||
@@ -268,3 +278,3 @@ ### overriding default configuration at runtime | ||
and is the best way to add low-latency server-side sound effects. | ||
Whenever a keydown or keyup occurs the command-id is checked against | ||
Whenever a rkeydown or rkeyup occurs the command-id is checked against | ||
a sequence of `/regular-expression/: command` rules and only | ||
@@ -330,2 +340,3 @@ the first matching rule will run. Here's an example: | ||
[jade]: http://jade-lang.com | ||
[JavaScript]: https://en.wikipedia.org/wiki/JavaScript | ||
[jquery]: http://jquery.com | ||
@@ -332,0 +343,0 @@ [keysym]: https://github.com/sidorares/node-x11/blob/master/lib/keysyms.js |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Debug access
Supply chain riskUses debug, reflection and dynamic code execution features.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
1497552
61
21540
349
18
7
4
+ Addedmoment@2.10.3
+ Addedmoment@2.10.3(transitive)