mirror of
https://github.com/Eugeny/tabby
synced 2024-12-14 07:12:50 +00:00
Revert "wsl: Get the distro icon from the package family name"
This reverts commit 1e6c2cba76
.
This commit is contained in:
parent
4485e9a917
commit
72a5da5ac3
4 changed files with 3 additions and 54 deletions
|
@ -24,7 +24,6 @@
|
||||||
"electron-updater": "^5.2.1",
|
"electron-updater": "^5.2.1",
|
||||||
"fontmanager-redux": "1.1.0",
|
"fontmanager-redux": "1.1.0",
|
||||||
"glasstron": "0.1.1",
|
"glasstron": "0.1.1",
|
||||||
"node-powershell": "5.0.1",
|
|
||||||
"js-yaml": "4.1.0",
|
"js-yaml": "4.1.0",
|
||||||
"keytar": "^7.9.0",
|
"keytar": "^7.9.0",
|
||||||
"mz": "^2.7.0",
|
"mz": "^2.7.0",
|
||||||
|
|
|
@ -1,11 +1,7 @@
|
||||||
.icon(
|
|
||||||
[fastHtmlBind]='pngPath',
|
|
||||||
*ngIf='!isHTML && isPNG'
|
|
||||||
)
|
|
||||||
i.icon(
|
i.icon(
|
||||||
class='fa-fw {{icon}}',
|
class='fa-fw {{icon}}',
|
||||||
[style.color]='color',
|
[style.color]='color',
|
||||||
*ngIf='!isHTML && !isPNG'
|
*ngIf='!isHTML'
|
||||||
)
|
)
|
||||||
.icon(
|
.icon(
|
||||||
[fastHtmlBind]='icon',
|
[fastHtmlBind]='icon',
|
||||||
|
|
|
@ -12,15 +12,7 @@ export class ProfileIconComponent extends BaseComponent {
|
||||||
@Input() icon?: string
|
@Input() icon?: string
|
||||||
@Input() color?: string
|
@Input() color?: string
|
||||||
|
|
||||||
get pngPath (): string {
|
|
||||||
return `<img src="${this.icon?.trim()}" width="16" height="16" />`
|
|
||||||
}
|
|
||||||
|
|
||||||
get isHTML (): boolean {
|
get isHTML (): boolean {
|
||||||
return this.icon?.startsWith('<') ?? false
|
return this.icon?.startsWith('<') ?? false
|
||||||
}
|
}
|
||||||
|
|
||||||
get isPNG (): boolean {
|
|
||||||
return this.icon?.endsWith('.png') ?? false
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,8 +6,6 @@ import { HostAppService, Platform, isWindowsBuild, WIN_BUILD_WSL_EXE_DISTRO_FLAG
|
||||||
|
|
||||||
import { ShellProvider, Shell } from 'tabby-local'
|
import { ShellProvider, Shell } from 'tabby-local'
|
||||||
|
|
||||||
import { PowerShell } from 'node-powershell'
|
|
||||||
|
|
||||||
/* eslint-disable block-scoped-var */
|
/* eslint-disable block-scoped-var */
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
@ -40,42 +38,10 @@ const wslIconMap: Record<string, string> = {
|
||||||
/** @hidden */
|
/** @hidden */
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class WSLShellProvider extends ShellProvider {
|
export class WSLShellProvider extends ShellProvider {
|
||||||
private _pwsh: PowerShell
|
|
||||||
|
|
||||||
constructor (
|
constructor (
|
||||||
private hostApp: HostAppService,
|
private hostApp: HostAppService,
|
||||||
) {
|
) {
|
||||||
super()
|
super()
|
||||||
|
|
||||||
// make sure that this will not use the powershell profile
|
|
||||||
// that may take a long time to load
|
|
||||||
this._pwsh = new PowerShell({
|
|
||||||
executableOptions: {
|
|
||||||
'-NoProfile': true,
|
|
||||||
},
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
private async _resolveIcon (defaultDistKey: any): Promise<string> {
|
|
||||||
let _icon = wslIconMap.Linux
|
|
||||||
|
|
||||||
// check if the register has PackageFamilyName
|
|
||||||
if (defaultDistKey.PackageFamilyName) {
|
|
||||||
// get the icon from the package family name
|
|
||||||
const packageFamilyName = (defaultDistKey.PackageFamilyName.value as string).split('_')[0]
|
|
||||||
|
|
||||||
if (packageFamilyName) {
|
|
||||||
const _ret = await this._pwsh.invoke(`Get-AppxPackage ${packageFamilyName} | ConvertTo-Json`)
|
|
||||||
|
|
||||||
if (!_ret.hadErrors && _ret.stdout?.toString() !== undefined && _ret.stdout.toString() !== '') {
|
|
||||||
const appx = JSON.parse(_ret.stdout.toString())
|
|
||||||
const installationLocation = appx.InstallLocation
|
|
||||||
_icon = `${installationLocation}\\Assets\\Square44x44Logo.targetsize-16.png`
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return _icon
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async provide (): Promise<Shell[]> {
|
async provide (): Promise<Shell[]> {
|
||||||
|
@ -93,7 +59,6 @@ export class WSLShellProvider extends ShellProvider {
|
||||||
if (lxss?.DefaultDistribution) {
|
if (lxss?.DefaultDistribution) {
|
||||||
const defaultDistKey = wnr.getRegistryKey(wnr.HK.CU, lxssPath + '\\' + String(lxss.DefaultDistribution.value))
|
const defaultDistKey = wnr.getRegistryKey(wnr.HK.CU, lxssPath + '\\' + String(lxss.DefaultDistribution.value))
|
||||||
if (defaultDistKey?.DistributionName) {
|
if (defaultDistKey?.DistributionName) {
|
||||||
const _icon = await this._resolveIcon(defaultDistKey)
|
|
||||||
const shell: Shell = {
|
const shell: Shell = {
|
||||||
id: 'wsl',
|
id: 'wsl',
|
||||||
name: 'WSL / Default distro',
|
name: 'WSL / Default distro',
|
||||||
|
@ -103,7 +68,7 @@ export class WSLShellProvider extends ShellProvider {
|
||||||
COLORTERM: 'truecolor',
|
COLORTERM: 'truecolor',
|
||||||
},
|
},
|
||||||
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
||||||
icon: wslIconMap[defaultDistKey.DistributionName.value] ?? _icon,
|
icon: wslIconMap[defaultDistKey.DistributionName.value] ?? wslIconMap.Linux,
|
||||||
}
|
}
|
||||||
shells.push(shell)
|
shells.push(shell)
|
||||||
}
|
}
|
||||||
|
@ -125,14 +90,11 @@ export class WSLShellProvider extends ShellProvider {
|
||||||
return []
|
return []
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (const child of wnr.listRegistrySubkeys(wnr.HK.CU, lxssPath) as string[]) {
|
for (const child of wnr.listRegistrySubkeys(wnr.HK.CU, lxssPath) as string[]) {
|
||||||
const childKey = wnr.getRegistryKey(wnr.HK.CU, lxssPath + '\\' + child)
|
const childKey = wnr.getRegistryKey(wnr.HK.CU, lxssPath + '\\' + child)
|
||||||
if (!childKey.DistributionName || !childKey.BasePath) {
|
if (!childKey.DistributionName || !childKey.BasePath) {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
const _icon = await this._resolveIcon(childKey)
|
|
||||||
const wslVersion = (childKey.Flags?.value || 0) & 8 ? 2 : 1
|
const wslVersion = (childKey.Flags?.value || 0) & 8 ? 2 : 1
|
||||||
const name = childKey.DistributionName.value
|
const name = childKey.DistributionName.value
|
||||||
const fsBase = wslVersion === 2 ? `\\\\wsl$\\${name}` : childKey.BasePath.value as string + '\\rootfs'
|
const fsBase = wslVersion === 2 ? `\\\\wsl$\\${name}` : childKey.BasePath.value as string + '\\rootfs'
|
||||||
|
@ -148,7 +110,7 @@ export class WSLShellProvider extends ShellProvider {
|
||||||
COLORTERM: 'truecolor',
|
COLORTERM: 'truecolor',
|
||||||
},
|
},
|
||||||
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
||||||
icon: wslIconMap[name] ?? _icon,
|
icon: wslIconMap[name] ?? wslIconMap.Linux,
|
||||||
}
|
}
|
||||||
shells.push(shell)
|
shells.push(shell)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue