diff --git a/src/vs/code/electron-main/main.ts b/src/vs/code/electron-main/main.ts index 8ea3d44a28626..0e4c43846ae2a 100644 --- a/src/vs/code/electron-main/main.ts +++ b/src/vs/code/electron-main/main.ts @@ -170,6 +170,15 @@ class CodeMain { // Environment const environmentMainService = new EnvironmentMainService(this.resolveArgs(), productService); + + // Set custom application name for WM_CLASS/app_id when --class argument is provided + if (environmentMainService.args.class) { + app.setName(environmentMainService.args.class); + if (isLinux) { + app.setDesktopName(environmentMainService.args.class); + } + } + const instanceEnvironment = this.patchEnvironment(environmentMainService); // Patch `process.env` with the instance's environment services.set(IEnvironmentMainService, environmentMainService); diff --git a/src/vs/platform/environment/common/argv.ts b/src/vs/platform/environment/common/argv.ts index a10f4c9b3bbc5..b9a42f27b4c2c 100644 --- a/src/vs/platform/environment/common/argv.ts +++ b/src/vs/platform/environment/common/argv.ts @@ -169,4 +169,5 @@ export interface NativeParsedArgs { 'trace-startup-file'?: string; 'trace-startup-duration'?: string; 'xdg-portal-required-version'?: string; + 'class'?: string; } diff --git a/src/vs/platform/environment/node/argv.ts b/src/vs/platform/environment/node/argv.ts index 35a833d5f903d..02274526881d5 100644 --- a/src/vs/platform/environment/node/argv.ts +++ b/src/vs/platform/environment/node/argv.ts @@ -103,6 +103,7 @@ export const OPTIONS: OptionDescriptions> = { 'waitMarkerFilePath': { type: 'string' }, 'locale': { type: 'string', cat: 'o', args: 'locale', description: localize('locale', "The locale to use (e.g. en-US or zh-TW).") }, 'user-data-dir': { type: 'string', cat: 'o', args: 'dir', description: localize('userDataDir', "Specifies the directory that user data is kept in. Can be used to open multiple distinct instances of Code.") }, + 'class': { type: 'string', cat: 'o', args: 'name', description: localize('class', "Sets the application class as used by window managers. This affects the WM_CLASS window property and allows window managers to apply specific rules to the window.") }, 'profile': { type: 'string', 'cat': 'o', args: 'profileName', description: localize('profileName', "Opens the provided folder or workspace with the given profile and associates the profile with the workspace. If the profile does not exist, a new empty one is created.") }, 'help': { type: 'boolean', cat: 'o', alias: 'h', description: localize('help', "Print usage.") },