Skip to content

Commit a253891

Browse files
committed
autostart tests
1 parent 6679017 commit a253891

File tree

3 files changed

+38
-18
lines changed

3 files changed

+38
-18
lines changed

extensions_main/autostart.js

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
const { app } = require('electron');
2+
const fs = require('fs');
3+
const path = require('../lib/path2');
4+
5+
// Sample Module. Plase copy-paste this file into new module's main folder
6+
class Autostarter extends require('../lib/BaseModule')
7+
{
8+
// unspecified: loads data.json
9+
// MODULE_NAME = "autostarter";
10+
11+
setup()
12+
{
13+
this.log("setting autostart to", this.__conf.autostart == true);
14+
app.on('ready', () => {
15+
app.setLoginItemSettings({
16+
openAtLogin: (this.__conf.autostart == true), // autostart at login
17+
openAsHidden: false, // can hide window if desired
18+
});
19+
});
20+
21+
let filel = null;
22+
const logfile = path.joinAppData("lel.txt");
23+
if (fs.existsSync(logfile))
24+
filel = fs.readFileSync(logfile)
25+
else
26+
filel = ""
27+
filel = filel + "\ntried to open at " + Date.now().toString();
28+
fs.writeFileSync(logfile, filel);
29+
}
30+
}
31+
32+
module.exports = Autostarter;

lib/BaseModule.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,12 @@ class BaseModule
1919
this.window = window;
2020
this.tab = tab;
2121
this.module_name = this.MODULE_NAME || 'BaseModule';
22-
this.conf_file_path = path.joinConfigDir(this.module_name + '.json');
22+
23+
if (this.module_name == 'BaseModule')
24+
this.conf_file_path = path.joinConfigDir('data.json');
25+
else
26+
this.conf_file_path = path.joinConfigDir(this.module_name + '.json');
27+
2328
try { this.__conf = JSON.parse(fs.readFileSync(this.conf_file_path, 'utf-8')); }
2429
catch (e) { console.log('Could not load conf file for', this.module_name, ':', e, '.'); }
2530

package-lock.json

Lines changed: 0 additions & 17 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)