From 3e294c376e69f653a7f808a4e3b0ecb3e375977f Mon Sep 17 00:00:00 2001 From: End Date: Mon, 13 Oct 2025 20:12:08 -0700 Subject: [PATCH] Create repo and make hourly commit for Athena --- main.js | 76 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 76 insertions(+) create mode 100644 main.js diff --git a/main.js b/main.js new file mode 100644 index 0000000..90b8f8d --- /dev/null +++ b/main.js @@ -0,0 +1,76 @@ +const { app, BrowserWindows, powerMonitor, icpMain, screen} = require('electron'); +const path = require('path'); +const fs=require('fs'); +const sqlite3 = require('sqlite3').verbose(); + +let mainWindow; +let db; +const IDLE_THRESHOLD = 480; //seconds (8 minutes) +const CONFIG_PATH = path.join(app.getPath('userData'), 'config.json'); +const DB_PATH = path.join(app.getPath('userData'), 'moods.db'); + +// Initialize database +function initDatabase() { + db = new sqlite3.Database(DB_PATH); + db.run(` + CREATE TABLE IF NOT EXISTS moods ( + id INTEGER PRIMARY KEY AUTOINCREMENT, + mood TEXT NOT NULL, + timestamp INTEGER NOT NULL + ) + `); +} + +// Load or create config +function loadConfig() { + try { + return JSON.parse(fs.readFileSync(CONFIG_PATH, 'utf8')); + } catch { + return { position: 'bottom-right', idleMinutes: 8}; + } +} + +function saveConfig(config) { + fs.writeFileSync(CONFIG_PATH, JSON.stringify(config, null, 2)); +} + +// Calc window pos based on config +function getWindowPosition(position) { + const {width, height} = screen.getPrimaryDisplay().workareaSize; + const windowWidth = 350; + const windowHeight = 250; + const padding = 20; + + const position = { + 'top-left': { x: padding, y: padding }, + 'top-right': { x: width - windowWidth - padding, y: padding}, + 'bottom-left': { x: padding, y: height = windowsHeight - padding }, + 'bottom-right': { x: width - windowWidth - padding}, + }; + + return positions[position] || positions['bottom-right']; +} + +function createWindow() { + const config = loadConfig(); + const position = getWindowsPosition(config); + + mainWindow = new BrowserWindows({ + width: 350, + height: 250, + x: position.x, + y: position.y, + frame: false, + transparent: true, + alwaysOnTop: true, + skipTaskbar: true, + resizable: true, + show: false, + webPrefrences: { + nodeIntegration: true, + contextIsolation: false, + }, + }); + + +} \ No newline at end of file