1
1
mirror of https://github.com/Eugeny/tabby.git synced 2024-12-24 02:53:43 +03:00

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()',
)
.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 { X11Socket } from '../session/x11'
import { ConfigService, HostAppService, Platform } from 'tabby-core'
/** @hidden */
@ -7,9 +8,17 @@ import { ConfigService, HostAppService, Platform } from 'tabby-core'
})
export class SSHSettingsTabComponent {
Platform = Platform
defaultX11Display: string
constructor (
public config: ConfigService,
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,
agentType: 'auto',
agentPath: null,
x11Display: null,
},
hotkeys: {
'restart-ssh-session': [],

View File

@ -5,16 +5,16 @@ export class X11Socket {
error$ = new Subject<Error>()
private socket: Socket | null = null
static resolveDisplaySpec (spec: string): SocketConnectOpts {
static resolveDisplaySpec (spec?: string|null): SocketConnectOpts {
// 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') {
xHost ??= 'localhost'
} else {
xHost ??= 'unix'
}
if (spec.startsWith('/')) {
if (spec?.startsWith('/')) {
xHost = spec
}

View File

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