浏览代码

ssh: allow overriding X11 display - fixes #3975

Eugene Pankov 4 年之前
父节点
当前提交
6fed2cb9c0

+ 12 - 1
tabby-ssh/src/components/sshSettingsTab.component.pug

@@ -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

+ 10 - 1
tabby-ssh/src/components/sshSettingsTab.component.ts

@@ -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}`
+        }
+    }
 }

+ 1 - 0
tabby-ssh/src/config.ts

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

+ 3 - 3
tabby-ssh/src/session/x11.ts

@@ -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
         }
 

+ 2 - 0
tabby-terminal/src/settings.ts

@@ -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