@@ -129,3 +145,7 @@
Macro sidebar grouping
The Follow operating system theme option may not be supported on all Linux distributions.
+
+
+ On Linux, disabling this option stops minimize-to-tray behaviour immediately, but the tray icon may remain visible until Agent is restarted.
+
diff --git a/packages/uhk-web/src/app/components/agent/settings/settings.component.ts b/packages/uhk-web/src/app/components/agent/settings/settings.component.ts
index 8bb2c563ab7..ccd06a1380b 100644
--- a/packages/uhk-web/src/app/components/agent/settings/settings.component.ts
+++ b/packages/uhk-web/src/app/components/agent/settings/settings.component.ts
@@ -13,9 +13,10 @@ import {
getAppTheme,
getIsAdvancedSettingsMenuVisible,
getMacroGroupingSettings,
+ getMinimizeToTray,
getOperatingSystem,
getSupportedThemes,
- keyboardHalvesAlwaysJoined
+ keyboardHalvesAlwaysJoined,
} from '../../../store';
import { MACRO_GROUPING_MAX_DEPTH } from '../../../util/group-macros-by-name';
import { State as UpdateSettingsState } from '../../../store/reducers/auto-update-settings';
@@ -23,7 +24,14 @@ import {
CheckForUpdateNowAction,
ToggleCheckForUpdateOnStartupAction
} from '../../../store/actions/auto-update-settings';
-import { OpenConfigFolderAction, SetAppThemeAction, SetMacroGroupingSettingsAction, ToggleAnimationEnabledAction, ToggleKeyboardHalvesAlwaysJoinedAction } from '../../../store/actions/app';
+import {
+ OpenConfigFolderAction,
+ SetAppThemeAction,
+ SetMacroGroupingSettingsAction,
+ ToggleAnimationEnabledAction,
+ ToggleKeyboardHalvesAlwaysJoinedAction,
+ ToggleMinimizeToTrayAction,
+} from '../../../store/actions/app';
import { ToggleAlwaysEnableAdvancedModeAction } from '../../../store/actions/advance-settings.action';
import { OperatingSystem } from '../../../models/operating-system';
@@ -39,6 +47,7 @@ import { OperatingSystem } from '../../../models/operating-system';
export class SettingsComponent {
updateSettingsState$: Observable
;
animationEnabled$: Observable;
+ minimizeToTray$: Observable;
appTheme$: Observable;
themes$: Observable;
isLinux$: Observable;
@@ -52,6 +61,7 @@ export class SettingsComponent {
constructor(private store: Store) {
this.updateSettingsState$ = store.select(appUpdateSettingsState);
this.animationEnabled$ = store.select(getAnimationEnabled);
+ this.minimizeToTray$ = store.select(getMinimizeToTray);
this.appTheme$ = store.select(getAppTheme);
this.themes$ = store.select(getSupportedThemes);
this.isLinux$ = store.select(getOperatingSystem).pipe(map(os => os === OperatingSystem.Linux));
@@ -85,6 +95,10 @@ export class SettingsComponent {
this.store.dispatch(new ToggleKeyboardHalvesAlwaysJoinedAction(enabled));
}
+ toggleMinimizeToTray(enabled: boolean): void {
+ this.store.dispatch(new ToggleMinimizeToTrayAction(enabled));
+ }
+
toggleAlwaysEnableAdvancedMode(enabled: boolean): void {
this.store.dispatch(new ToggleAlwaysEnableAdvancedModeAction(enabled));
}
diff --git a/packages/uhk-web/src/app/services/app-renderer.service.ts b/packages/uhk-web/src/app/services/app-renderer.service.ts
index abe1235b226..9573965bbb5 100644
--- a/packages/uhk-web/src/app/services/app-renderer.service.ts
+++ b/packages/uhk-web/src/app/services/app-renderer.service.ts
@@ -1,9 +1,9 @@
import { Injectable, NgZone } from '@angular/core';
import { Action, Store } from '@ngrx/store';
-import { AppStartInfo, IpcEvents, LogService } from 'uhk-common';
+import { AppStartInfo, IpcEvents, LogService, NotificationType } from 'uhk-common';
import { AppState } from '../store';
-import { ElectronMainLogReceivedAction, ProcessAppStartInfoAction } from '../store/actions/app';
+import { ElectronMainLogReceivedAction, ProcessAppStartInfoAction, ShowNotificationAction } from '../store/actions/app';
import { IpcCommonRenderer } from './ipc-common-renderer';
@Injectable()
@@ -36,11 +36,23 @@ export class AppRendererService {
this.ipcRenderer.send(IpcEvents.app.openUrl, url);
}
+ setMinimizeToTray(enabled: boolean): void {
+ this.logService.misc(`[AppRendererService] set minimize to tray: ${enabled}`);
+ this.ipcRenderer.send(IpcEvents.app.minimizeToTrayChanged, enabled);
+ }
+
private registerEvents() {
this.ipcRenderer.on(IpcEvents.app.getAppStartInfoReply, (event: string, arg: AppStartInfo) => {
this.dispatchStoreAction(new ProcessAppStartInfoAction(arg));
});
+ this.ipcRenderer.on(IpcEvents.app.minimizeToTrayDisabledOnLinux, () => {
+ this.dispatchStoreAction(new ShowNotificationAction({
+ type: NotificationType.Info,
+ message: 'The tray icon will disappear after you restart Agent.'
+ }));
+ });
+
this.ipcRenderer.on('__ELECTRON_LOG_IPC__', (event: string, { level, data }) => {
const message = [];
diff --git a/packages/uhk-web/src/app/store/actions/app.ts b/packages/uhk-web/src/app/store/actions/app.ts
index 1ab6f0d9e10..3edf75caa69 100644
--- a/packages/uhk-web/src/app/store/actions/app.ts
+++ b/packages/uhk-web/src/app/store/actions/app.ts
@@ -30,6 +30,7 @@ export enum ActionTypes {
ToggleAnimationEnabled = '[app] Toggle animation enabled',
ToggleKeyboardHalvesAlwaysJoined = '[app] Toggle keyboard halves always joined',
SetMacroGroupingSettings = '[app] Set macro grouping settings',
+ ToggleMinimizeToTray = '[app] Toggle minimize to tray',
SetAppTheme = '[app] Set application theme',
LoadAppStartInfo = '[app] Load app start info',
StartKeypressCapturing = '[app] Start keypress capturing',
@@ -181,6 +182,13 @@ export class SetMacroGroupingSettingsAction implements Action {
}
}
+export class ToggleMinimizeToTrayAction implements Action {
+ type = ActionTypes.ToggleMinimizeToTray;
+
+ constructor(public payload: boolean) {
+ }
+}
+
export class SetAppThemeAction implements Action {
type = ActionTypes.SetAppTheme;
@@ -244,6 +252,7 @@ export type Actions
| ToggleAnimationEnabledAction
| ToggleKeyboardHalvesAlwaysJoinedAction
| SetMacroGroupingSettingsAction
+ | ToggleMinimizeToTrayAction
| SetAppThemeAction
| LoadAppStartInfoAction
| StartKeypressCapturingAction
diff --git a/packages/uhk-web/src/app/store/effects/app.ts b/packages/uhk-web/src/app/store/effects/app.ts
index 7e1689f2386..df97187dd0a 100644
--- a/packages/uhk-web/src/app/store/effects/app.ts
+++ b/packages/uhk-web/src/app/store/effects/app.ts
@@ -26,6 +26,7 @@ import {
SaveApplicationSettingsSuccessAction,
SetAppThemeAction,
ShowNotificationAction,
+ ToggleMinimizeToTrayAction,
UndoLastAction
} from '../actions/app';
import { ActionTypes as UpdateActionTypes } from '../actions/auto-update-settings';
@@ -60,6 +61,7 @@ export class ApplicationEffects {
everAttemptedSavingToKeyboard: false,
animationEnabled: true,
keyboardHalvesAlwaysJoined: false,
+ minimizeToTray: false,
...appSettings
};
@@ -147,6 +149,7 @@ export class ApplicationEffects {
ActionTypes.SetMacroGroupingSettings,
ActionTypes.ToggleAnimationEnabled,
ActionTypes.ToggleKeyboardHalvesAlwaysJoined,
+ ActionTypes.ToggleMinimizeToTray,
AdvanceSettingsActionTypes.toggleAlwaysEnableAdvancedMode,
UpdateActionTypes.ToggleCheckForUpdateOnStartup,
DeviceActionTypes.SaveConfiguration,
@@ -177,6 +180,17 @@ export class ApplicationEffects {
{ dispatch: false }
);
+ minimizeToTrayChanged$ = createEffect(() => this.actions$
+ .pipe(
+ ofType(ActionTypes.ToggleMinimizeToTray),
+ map(action => action.payload),
+ tap((enabled) => {
+ this.appRendererService.setMinimizeToTray(enabled);
+ })
+ ),
+ { dispatch: false }
+ );
+
navigateTo$ = createEffect(() => this.actions$
.pipe(
ofType(ActionTypes.NavigateTo),
diff --git a/packages/uhk-web/src/app/store/index.ts b/packages/uhk-web/src/app/store/index.ts
index e8665e4d4ac..a95a049ef6d 100644
--- a/packages/uhk-web/src/app/store/index.ts
+++ b/packages/uhk-web/src/app/store/index.ts
@@ -205,6 +205,7 @@ export const getEverAttemptedSavingToKeyboard = createSelector(appState, fromApp
export const getUdevFileContent = createSelector(appState, fromApp.getUdevFileContent);
export const getAnimationEnabled = createSelector(appState, fromApp.getAnimationEnabled);
export const getMacroGroupingSettings = createSelector(appState, fromApp.getMacroGroupingSettings);
+export const getMinimizeToTray = createSelector(appState, fromApp.getMinimizeToTray);
export const getAppTheme = createSelector(appState, fromApp.getAppTheme);
export const getUhkThemeColors = createSelector(getAppTheme, (theme): UhkThemeColors => {
return defaultUhkThemeColors(theme);
@@ -861,6 +862,7 @@ export const getApplicationSettings = createSelector(
appTheme: app.appTheme,
backlightingColorPalette,
keyboardHalvesAlwaysJoined,
+ minimizeToTray: app.minimizeToTray,
alwaysEnableAdvancedMode,
macroGrouping,
smartMacroPanelWidth
diff --git a/packages/uhk-web/src/app/store/reducers/app.reducer.ts b/packages/uhk-web/src/app/store/reducers/app.reducer.ts
index b55627f4f60..50954294259 100644
--- a/packages/uhk-web/src/app/store/reducers/app.reducer.ts
+++ b/packages/uhk-web/src/app/store/reducers/app.reducer.ts
@@ -24,6 +24,7 @@ const DEFAULT_ERROR_PANEL_HEIGHT = 10;
export interface State {
appTheme: AppTheme;
animationEnabled: boolean;
+ minimizeToTray: boolean;
errorPanelHeight: number;
isRunningOnWayland: boolean;
started: boolean;
@@ -48,6 +49,7 @@ export interface State {
export const initialState: State = {
appTheme: AppTheme.System,
animationEnabled: true,
+ minimizeToTray: false,
errorPanelHeight: DEFAULT_ERROR_PANEL_HEIGHT,
isRunningOnWayland: false,
started: false,
@@ -214,7 +216,8 @@ export function reducer(
everAttemptedSavingToKeyboard: settings.everAttemptedSavingToKeyboard,
animationEnabled: settings.animationEnabled,
appTheme: settings.appTheme || AppTheme.System,
- macroGrouping: normalizeMacroGroupingSettings(settings.macroGrouping)
+ macroGrouping: normalizeMacroGroupingSettings(settings.macroGrouping),
+ minimizeToTray: settings.minimizeToTray ?? false,
};
}
@@ -239,6 +242,12 @@ export function reducer(
})
};
+ case App.ActionTypes.ToggleMinimizeToTray:
+ return {
+ ...state,
+ minimizeToTray: (action as App.ToggleMinimizeToTrayAction).payload
+ };
+
case App.ActionTypes.SetAppTheme:
return {
...state,
@@ -283,6 +292,7 @@ export const getEverAttemptedSavingToKeyboard = (state: State): boolean => state
export const getUdevFileContent = (state: State): string => state.udevFileContent;
export const getAnimationEnabled = (state: State): boolean => state.animationEnabled;
export const getMacroGroupingSettings = (state: State): MacroGroupingSettings => state.macroGrouping;
+export const getMinimizeToTray = (state: State): boolean => state.minimizeToTray;
export const getAppTheme = (state: State): AppTheme => state.appTheme;
export const getHardwareConfiguration = (state: State): HardwareConfiguration => state.hardwareConfig;
export const getPlatform = (state: State): string => state.platform;