settings: refactor settings store

read-only: pass flag with index.html response
theme: clean & remove old themes
This commit is contained in:
bordun 2020-03-20 12:57:47 +01:00
parent a6b82a4c93
commit a588fb2b4a
23 changed files with 203 additions and 418 deletions

View file

@ -21,21 +21,12 @@ module.exports = {
ipc.send('sessionList', recentSessions, clientId)
ipc.send('clipboard', clipboard, clientId)
if (settings.read('readOnly')) {
ipc.send('readOnly')
}
if (data.backupId && sessionBackups[data.backupId]) {
ipc.send('loadBackup', sessionBackups[data.backupId])
return
}
if (settings.read('newSession')) {
ipc.send('sessionNew')
return
}
if (settings.read('sessionFile')) return this.sessionOpen({path:settings.read('sessionFile')},clientId)
if (settings.read('load')) return this.sessionOpen({path:settings.read('load')},clientId)
if (settings.read('examples')) {
@ -44,7 +35,7 @@ module.exports = {
recentSessions = recentSessions.map(function(file){return dir + '/' + file})
}
ipc.send('serverTargets', settings.read('targets'), clientId)
ipc.send('serverTargets', settings.read('send'), clientId)
},
@ -64,12 +55,12 @@ module.exports = {
return index == self.indexOf(elem)
})
recentSessions = recentSessions.reverse()
// history size limit
if (recentSessions.length > 10) recentSessions = recentSessions.slice(0, 10)
// save history
settings.write('recentSessions',recentSessions)
settings.write('recentSessions', recentSessions)
ipc.send('sessionList', recentSessions)
@ -91,7 +82,7 @@ module.exports = {
if (Array.isArray(data.path)) data.path = path.resolve(...data.path)
if (!settings.read('readOnly')) {
if (!settings.read('read-only')) {
module.exports.sessionAddToHistory(data.path)
}
@ -118,7 +109,7 @@ module.exports = {
if (Array.isArray(data.path)) data.path = path.resolve(...data.path)
if (settings.read('stateFile')) {
if (settings.read('state')) {
var send = true
for (var id in ipc.clients) {
// only make the client send its osc state if there are no other active clients
@ -127,7 +118,7 @@ module.exports = {
}
}
var state = {
state: settings.read('stateFile'),
state: settings.read('state'),
send: send
}
ipc.send('stateLoad', state, clientId)
@ -170,7 +161,7 @@ module.exports = {
if (!ok) return
if (!data.path || settings.read('remoteSaving') && !settings.read('remoteSaving').test(ipc.clients[clientId].address)) {
if (!data.path || settings.read('remote-saving') && !settings.read('remote-saving').test(ipc.clients[clientId].address)) {
return ipc.send('notify', {
icon: 'save',
@ -184,7 +175,7 @@ module.exports = {
if (Array.isArray(data.path)) data.path = path.resolve(...data.path)
var root = settings.read('remoteRoot')
var root = settings.read('remote-root')
if (root && !data.path.includes(root)) {
console.error('(ERROR) Could not save: path outside of remote-root')
return ipc.send('notify', {
@ -312,7 +303,7 @@ module.exports = {
var targets = []
if (data.target.indexOf(null) === -1 && settings.read('targets') && !shortdata.target) Array.prototype.push.apply(targets, settings.read('targets'))
if (data.target.indexOf(null) === -1 && settings.read('send') && !shortdata.target) Array.prototype.push.apply(targets, settings.read('send'))
if (data.target) Array.prototype.push.apply(targets, data.target)
data.args = data.preArgs ? data.preArgs.concat(value) : [value]
@ -436,7 +427,7 @@ module.exports = {
if (data.path) p = path.resolve(...data.path)
var root = settings.read('remoteRoot')
var root = settings.read('remote-root')
if (root && !p.includes(root)) p = root
fs.readdir(p, (err, files)=>{

View file

@ -6,16 +6,16 @@ app.setPath('userData', settings.configPath)
app.commandLine.appendSwitch('--touch-events')
if (settings.read('noVsync') || (!settings.cli && settings.read('argv')['disable-vsync'])) {
if (settings.read('disable-vsync')) {
app.commandLine.appendSwitch('--disable-gpu-vsync')
}
if (settings.read('noGpu') || (!settings.cli && settings.read('argv')['disable-gpu'])) {
if (settings.read('disable-gpu')) {
app.disableHardwareAcceleration()
app._noGpu = true
}
if (settings.read('forceGpu') || (!settings.cli && settings.read('argv')['force-gpu'])) {
if (settings.read('force-gpu')) {
app.commandLine.appendSwitch('--ignore-gpu-blacklist')
}
@ -36,7 +36,7 @@ var template = [{
if (process.platform === 'darwin') {
// Add app menu (macOs)
template.unshift({
label: settings.read('appName'),
label: settings.infos.appName,
submenu: [
{
label: 'Hide ' + infos.productName,

View file

@ -14,7 +14,7 @@ module.exports = function(options={}) {
window = new BrowserWindow({
width: options.width || screenSize.width,
height: options.height || screenSize.height,
title: options.title || settings.read('appName'),
title: options.title || settings.infos.appName,
icon: path.resolve(__dirname + '/../assets/logo.png'),
backgroundColor: options.color || theme.backgroundColor,
type: options.type,

View file

@ -9,9 +9,9 @@ function nodeMode() {
console.warn('(INFO) Running with node')
if (!settings.read('noGui')) {
if (!settings.read('no-gui')) {
settings.cli = true
settings.write('noGui', true, true)
settings.write('no-gui', true, true)
console.warn('(INFO) Headless mode (--no-gui) enabled automatically')
}
@ -66,10 +66,10 @@ function start() {
function openClient() {
var app = require('./electron-app')
var address = settings.read('appAddresses')[0]
var address = settings.appAddresses()[0]
var launch = ()=>{
var win = require('./electron-window')({address:address, shortcuts:true, fullscreen: settings.read('fullScreen')})
var win = require('./electron-window')({address:address, shortcuts:true, fullscreen: settings.read('fullscreen')})
win.on('error', ()=>{
console.log('ERR')
})
@ -89,7 +89,7 @@ function openClient() {
if (settings.cli) {
start()
if (!settings.read('noGui')) openClient()
if (!settings.read('no-gui')) openClient()
} else {
@ -142,18 +142,19 @@ if (settings.cli) {
ipcMain.on('start',function(e, options){
var args = ['--no-gui']
for (var k in settings.read('argv')) {
for (var k in settings.read('options')) {
args.push('--' + k)
var val = settings.read('argv')[k]
var val = settings.read(k)
if (typeof val === 'object') {
args = args.concat(val)
} else if (typeof val !== 'boolean') {
args.push(val)
}
}
global.serverProcess = spawn(process.argv[0], process.argv.slice(1).concat(args), {stdio: 'pipe'/*, env: {"ELECTRON_RUN_AS_NODE":"1"}*/})
if (!settings.read('noGui')) {
if (!settings.read('no-gui')) {
global.serverProcess.stdout.once('data', (data) => {
global.clientWindows.push(openClient())
})

View file

@ -1,54 +1,83 @@
var fs = require('fs')
module.exports = {
's':{alias:'send',type:'array',describe:'default targets for all widgets (ip:port / domain:port / midi:port_name pairs)',
's': {alias: 'send', type: 'array', describe: 'default targets for all widgets (ip: port / domain: port / midi: port_name pairs)',
check: (s)=>{
return s.some(item=>!item.match(/^[^:]*:[0-9]{4,5}$/) && !item.match(/^midi:.*$/)) ?
'Targets must be ip:port or domain:port pairs (udp / tcp port must be >= 1024) or midi:port_name pairs' : true
return s.some(item=>!item.match(/^[^: ]*: [0-9]{4, 5}$/) && !item.match(/^midi: .*$/)) ?
'Targets must be ip: port or domain: port pairs (udp / tcp port must be >= 1024) or midi: port_name pairs' : true
}
},
'l':{alias:'load',type:'string',file:{name:'OSC Session (.json)', extensions: ['json', 'js']},describe:'session file to load'},
'state':{type:'string',file:{name:'OSC State (.state)', extensions: ['state']},describe:'state file to load'},
'c':{alias:'custom-module',type:'array',file:{name:'OSC Custom module (.js)', extensions: ['js']},describe:'custom module file to load (custom options can be passed after the filename)'},
'p':{alias:'port',type:'number',describe:'http port of the server (default to 8080)',
'l': {alias: 'load', type: 'string', file: {name: 'OSC Session (.json)', extensions: ['json', 'js']}, describe: 'session file to load',
check: (arg)=>{
return fs.lstatSync(arg) ? true : 'Session file not found: ' + arg
},
coerce: (arg)=>{
return JSON.parse(fs.readFileSync(arg, 'utf8'))
}
},
'state': {type: 'string', file: {name: 'OSC State (.state)', extensions: ['state']}, describe: 'state file to load',
check: (arg)=>{
return fs.lstatSync(arg) ? true : 'State file not found: ' + arg
},
coerce: (arg)=>{
return JSON.parse(fs.readFileSync(arg, 'utf8'))
}
},
'c': {alias: 'custom-module', type: 'array', file: {name: 'OSC Custom module (.js)', extensions: ['js']}, describe: 'custom module file to load (custom options can be passed after the filename)',
check: (arg)=>{
return fs.lstatSync(arg) ? true : 'Custom module file not found: ' + arg
},
},
'p': {alias: 'port', type: 'number', describe: 'http port of the server (default to 8080)',
check: (p)=>{
return (!isNaN(p) && p > 1023 && parseInt(p)===p) ?
true : 'Port must be an integer >= 1024'
}
},
'o':{alias:'osc-port',type:'number',describe:'osc input port (default to --port)',
'o': {alias: 'osc-port', type: 'number', describe: 'osc input port (default to --port)',
check: (o)=>{
return (!isNaN(o) && o > 1023 && parseInt(o)===o) ?
true : 'Port must be an integer >= 1024'
}
},
'tcp-port':{type:'number', describe:'tcp server input port',
'tcp-port': {type: 'number', describe: 'tcp server input port',
check: (t, argv)=>{
var h = argv['port'] || 8080
if (t===h) return 'tcp input port must different from --port'
var h = argv['port']
if (t === h) return 'Tcp input port must different from --port'
return (!isNaN(t) && t > 1023 && parseInt(t)===t) ?
true : 'Port must be an integer >= 1024'
}
},
'tcp-targets':{type:'array',describe:'tcp servers to connect to (ip:port pairs), does not susbtitute for --send',
'tcp-targets': {type: 'array', describe: 'tcp servers to connect to (ip: port pairs), does not susbtitute for --send',
check: (s, argv)=>{
if (!argv['tcp-port']) return '--tcp-port must be set'
return s.some(item=>!item.match('^[^:\s\"\']*:[0-9]{4,5}[\s\"\']*$')) ?
'Targets must be ip:port pairs & port must be >= 1024' : true
return s.some(item=>!item.match('^[^: \s\"\']*: [0-9]{4, 5}[\s\"\']*$')) ?
'Targets must be ip: port pairs & port must be >= 1024' : true
}
},
'm':{alias:'midi',type:'array',describe:'midi router settings'},
'd':{alias:'debug',type:'boolean',describe:'log received osc messages in the console'},
'n':{alias:'no-gui',type:'boolean',describe:'disable default gui'},
't':{alias:'theme',type:'array',describe:'theme name or path (mutliple values allowed)'},
'client-options':{type:'array',describe:'client options (opt=value pairs)',
'm': {alias: 'midi', type: 'array', describe: 'midi router settings'},
'd': {alias: 'debug', type: 'boolean', describe: 'log received osc messages in the console'},
'n': {alias: 'no-gui', type: 'boolean', describe: 'disable default gui'},
't': {alias: 'theme', type: 'array', describe: 'theme name or path (mutliple values allowed)'},
'client-options': {type: 'array', describe: 'client options (opt=value pairs)',
check: (o)=>{
return o.some(item=>!item.match(/^[^=]*=[^=]*$/)) ?
'Options must be key=value pairs' : true
},
coerce: (arg)=>{
var opts = {}
for (var o of arg) {
if (!o.includes('=')) continue
var [k, v] = o.split('=')
opts[k] = v
}
return opts
}
},
'disable-vsync':{type:'boolean',describe:'disable gui\'s vertical synchronization', restart: true},
'force-gpu':{type:'boolean',describe:'ignore chrome\'s gpu blacklist', restart: true},
'read-only':{type:'boolean',describe:'disable session editing and session history changes'},
'remote-saving':{type:'string',describe:'disable remote session saving for hosts that don\'t match the regular expresion',
'disable-vsync': {type: 'boolean', describe: 'disable gui\'s vertical synchronization', restart: true},
'force-gpu': {type: 'boolean', describe: 'ignore chrome\'s gpu blacklist', restart: true},
'read-only': {type: 'boolean', describe: 'disable session editing and session history changes'},
'remote-saving': {type: 'string', describe: 'disable remote session saving for hosts that don\'t match the regular expresion',
check: (r, argv)=>{
var msg = true
try {
@ -57,15 +86,16 @@ module.exports = {
msg = e
}
return msg
}
},
coerce: arg=>RegExp(arg)
},
'remote-root':{type:'string', describe:'set remote file browsing root folder', file:{folder: true}},
'instance-name':{type:'string',describe:'used to differenciate multiple instances in a zeroconf network'},
'fullscreen':{type:'boolean', describe:'launch in fullscreen mode (only affects the default client gui)'},
'remote-root': {type: 'string', describe: 'set remote file browsing root folder', file: {folder: true}},
'instance-name': {type: 'string', describe: 'used to differenciate multiple instances in a zeroconf network'},
'fullscreen': {type: 'boolean', describe: 'launch in fullscreen mode (only affects the default client gui)'},
// cli only
'disable-gpu':{type:'boolean',describe:'disable hardware acceleration', launcher: false},
'inspect':{type:'boolean', describe:'enable node/electron inspector', launcher: false},
'cache-dir':{type:'string', describe:'override default cache directory', launcher: false},
'config-file':{type:'string', describe:'override default config file (defaults to cache-dir/config.json)', launcher: false}
'disable-gpu': {type: 'boolean', describe: 'disable hardware acceleration', launcher: false},
'inspect': {type: 'boolean', describe: 'enable node/electron inspector', launcher: false},
'cache-dir': {type: 'string', describe: 'override default cache directory', launcher: false},
'config-file': {type: 'string', describe: 'override default config file (defaults to cache-dir/config.json)', launcher: false}
}

View file

@ -1,7 +1,7 @@
var path = require('path'),
ipc = require('../server').ipc,
settings = require('../settings'),
tcpInPort = settings.read('tcpInPort'),
tcpInPort = settings.read('tcp-port'),
debug = settings.read('debug'),
vm = require('vm'),
fs = require('fs'),
@ -20,7 +20,7 @@ class OscServer {
this.customModuleEventEmitter = new EventEmitter()
this.customModule = (()=>{
var customModule = settings.read('customModule')
var customModule = settings.read('custom-module')
if (!customModule) return false
// consolidate path containing whitespaces
@ -257,7 +257,7 @@ class OscServer {
oscUDPServer.on('message', this.oscInHandlerWrapper.bind(this))
oscUDPServer.open()
if (settings.read('tcpInPort')) {
if (settings.read('tcp-port')) {
oscTCPServer.on('message', this.oscInHandlerWrapper.bind(this))
oscTCPServer.open()
}

View file

@ -2,8 +2,8 @@ var osc = require('./osc'),
EventEmitter = require('events').EventEmitter,
settings = require('../settings'),
zeroconf = require('../zeroconf'),
tcpInPort = settings.read('tcpInPort'),
tcpTargets = settings.read('tcpTargets'),
tcpInPort = settings.read('tcp-port'),
tcpTargets = settings.read('tcp-targets'),
net = require('net')
class OscTCPClient extends EventEmitter {
@ -129,7 +129,7 @@ class OscTCPServer extends EventEmitter {
}
zeroconf.publish({
name: settings.read('appName') + (settings.read('instanceName') ? ' (' + settings.read('instanceName') + ')' : ''),
name: settings.infos.appName + (settings.read('instance-name') ? ' (' + settings.read('instance-name') + ')' : ''),
protocol: 'tcp',
type: 'osc',
port: tcpInPort

View file

@ -1,7 +1,7 @@
var osc = require('./osc'),
settings = require('../settings'),
zeroconf = require('../zeroconf'),
oscInPort = settings.read('oscInPort') || settings.read('httpPort')
oscInPort = settings.read('osc-port') || settings.read('port') || 8080
var oscUDPServer = new osc.UDPPort({
localAddress: '0.0.0.0',
@ -19,7 +19,7 @@ oscUDPServer.on('error', function(e) {
})
zeroconf.publish({
name: settings.read('appName') + (settings.read('instanceName') ? ' (' + settings.read('instanceName') + ')' : ''),
name: settings.infos.appName + (settings.read('instance-name') ? ' (' + settings.read('instance-name') + ')' : ''),
protocol: 'udp',
type: 'osc',
port: oscInPort

View file

@ -10,7 +10,7 @@ var urlparser = require('url'),
settings = require('./settings'),
theme = require('./theme').init(),
zeroconf = require('./zeroconf'),
appAddresses = settings.read('appAddresses'),
appAddresses = settings.appAddresses(),
osc = {},
clients = {},
httpCheckTimeout
@ -28,7 +28,11 @@ function httpRoute(req, res) {
if (url === '/' || url.indexOf('/?') === 0) {
fs.createReadStream(path.resolve(__dirname + '/../client/index.html'))
.pipe(replaceStream('</body>', `<script>window.ENV=${JSON.stringify(settings.read('clientOptions'))}</script></body>`))
.pipe(replaceStream('</body>', `
<script>
window.ENV=${JSON.stringify(settings.read('client-options'))}
window.READ_ONLY=${JSON.stringify(settings.read('read-only'))}
</script></body>`))
.pipe(res);
// res.sendFile(path.resolve(__dirname + '/../client/index.html'))
@ -89,9 +93,9 @@ server.on('error', (e)=>{
}
})
server.listen(settings.read('httpPort'))
server.listen(settings.read('port') || 8080)
http.get(settings.read('appAddresses')[0] + '/osc-ping', ()=>{}).on('error', ()=>{httpCheck(false)})
http.get(settings.appAddresses()[0] + '/osc-ping', ()=>{}).on('error', ()=>{httpCheck(false)})
httpCheckTimeout = setTimeout(()=>{httpCheck(false)}, 5000)
function httpCheck(ok){
if (!httpCheckTimeout) return
@ -105,9 +109,9 @@ function httpCheck(ok){
}
zeroconf.publish({
name: settings.read('appName') + (settings.read('instanceName') ? ' (' + settings.read('instanceName') + ')' : ''),
name: settings.infos.appName + (settings.read('instanceName') ? ' (' + settings.read('instanceName') + ')' : ''),
type: 'http',
port: settings.read('httpPort')
port: settings.read('port') || 8080
}).on('error', (e)=>{
console.error(`(ERROR, ZEROCONF) ${e.message}`)
})

View file

@ -1,3 +1,15 @@
var path = require('path'),
fs = require('fs'),
ifaces = require('os').networkInterfaces(),
yargs = require('yargs'),
infos = require('../package.json'),
options = require('./options')
var appAddresses = Object.values(ifaces)
.reduce((a,b)=>a.concat(b), [])
.filter(i=>i.family === 'IPv4')
.map(i=>'http://' + i.address + ':')
// This prevents argv parsing to be breaked when the app is packaged (executed without 'electron' prefix)
if (process.argv[1] && process.argv[1].indexOf('-') == 0) process.argv.unshift('')
@ -7,11 +19,7 @@ if (process.argv[1] && process.argv[1].indexOf('-') == 0) process.argv.unshift('
// it must be stripped to let yargs work normally
if (process.argv[2] == '--') process.argv.splice(2, 1)
var infos = require('../package.json')
var options = require('./options'),
argv = require('yargs')
var argv = yargs
.parserConfiguration({'boolean-negation': false})
.help('help').usage('\nUsage:\n $0 [options]').alias('h', 'help')
.options(options)
@ -40,78 +48,45 @@ argv = argv.argv
delete argv._
delete argv.$0
// are we in a terminal ?
var cli = false,
ignored = ['_', '$0', 'no-sandbox', 'noSandbox', 'cache-dir', 'cacheDir', 'config-file', 'configFile', 'disable-gpu', 'disableGpu', 'inspect']
// clean argv
var optNames = [],
cliOnly = []
for (i in argv) {
if (!ignored.includes(i) && (argv[i]!=undefined && argv[i]!==false)) cli = true
}
var fs = require('fs'),
ifaces = require('os').networkInterfaces()
var defaultConfig,
makeDefaultConfig = function(argv){
defaultConfig = {
argv:argv,
recentSessions: [],
appName: infos.productName,
instanceName: argv['instance-name'] || false,
targets: argv['send'] || false,
oscInPort: argv['osc-port'] || 0,
httpPort: argv['port'] || 8080,
tcpInPort: argv['tcp-port'] || false,
tcpTargets: argv['tcp-targets'] || [],
debug: argv['debug'] || false,
sessionFile: argv['load'] || false,
newSession: argv['blank'] || false,
customModule: argv['custom-module'] || false,
fullScreen: argv['fullscreen'] || false,
noGui: argv['no-gui'] || false,
guiOnly: typeof argv['gui-only'] == 'string' ? argv['gui-only'].length ? argv['gui-only'] : true : false,
clientOptions: argv['client-options'] ? (function(){
var opts = {}
for (var o of argv['client-options']) {
if (!o.includes('=')) continue
var [k, v] = o.split('=')
opts[k] = v
}
return opts
})() : false,
noVsync: argv['disable-vsync'] || false,
noGpu: argv['disable-gpu'] || false,
forceGpu: argv['force-gpu'] || false,
readOnly: argv['read-only'] || false,
remoteSaving: argv['remote-saving'] ? RegExp(argv['remote-saving']) : false,
remoteRoot: argv['remote-root'] || false,
midi: argv['midi'],
stateFile: (function(){
if (!argv['state']) return false
try {
return JSON.parse(fs.readFileSync(argv['state'], 'utf8'))
} catch(err) {
console.error(err)
return false
}
})(),
appAddresses: Object.values(ifaces)
.reduce((a,b)=>a.concat(b), [])
.filter(i=>i.family === 'IPv4')
.map(i=>'http://' + i.address + ':' + (argv['port'] || 8080)),
examples: argv['examples'],
theme: argv['theme'] || [],
checkForUpdates: true
for (var k in options) {
var name = options[k].alias || k
optNames.push(name)
if (options[k].launcher === false) {
cliOnly.push(name)
}
}
makeDefaultConfig(argv)
for (var i in argv) {
if (argv[i] === false || !optNames.includes(i)) {
delete argv[i]
}
}
delete argv._
delete argv.$0
// are we in a terminal ?
var cli = false
for (i in argv) {
if (!cliOnly.includes(i)) cli = true
}
var settings = {
options: argv,
recentSessions: [],
checkForUpdates: true
}
var path = require('path'),
baseDir, configPath, configPathExists = true
///////////////// config paths
var baseDir, configPath, configPathExists = true
if (argv['cache-dir']) {
baseDir = path.isAbsolute(argv['cache-dir']) ? argv['cache-dir'] : path.resolve(process.cwd(), argv['cache-dir'])
@ -142,34 +117,52 @@ if (configPathExists) {
} else {
configPath = path.join(baseDir, 'config.json')
}
configFile = function(){try {return JSON.parse(fs.readFileSync(configPath,'utf-8'))} catch(err) {return {}}}()
config = JSON.parse(JSON.stringify(configFile))
try {
config = JSON.parse(fs.readFileSync(configPath,'utf-8'))
} catch(e) {}
if (cli) {
for (var k in config) {
if (k === 'options') continue
settings[k] = config[k]
}
} else {
for (var k in config) {
settings[k] = config[k]
}
}
}
if (!configPath) {
console.warn('(WARNING) Config directory not found, settings and session history will not be saved.')
}
/////////////////
module.exports = {
argv: argv,
options: options,
makeDefaultConfig: makeDefaultConfig,
read: function(key){
var x = config[key] !== undefined ? config[key] : defaultConfig[key]
return x
return settings.options[key] !== undefined ? settings.options[key] : settings[key]
},
write:function(key,value,tmp) {
write:function(key, value, tmp) {
config[key] = value
if (tmp || !configPathExists) return
settings[key] = value
configFile[key] = value
if (!tmp && configPathExists) {
config[key] = value
fs.writeFile(configPath, JSON.stringify(config, null, 4), function(err, data) {
if (err) throw err
})
}
fs.writeFile(configPath, JSON.stringify(configFile, null, 4), function(err, data) {
if (err) throw err
})
},
cli: cli,
configPath: baseDir,
infos: infos,
appAddresses: ()=>{
return appAddresses.map(x=>x + (settings.options.port || 8080))
}
}

View file

@ -17,7 +17,7 @@ class Theme {
init() {
this.themes = settings.read('theme')
this.themes = settings.read('theme') || []
this.files = []
for (let theme of this.themes) {
@ -53,8 +53,8 @@ class Theme {
var css = this.get()
if (css.includes('--color-bg:')) {
this.backgroundColor = css.match(/--color-bg:([^;]*);/)[1].trim()
if (css.includes('--color-background:')) {
this.backgroundColor = css.match(/--color-background:([^;]*);/)[1].trim()
} else {
this.backgroundColor = this.defaultColor
}