Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Electron: Support tray icon on Linux
  • Loading branch information
JimmyJichi committed Mar 9, 2024
commit 568890c28498a0c9250d036b39339627eed8fd62
Binary file added public/icon-electron-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 3 additions & 2 deletions src/components/left/settings/SettingsGeneral.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ import { pick } from '../../../util/iteratees';
import { setTimeFormat } from '../../../util/langProvider';
import { getSystemTheme } from '../../../util/systemTheme';
import {
IS_ANDROID, IS_ELECTRON, IS_IOS, IS_MAC_OS, IS_WINDOWS,
IS_ANDROID, IS_ELECTRON, IS_IOS, IS_LINUX,
IS_MAC_OS, IS_WINDOWS,
} from '../../../util/windowEnvironment';

import useAppLayout from '../../../hooks/useAppLayout';
Expand Down Expand Up @@ -152,7 +153,7 @@ const SettingsGeneral: FC<OwnProps & StateProps> = ({
{lang('ChatBackground')}
</ListItem>

{IS_ELECTRON && IS_WINDOWS && (
{IS_ELECTRON && (IS_WINDOWS || IS_LINUX) && (
<Checkbox
label={lang('GeneralSettings.StatusBarItem')}
checked={Boolean(isTrayIconEnabled)}
Expand Down
1 change: 1 addition & 0 deletions src/electron/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ files:
- "dist"
- "package.json"
- "public/icon-electron-windows.ico"
- "public/icon-electron-linux.png"
- "!dist/**/build-stats.json"
- "!dist/**/statoscope-report.html"
- "!dist/**/reference.json"
Expand Down
7 changes: 5 additions & 2 deletions src/electron/tray.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ import {
import path from 'path';

import {
focusLastWindow, forceQuit, getAppTitle, store,
focusLastWindow, forceQuit, getAppTitle, IS_WINDOWS,
store,
} from './utils';

const TRAY_ICON_SETTINGS_KEY = 'trayIcon';
Expand Down Expand Up @@ -46,7 +47,9 @@ const tray: TrayHelper = {
return;
}

const icon = nativeImage.createFromPath(path.resolve(__dirname, '../public/icon-electron-windows.ico'));
const icon = IS_WINDOWS
? nativeImage.createFromPath(path.resolve(__dirname, '../public/icon-electron-windows.ico'))
: nativeImage.createFromPath(path.resolve(__dirname, '../public/icon-electron-linux.png'));
const title = getAppTitle();

this.instance = new Tray(icon);
Expand Down
6 changes: 3 additions & 3 deletions src/electron/window.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import { captureLocalStorage, restoreLocalStorage } from './localStorage';
import tray from './tray';
import {
checkIsWebContentsUrlAllowed, forceQuit, getAppTitle, getCurrentWindow, getLastWindow,
hasExtraWindows, IS_FIRST_RUN, IS_MAC_OS, IS_PREVIEW, IS_PRODUCTION, IS_WINDOWS,
hasExtraWindows, IS_FIRST_RUN, IS_LINUX, IS_MAC_OS, IS_PREVIEW, IS_PRODUCTION, IS_WINDOWS,
reloadWindows, store, TRAFFIC_LIGHT_POSITION, windows,
} from './utils';
import windowStateKeeper from './windowState';
Expand Down Expand Up @@ -100,7 +100,7 @@ export function createWindow(url?: string) {
});

window.on('close', (event) => {
if (IS_MAC_OS || (IS_WINDOWS && tray.isEnabled)) {
if (IS_MAC_OS || ((IS_WINDOWS || IS_LINUX) && tray.isEnabled)) {
if (forceQuit.isEnabled) {
app.exit(0);
forceQuit.disable();
Expand All @@ -120,7 +120,7 @@ export function createWindow(url?: string) {
window.removeMenu();
}

if (IS_WINDOWS && tray.isEnabled) {
if ((IS_WINDOWS || IS_LINUX) && tray.isEnabled) {
tray.setupListeners(window);
tray.create();
}
Expand Down