diff --git a/index.js b/index.js index ad8284f..4d2ff38 100644 --- a/index.js +++ b/index.js @@ -78,6 +78,7 @@ const utilsCmd = { // security risk but for now not accepting user input so safe 'listprototypes': { cmd: 'ls', context: {cwd: propath}, format: res => res.toString().split('\n') }, + 'mousemove' : { cmd: 'xdotool mousemove ', optionsPattern: /\d+ \d+/}, // per device specific (until adjustable per user) 'minimizeall' : { cmd: kwinmin}, //KWin script //'minimizeall' : { cmd: '/home/fabien/Prototypes/kwin-scripting/launch'}, //KWin script @@ -95,6 +96,7 @@ const utilsCmd = { // security risk but for now not accepting user input so safe // could be interesting to consider also recent containers and ~/.bashrc for services const instructions = ` +
 /home/deck/.ssh/
 	trusted context, i.e on closed WiFi and over https with bearer authorization
 /home/deck/.ssh/config
@@ -116,6 +118,7 @@ ssh remarkable2 to get drawing preview
 util functions
 	modify WiFi parameters, including AP if available
 	shutdown/reboot
+
` const auth_instructions = `generate md5 from pub offline-octopus then provide as bearer query param` @@ -217,8 +220,8 @@ app.get('/exec', (req, res) => { } }) -function execConfiguredCommand(cmdName){ - let resultFromExecution = execSync(utilsCmd[cmdName].cmd, utilsCmd[cmdName].context) +function execConfiguredCommand(cmdName, options=''){ + let resultFromExecution = execSync(utilsCmd[cmdName].cmd+options, utilsCmd[cmdName].context) let formatter = utilsCmd[cmdName].format if (formatter) resultFromExecution = formatter(resultFromExecution) return resultFromExecution @@ -264,7 +267,7 @@ let dynURL = '/' app.get('/hmdlink/set', (req, res) => { // could be a PUT instead // e.g http://192.168.4.3:8082/hmdlink/set?url=http://192.168.4.3:8082/114df5f8-3921-42f0-81e7-48731b563571.thumbnails/f07120ba-0ca1-429d-869f-c704a52b7aa3.png // should return a warning if req.query.url is undefined - if (!oeq.query.url) {res.json( {error: 'use /hmdlink/set?url=YOURURL'}); return} + if (!req.query.url) {res.json( {error: 'use /hmdlink/set?url=YOURURL'}); return} dynURL = req.query.url res.redirect( dynURL ) }) @@ -409,6 +412,10 @@ function getSshConfig(){ easier to revoke if need be */ +app.get('/mousemove', (req, res) => { + if( !req.query.options?.match(utilsCmd['mousemove']) ) { {res.json( {error: 'use /mousemove/set?options=100 2000'}); return}} + res.json( execConfiguredCommand('mousemove',req.query.options) ) } +) app.get('/minimizeall', (req, res) => { res.json( execConfiguredCommand('minimizeall') ) }) app.get('/resolution/high', (req, res) => { res.json( execConfiguredCommand('highresscreen') ) }) app.get('/resolution/low', (req, res) => { res.json( execConfiguredCommand('lowresscreen') ) })