ssh: allow overriding X11 display - fixes #3975

This commit is contained in:
Eugene Pankov 2021-10-24 22:34:59 +02:00
parent 8e2ffa1654
commit 6fed2cb9c0
No known key found for this signature in database
GPG key ID: 5896FCBBDD1CF4F4
5 changed files with 28 additions and 5 deletions

View file

@ -42,4 +42,15 @@ h3 SSH
(ngModelChange)='config.save()', (ngModelChange)='config.save()',
) )
.alert.alert-info SSH connection management is now done through the Profiles tab .form-line
.header
.title Override X11 display
.description Path or address of the local X11 socket
input.form-control(
type='text',
[placeholder]='defaultX11Display',
[(ngModel)]='config.store.ssh.x11Display',
(ngModelChange)='config.save()'
)
.alert.alert-info SSH connection management is now done through the #[strong Profiles & connections] tab

View file

@ -1,4 +1,5 @@
import { Component } from '@angular/core' import { Component } from '@angular/core'
import { X11Socket } from '../session/x11'
import { ConfigService, HostAppService, Platform } from 'tabby-core' import { ConfigService, HostAppService, Platform } from 'tabby-core'
/** @hidden */ /** @hidden */
@ -7,9 +8,17 @@ import { ConfigService, HostAppService, Platform } from 'tabby-core'
}) })
export class SSHSettingsTabComponent { export class SSHSettingsTabComponent {
Platform = Platform Platform = Platform
defaultX11Display: string
constructor ( constructor (
public config: ConfigService, public config: ConfigService,
public hostApp: HostAppService, public hostApp: HostAppService,
) { } ) {
const spec = X11Socket.resolveDisplaySpec()
if ('path' in spec) {
this.defaultX11Display = spec.path
} else {
this.defaultX11Display = `${spec.host}:${spec.port}`
}
}
} }

View file

@ -8,6 +8,7 @@ export class SSHConfigProvider extends ConfigProvider {
winSCPPath: null, winSCPPath: null,
agentType: 'auto', agentType: 'auto',
agentPath: null, agentPath: null,
x11Display: null,
}, },
hotkeys: { hotkeys: {
'restart-ssh-session': [], 'restart-ssh-session': [],

View file

@ -5,16 +5,16 @@ export class X11Socket {
error$ = new Subject<Error>() error$ = new Subject<Error>()
private socket: Socket | null = null private socket: Socket | null = null
static resolveDisplaySpec (spec: string): SocketConnectOpts { static resolveDisplaySpec (spec?: string|null): SocketConnectOpts {
// eslint-disable-next-line prefer-const // eslint-disable-next-line prefer-const
let [xHost, xDisplay] = /^(.+):(\d+)(?:.(\d+))$/.exec(spec) ?? [] let [xHost, xDisplay] = /^(.+):(\d+)(?:.(\d+))$/.exec(spec ?? process.env.DISPLAY ?? 'localhost:0') ?? []
if (process.platform === 'win32') { if (process.platform === 'win32') {
xHost ??= 'localhost' xHost ??= 'localhost'
} else { } else {
xHost ??= 'unix' xHost ??= 'unix'
} }
if (spec.startsWith('/')) { if (spec?.startsWith('/')) {
xHost = spec xHost = spec
} }

View file

@ -11,6 +11,7 @@ export class AppearanceSettingsTabProvider extends SettingsTabProvider {
id = 'terminal-appearance' id = 'terminal-appearance'
icon = 'swatchbook' icon = 'swatchbook'
title = 'Appearance' title = 'Appearance'
prioritized = true
getComponentType (): any { getComponentType (): any {
return AppearanceSettingsTabComponent return AppearanceSettingsTabComponent
@ -35,6 +36,7 @@ export class TerminalSettingsTabProvider extends SettingsTabProvider {
id = 'terminal' id = 'terminal'
icon = 'terminal' icon = 'terminal'
title = 'Terminal' title = 'Terminal'
prioritized = true
getComponentType (): any { getComponentType (): any {
return TerminalSettingsTabComponent return TerminalSettingsTabComponent