diff --git a/package.json b/package.json index 7cf62ff..7e93487 100644 --- a/package.json +++ b/package.json @@ -5,7 +5,7 @@ "main": "./build/main.js", "scripts": { "build": "mkdir -p build && copyfiles -u 1 \"src/titlebar/**/*\" \"build\" && tsc -p .", - "run": "electron27 build/main.js", + "run": "electron build/main.js", "postbuild": "copyfiles -u 1 \"src/assets/**/*\" \"build\"", "make-app": "npm run build && npm run postbuild && npm run run", "clean": "rm -r build/", diff --git a/src/app.ts b/src/app.ts index 5449fa4..87b2d32 100644 --- a/src/app.ts +++ b/src/app.ts @@ -8,9 +8,10 @@ import * as fs from "fs"; import * as os from "os"; const titlebarIsEnabled = getConfig().titlebar +const hiddeOnClose = getConfig().hiddeOnClose Menu.setApplicationMenu(null); -if(titlebarIsEnabled) { +if (titlebarIsEnabled) { setupTitlebar(); } @@ -29,9 +30,8 @@ export class MainApp { */ constructor(app: Electron.App) { this.app = app; - this.userAgent = `Mozilla/5.0 (X11; ${ - os.type - } ${os.arch()}) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/112.0.0.0 Safari/537.36`; + this.userAgent = `Mozilla/5.0 (X11; ${os.type + } ${os.arch()}) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/112.0.0.0 Safari/537.36`; this.icons = { main: path.join(__dirname, "assets/icons/main.png"), tray: path.join(__dirname, "assets/icons/tray.png"), @@ -94,7 +94,7 @@ export class MainApp { }); this.win.webContents.setUserAgent(this.userAgent); this.win.loadURL("https://discord.com/app"); - if(titlebarIsEnabled) { + if (titlebarIsEnabled) { attachTitlebarToWindow(this.win); } } @@ -104,10 +104,12 @@ export class MainApp { */ private windowEvents() { // hide window - this.win.on("close", (event: Event) => { - event.preventDefault(); - this.win.hide(); - }); + if (hiddeOnClose) { + this.win.on("close", (event: Event) => { + event.preventDefault(); + this.win.hide(); + }); + } // Open links in the browser. this.win.webContents.setWindowOpenHandler( diff --git a/src/assets/web/html/settings.html b/src/assets/web/html/settings.html index ad04283..d64a8ce 100644 --- a/src/assets/web/html/settings.html +++ b/src/assets/web/html/settings.html @@ -1,264 +1,272 @@ - - - - - - - - - - DiscordBSD Settings - - - - -
- -
- - -
- - -
-
- - -
- - Apply -

you have to restart to see the changes

-
-
- - - - - - - - - - /* Input for color picker */ - .color-picker-input { - width: 50px; - } - diff --git a/src/settings.ts b/src/settings.ts index e011c8a..eb088d4 100644 --- a/src/settings.ts +++ b/src/settings.ts @@ -1,12 +1,13 @@ -import {BrowserWindow, ipcMain} from "electron"; +import { BrowserWindow, ipcMain } from "electron"; import * as fs from "fs"; import * as path from "path"; export const configPath = - path.join(require("os").homedir(), ".config", "DiscordBSD"); + path.join(require("os").homedir(), ".config", "DiscordBSD"); export const filePath = path.join(configPath, "config.json"); export interface ConfigData { + hiddeOnClose: boolean; titlebar: boolean; titlebarcolor: string; } @@ -40,7 +41,7 @@ export class DiscordSettings { // Event handler for setting configuration data ipcMain.on("set-config", - (_event, config: ConfigData) => { setConfig(config); }); + (_event, config: ConfigData) => { setConfig(config); }); // Event handler for getting configuration data ipcMain.handle("get-config", (_event) => { @@ -51,13 +52,13 @@ export class DiscordSettings { private createWindow() { this.win = new BrowserWindow({ - title : "DiscordBSD Settings", - width : 640, - height : 480, - alwaysOnTop : true, - webPreferences : { - sandbox : false, - preload : path.join(__dirname, "preload/settingspl.js"), + title: "DiscordBSD Settings", + width: 640, + height: 480, + alwaysOnTop: true, + webPreferences: { + sandbox: false, + preload: path.join(__dirname, "preload/settingspl.js"), }, }); @@ -117,7 +118,7 @@ export const setConfig = (data: ConfigData) => { * Get configuration data for DiscordBSD from the specified file path. * @returns Configuration data if successful, otherwise null. */ -export const getConfig = (): ConfigData|null => { +export const getConfig = (): ConfigData | null => { initializeConfig() try { // Read the JSON data from the configuration file @@ -139,8 +140,9 @@ export const initializeConfig = () => { if (!fs.existsSync(filePath)) { const initialData: ConfigData = { - titlebar : false, - titlebarcolor : "#6538b9", + hiddeOnClose: true, + titlebar: false, + titlebarcolor: "#6538b9", }; setConfig(initialData); }