fix: improve Linux tray robustness by using system pixmaps and adding libappindicator dependency
This commit is contained in:
2
PKGBUILD
2
PKGBUILD
@@ -6,7 +6,7 @@ pkgdesc="Professional Steam Account Manager & Ban Tracker"
|
|||||||
arch=('x86_64')
|
arch=('x86_64')
|
||||||
url="https://narl.io"
|
url="https://narl.io"
|
||||||
license=('custom:Personal Use and Non-Commercial')
|
license=('custom:Personal Use and Non-Commercial')
|
||||||
depends=('electron' 'nodejs' 'npm' 'libxss' 'nss' 'libxtst')
|
depends=('electron' 'nodejs' 'npm' 'libxss' 'nss' 'libxtst' 'libappindicator-gtk3')
|
||||||
makedepends=('imagemagick')
|
makedepends=('imagemagick')
|
||||||
source=("ultimate-ban-tracker-${pkgver}.tar.gz::https://git.narl.io/nvrl/ultimate-ban-tracker/archive/v${pkgver}.tar.gz")
|
source=("ultimate-ban-tracker-${pkgver}.tar.gz::https://git.narl.io/nvrl/ultimate-ban-tracker/archive/v${pkgver}.tar.gz")
|
||||||
sha256sums=('SKIP')
|
sha256sums=('SKIP')
|
||||||
|
|||||||
@@ -93,40 +93,23 @@ const initBackend = () => {
|
|||||||
|
|
||||||
// --- System Tray ---
|
// --- System Tray ---
|
||||||
const createTray = () => {
|
const createTray = () => {
|
||||||
// Try to find the icon in various standard locations
|
|
||||||
const possiblePaths = [
|
const possiblePaths = [
|
||||||
path.join(__dirname, '..', 'assets-build'), // Dev
|
'/usr/share/pixmaps/ultimate-ban-tracker.png', // System installed (highest priority)
|
||||||
path.join(process.resourcesPath, 'assets-build'), // Packaged (External)
|
path.join(__dirname, '..', 'assets-build', 'icon.png'),
|
||||||
path.join(app.getAppPath(), 'dist', 'assets-build'), // Packaged (Internal dist)
|
path.join(__dirname, '..', 'assets-build', 'icon.svg'),
|
||||||
path.join(app.getAppPath(), 'assets-build') // Packaged (Internal root)
|
path.join(process.resourcesPath, 'assets-build', 'icon.png'),
|
||||||
|
path.join(app.getAppPath(), 'assets-build', 'icon.png')
|
||||||
];
|
];
|
||||||
|
|
||||||
let assetsDir = '';
|
|
||||||
for (const p of possiblePaths) {
|
|
||||||
if (fs.existsSync(p)) {
|
|
||||||
assetsDir = p;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const possibleIcons = ['icon.png', 'icon.svg'];
|
|
||||||
let iconPath = '';
|
let iconPath = '';
|
||||||
|
for (const p of possiblePaths) {
|
||||||
if (assetsDir) {
|
if (fs.existsSync(p)) { iconPath = p; break; }
|
||||||
for (const name of possibleIcons) {
|
|
||||||
const fullPath = path.join(assetsDir, name);
|
|
||||||
if (fs.existsSync(fullPath)) {
|
|
||||||
iconPath = fullPath;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log(`[Tray] Resolved assets directory: ${assetsDir || 'NOT FOUND'}`);
|
console.log(`[Tray] Resolved icon path: ${iconPath || 'NONE FOUND'}`);
|
||||||
console.log(`[Tray] Attempting to initialize with icon: ${iconPath || 'NONE FOUND'}`);
|
|
||||||
|
|
||||||
if (!iconPath) {
|
if (!iconPath) {
|
||||||
console.warn(`[Tray] FAILED: No valid icon found in searched paths.`);
|
console.warn(`[Tray] FAILED: No valid icon found.`);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -134,22 +117,34 @@ const createTray = () => {
|
|||||||
const icon = nativeImage.createFromPath(iconPath).resize({ width: 16, height: 16 });
|
const icon = nativeImage.createFromPath(iconPath).resize({ width: 16, height: 16 });
|
||||||
tray = new Tray(icon);
|
tray = new Tray(icon);
|
||||||
tray.setToolTip('Ultimate Ban Tracker');
|
tray.setToolTip('Ultimate Ban Tracker');
|
||||||
|
|
||||||
|
// Linux Fix: Some DEs need this to show the menu correctly
|
||||||
|
if (process.platform === 'linux') {
|
||||||
|
tray.setIgnoreMouseEvents(false);
|
||||||
|
}
|
||||||
|
|
||||||
tray.on('click', () => { if (mainWindow) { mainWindow.show(); mainWindow.focus(); } });
|
tray.on('click', () => { if (mainWindow) { mainWindow.show(); mainWindow.focus(); } });
|
||||||
|
|
||||||
// Load initial themed icon
|
// Load initial themed icon if possible
|
||||||
const config = store.get('serverConfig');
|
const config = store.get('serverConfig');
|
||||||
if (config?.theme) {
|
if (config?.theme) {
|
||||||
setAppIcon(config.theme);
|
setAppIcon(config.theme);
|
||||||
} else {
|
} else {
|
||||||
updateTrayMenu(); // Fallback to refresh menu
|
updateTrayMenu();
|
||||||
|
}
|
||||||
|
console.log(`[Tray] Successfully initialized`);
|
||||||
|
} catch (e: any) {
|
||||||
|
console.error(`[Tray] Error: ${e.message}`);
|
||||||
}
|
}
|
||||||
} catch (e) { }
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const updateTrayMenu = () => {
|
const updateTrayMenu = () => {
|
||||||
if (!tray) return;
|
if (!tray) return;
|
||||||
const accounts = store.get('accounts') as Account[];
|
const accounts = store.get('accounts') as Account[];
|
||||||
const config = store.get('serverConfig');
|
const config = store.get('serverConfig');
|
||||||
|
|
||||||
|
console.log(`[Tray] Building menu with ${accounts.length} accounts`);
|
||||||
|
|
||||||
const contextMenu = Menu.buildFromTemplate([
|
const contextMenu = Menu.buildFromTemplate([
|
||||||
{ label: `Ultimate Ban Tracker v${app.getVersion()}`, enabled: false },
|
{ label: `Ultimate Ban Tracker v${app.getVersion()}`, enabled: false },
|
||||||
{ type: 'separator' },
|
{ type: 'separator' },
|
||||||
@@ -158,34 +153,40 @@ const updateTrayMenu = () => {
|
|||||||
submenu: accounts.length > 0 ? accounts.map(acc => ({
|
submenu: accounts.length > 0 ? accounts.map(acc => ({
|
||||||
label: `${acc.personaName} ${acc.loginName ? `(${acc.loginName})` : ''}`,
|
label: `${acc.personaName} ${acc.loginName ? `(${acc.loginName})` : ''}`,
|
||||||
enabled: !!acc.loginName,
|
enabled: !!acc.loginName,
|
||||||
click: () => handleSwitchAccount(acc.loginName)
|
click: () => {
|
||||||
|
console.log(`[Tray] Switching to ${acc.loginName}`);
|
||||||
|
handleSwitchAccount(acc.loginName);
|
||||||
|
}
|
||||||
})) : [{ label: 'No accounts found', enabled: false }]
|
})) : [{ label: 'No accounts found', enabled: false }]
|
||||||
},
|
},
|
||||||
{ label: 'Sync Now', enabled: !!config?.enabled, click: () => syncAccounts(true) },
|
{ label: 'Sync Now', enabled: !!config?.enabled, click: () => syncAccounts(true) },
|
||||||
{ type: 'separator' },
|
{ type: 'separator' },
|
||||||
{ label: 'Show Dashboard', click: () => { if (mainWindow) mainWindow.show(); } },
|
{ label: 'Show Dashboard', click: () => { if (mainWindow) { mainWindow.show(); mainWindow.focus(); } } },
|
||||||
{ label: 'Quit', click: () => { (app as any).isQuitting = true; app.quit(); } }
|
{ label: 'Quit', click: () => { (app as any).isQuitting = true; app.quit(); } }
|
||||||
]);
|
]);
|
||||||
tray.setContextMenu(contextMenu);
|
tray.setContextMenu(contextMenu);
|
||||||
};
|
};
|
||||||
|
|
||||||
const setAppIcon = (themeName: string = 'steam') => {
|
const setAppIcon = (themeName: string = 'steam') => {
|
||||||
const assetsDir = path.join(__dirname, '..', 'assets-build', 'icons');
|
// Check system icons folder first on Linux
|
||||||
const iconPath = path.join(assetsDir, `${themeName}.svg`);
|
const possiblePaths = [
|
||||||
|
path.join(__dirname, '..', 'assets-build', 'icons', `${themeName}.svg`),
|
||||||
|
path.join(app.getAppPath(), 'assets-build', 'icons', `${themeName}.svg`),
|
||||||
|
'/usr/share/pixmaps/ultimate-ban-tracker.png' // Global fallback
|
||||||
|
];
|
||||||
|
|
||||||
if (!fs.existsSync(iconPath)) return;
|
let iconPath = '';
|
||||||
|
for (const p of possiblePaths) {
|
||||||
|
if (fs.existsSync(p)) { iconPath = p; break; }
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!iconPath) return;
|
||||||
|
|
||||||
const icon = nativeImage.createFromPath(iconPath);
|
const icon = nativeImage.createFromPath(iconPath);
|
||||||
|
if (tray) tray.setImage(icon.resize({ width: 16, height: 16 }));
|
||||||
|
if (mainWindow) mainWindow.setIcon(icon);
|
||||||
|
|
||||||
// Update Tray
|
updateTrayMenu(); // Always rebuild menu after icon update to ensure it's fresh
|
||||||
if (tray) {
|
|
||||||
tray.setImage(icon.resize({ width: 16, height: 16 }));
|
|
||||||
}
|
|
||||||
|
|
||||||
// Update Main Window
|
|
||||||
if (mainWindow) {
|
|
||||||
mainWindow.setIcon(icon);
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// --- Steam Logic ---
|
// --- Steam Logic ---
|
||||||
|
|||||||
Reference in New Issue
Block a user