From 6cb7a8c8c884dfc5fed74b075350df797b756164 Mon Sep 17 00:00:00 2001 From: Utopiah Date: Mon, 23 Oct 2023 10:05:47 +0200 Subject: [PATCH] res change example --- index.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/index.js b/index.js index d2d0cce..b980638 100644 --- a/index.js +++ b/index.js @@ -10,7 +10,8 @@ const express = require("express"); // could be good to replace with c // Get port or default to 8082 const port = process.env.PORT || 8082; const protocol = process.env.PROTOCOL || 'https' -const subclass = process.env.SUBCLASS || '192.168.4.' +const subclass = process.env.SUBCLASS || '192.168.0.' // defaulting to IP used at home rather than RPi0. Could also change it there as it's not justified beside helping distinction. +// Object.values(require("os").networkInterfaces()).flat().filter(({ family, internal }) => family === "IPv4" && !internal).map(({ address }) => address)[0].split('.').slice(0,3).join('.')+'.' const publicKeyPath = path.resolve(process.env.HOME,'.ssh','id_rsa_offlineoctopus.pub') const publicKey = fs.readFileSync(publicKeyPath).toString().split(' ')[1] @@ -66,6 +67,10 @@ 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') }, + // per device specific (until adjustable per user) + 'highresscreen' : { cmd: 'xrandr --output DP-4 --mode 3840x2160'}, + 'lowresscreen' : { cmd: 'xrandr --output DP-4 --mode 1920x1080'}, + //'npmfind' : { desc: 'package manager finder', cmd: 'find . -wholename "*node_modules/acorn"' }, // security risk if relying on user provided name, e.g replacing acorn by user input // example that could be generalized to other package managers e.g .deb or opkg @@ -372,6 +377,9 @@ function getSshConfig(){ easier to revoke if need be */ +app.get('/resolution/high', (req, res) => { res.json( execConfiguredCommand('highresscreen') ) }) +app.get('/resolution/low', (req, res) => { res.json( execConfiguredCommand('lowresscreen') ) }) + app.get('/localprototypes', (req, res) => { // examples to disentangle own work for cloned existing repositories : // find Prototypes/ -iwholename */.git/config | xargs grep git.benetou.fr