mirror of
https://github.com/smartfrigde/armcord.git
synced 2024-08-14 23:56:58 +00:00
Add a Tray Icon
This commit is contained in:
parent
cd56cfa8eb
commit
1c55ed7335
4 changed files with 45 additions and 113 deletions
48
main.js
48
main.js
|
@ -1,15 +1,15 @@
|
||||||
// Modules to control application life and create native browser window
|
// Modules to control application life and create native browser window
|
||||||
const { app, BrowserWindow, session } = require('electron')
|
const { app, BrowserWindow, session, Tray, Menu } = require('electron')
|
||||||
const path = require('path')
|
const path = require('path')
|
||||||
require("v8-compile-cache");
|
require("v8-compile-cache");
|
||||||
require("./utils/updater");
|
require("./utils/updater");
|
||||||
let mainWindow
|
let mainWindow
|
||||||
require("./menu.js")
|
|
||||||
function createWindow() {
|
function createWindow() {
|
||||||
mainWindow = new BrowserWindow({
|
mainWindow = new BrowserWindow({
|
||||||
width: 800,
|
width: 800,
|
||||||
height: 600,
|
height: 600,
|
||||||
icon: __dirname + '/discord.ico',
|
icon: __dirname + "/discord.ico",
|
||||||
|
title: "ArmCord",
|
||||||
frame: false,
|
frame: false,
|
||||||
webPreferences: {
|
webPreferences: {
|
||||||
preload: path.join(__dirname, "preload.js"),
|
preload: path.join(__dirname, "preload.js"),
|
||||||
|
@ -17,21 +17,59 @@ function createWindow() {
|
||||||
nodeIntegration: false,
|
nodeIntegration: false,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
var appIcon = new Tray(__dirname + "/discord.ico");
|
||||||
mainWindow.webContents.userAgent =
|
mainWindow.webContents.userAgent =
|
||||||
"Mozilla/5.0 (X12; TempleOS MIPS) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3729.169 Safari/537.36"; //to set
|
"Mozilla/5.0 (X12; FreeBSD x86) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3729.169 Safari/537.36"; //fake useragent
|
||||||
mainWindow.loadFile("index.html");
|
mainWindow.loadFile("index.html");
|
||||||
|
mainWindow.focus();
|
||||||
mainWindow.webContents.on("new-window", function (e, url) {
|
mainWindow.webContents.on("new-window", function (e, url) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
require("electron").shell.openExternal(url);
|
require("electron").shell.openExternal(url);
|
||||||
});
|
});
|
||||||
// Open the DevTools.
|
// Open the DevTools.
|
||||||
// mainWindow.webContents.openDevTools()
|
// mainWindow.webContents.openDevTools()
|
||||||
|
var contextMenu = Menu.buildFromTemplate([
|
||||||
|
{
|
||||||
|
label: "Show App",
|
||||||
|
click: function () {
|
||||||
|
mainWindow.show();
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: "Support Discord Server",
|
||||||
|
click: function () {
|
||||||
|
mainWindow.loadURL("https://discord.gg/F25bc4RYDt");
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: "Quit",
|
||||||
|
click: function () {
|
||||||
|
app.isQuiting = true;
|
||||||
|
app.quit();
|
||||||
|
},
|
||||||
|
},
|
||||||
|
]);
|
||||||
|
|
||||||
mainWindow.on("closed", () => {
|
appIcon.setContextMenu(contextMenu);
|
||||||
|
|
||||||
|
// Emitted when the window is closed.
|
||||||
|
mainWindow.on("close", function (event) {
|
||||||
mainWindow = null;
|
mainWindow = null;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
mainWindow.on("minimize", function (event) {
|
||||||
|
event.preventDefault();
|
||||||
|
mainWindow.hide();
|
||||||
|
});
|
||||||
|
|
||||||
|
mainWindow.on("show", function () {
|
||||||
|
appIcon.setHighlightMode("always");
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// This method will be called when Electron has finished
|
// This method will be called when Electron has finished
|
||||||
// initialization and is ready to create browser windows.
|
// initialization and is ready to create browser windows.
|
||||||
// Some APIs can only be used after this event occurs.
|
// Some APIs can only be used after this event occurs.
|
||||||
|
|
107
menu.js
107
menu.js
|
@ -1,107 +0,0 @@
|
||||||
const { app, Menu } = require("electron");
|
|
||||||
|
|
||||||
const isMac = process.platform === "darwin";
|
|
||||||
|
|
||||||
const template = [
|
|
||||||
// { role: 'appMenu' }
|
|
||||||
...(isMac
|
|
||||||
? [
|
|
||||||
{
|
|
||||||
label: app.name,
|
|
||||||
submenu: [
|
|
||||||
{ role: "about" },
|
|
||||||
{ type: "separator" },
|
|
||||||
{ role: "services" },
|
|
||||||
{ type: "separator" },
|
|
||||||
{ role: "hide" },
|
|
||||||
{ role: "hideothers" },
|
|
||||||
{ role: "unhide" },
|
|
||||||
{ type: "separator" },
|
|
||||||
{ role: "quit" },
|
|
||||||
],
|
|
||||||
},
|
|
||||||
]
|
|
||||||
: []),
|
|
||||||
// { role: 'fileMenu' }
|
|
||||||
{
|
|
||||||
label: "File",
|
|
||||||
submenu: [isMac ? { role: "close" } : { role: "quit" }],
|
|
||||||
},
|
|
||||||
// { role: 'editMenu' }
|
|
||||||
{
|
|
||||||
label: "Edit",
|
|
||||||
submenu: [
|
|
||||||
{ role: "undo" },
|
|
||||||
{ role: "redo" },
|
|
||||||
{ type: "separator" },
|
|
||||||
{ role: "cut" },
|
|
||||||
{ role: "copy" },
|
|
||||||
{ role: "paste" },
|
|
||||||
...(isMac
|
|
||||||
? [
|
|
||||||
{ role: "pasteAndMatchStyle" },
|
|
||||||
{ role: "delete" },
|
|
||||||
{ role: "selectAll" },
|
|
||||||
{ type: "separator" },
|
|
||||||
{
|
|
||||||
label: "Speech",
|
|
||||||
submenu: [{ role: "startSpeaking" }, { role: "stopSpeaking" }],
|
|
||||||
},
|
|
||||||
]
|
|
||||||
: [{ role: "delete" }, { type: "separator" }, { role: "selectAll" }]),
|
|
||||||
],
|
|
||||||
},
|
|
||||||
// { role: 'viewMenu' }
|
|
||||||
{
|
|
||||||
label: "View",
|
|
||||||
submenu: [
|
|
||||||
{ role: "reload" },
|
|
||||||
{ role: "forceReload" },
|
|
||||||
{ role: "toggleDevTools" },
|
|
||||||
{ type: "separator" },
|
|
||||||
{ role: "resetZoom" },
|
|
||||||
{ role: "zoomIn" },
|
|
||||||
{ role: "zoomOut" },
|
|
||||||
{ type: "separator" },
|
|
||||||
{ role: "togglefullscreen" },
|
|
||||||
],
|
|
||||||
},
|
|
||||||
// { role: 'windowMenu' }
|
|
||||||
{
|
|
||||||
label: "Window",
|
|
||||||
submenu: [
|
|
||||||
{ role: "minimize" },
|
|
||||||
{ role: "zoom" },
|
|
||||||
...(isMac
|
|
||||||
? [
|
|
||||||
{ type: "separator" },
|
|
||||||
{ role: "front" },
|
|
||||||
{ type: "separator" },
|
|
||||||
{ role: "window" },
|
|
||||||
]
|
|
||||||
: [{ role: "close" }]),
|
|
||||||
],
|
|
||||||
},
|
|
||||||
{
|
|
||||||
role: "help",
|
|
||||||
submenu: [
|
|
||||||
{
|
|
||||||
label: "Learn More",
|
|
||||||
click: async () => {
|
|
||||||
const { shell } = require("electron");
|
|
||||||
await shell.openExternal("https://github.com/smartfrigde/armcord");
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
label: "Support Server",
|
|
||||||
click: async () => {
|
|
||||||
const { shell } = require("electron");
|
|
||||||
await shell.openExternal("https://discord.gg/F25bc4RYDt");
|
|
||||||
},
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
|
||||||
];
|
|
||||||
|
|
||||||
const menu = Menu.buildFromTemplate(template);
|
|
||||||
Menu.setApplicationMenu(menu);
|
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "armcord",
|
"name": "armcord",
|
||||||
"version": "2.2.0",
|
"version": "2.3.0",
|
||||||
"description": "ArmCord is a Discord client made for ARM Linux that allows you to customize your experience.",
|
"description": "ArmCord is a Discord client made for ARM Linux that allows you to customize your experience.",
|
||||||
"main": "main.js",
|
"main": "main.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
|
|
@ -5,6 +5,7 @@ const { remote } = require("electron");
|
||||||
window.addEventListener('DOMContentLoaded', () => {
|
window.addEventListener('DOMContentLoaded', () => {
|
||||||
new customTitlebar.Titlebar({
|
new customTitlebar.Titlebar({
|
||||||
backgroundColor: customTitlebar.Color.fromHex("#202225"),
|
backgroundColor: customTitlebar.Color.fromHex("#202225"),
|
||||||
|
menu: false,
|
||||||
});
|
});
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in a new issue