TeamViewer 仅在 GUI 启动后运行

TeamViewer 仅在 GUI 启动后运行

我有一个可以正常工作的 TeamViewer,在启动 TeamViewer 的 GUI 后,我可以成功连接到它。但不幸的是,当 TeamViewer 的 GUI 未启动时,我无法连接到我的计算机。所有可以找到的文档都表明,运行 TeamViewer 守护程序teamviewerd就足以远程连接到计算机,但对我来说似乎并非如此。

没有 TeamViewer GUI(只有 teamviewerd)

输出teamviewer status

 TeamViewer                           11.0.57095  (DEB) 

 teamviewerd status                   ● teamviewerd.service - TeamViewer remote control daemon
   Loaded: loaded (/etc/systemd/system/teamviewerd.service; enabled; vendor preset: enabled)
   Active: active (running) since Sa 2016-04-30 17:01:55 CEST; 11min ago
  Process: 15518 ExecStart=/opt/teamviewer/tv_bin/teamviewerd -d (code=exited, status=0/SUCCESS)
 Main PID: 15521 (teamviewerd)
   CGroup: /system.slice/teamviewerd.service
           └─15521 /opt/teamviewer/tv_bin/teamviewerd -d

Apr 30 17:01:54 rvaio systemd[1]: Starting TeamViewer remote control daemon...
Apr 30 17:01:55 rvaio systemd[1]: teamviewerd.service: PID file /var/run/teamviewerd.pid not readable (yet?) after start: No such file or directory
Apr 30 17:01:55 rvaio systemd[1]: Started TeamViewer remote control daemon. 

 TeamViewer ID:                        123456789

输出sudo netstat -ntap | grep teamviewer

tcp        0      0 0.0.0.0:5938            0.0.0.0:*               LISTEN      1447/teamviewerd
tcp        0      0 127.0.0.1:5940          0.0.0.0:*               LISTEN      1447/teamviewerd
tcp6       0      0 :::5938                 :::*                    LISTEN      1447/teamviewerd

启动 TeamViewer GUI

输出teamviewer status

 TeamViewer                           11.0.57095  (DEB) 

 teamviewerd status                   ● teamviewerd.service - TeamViewer remote control daemon
   Loaded: loaded (/etc/systemd/system/teamviewerd.service; enabled; vendor preset: enabled)
   Active: active (running) since Sa 2016-04-30 17:01:55 CEST; 18min ago
  Process: 15518 ExecStart=/opt/teamviewer/tv_bin/teamviewerd -d (code=exited, status=0/SUCCESS)
 Main PID: 15521 (teamviewerd)
   CGroup: /system.slice/teamviewerd.service
           └─15521 /opt/teamviewer/tv_bin/teamviewerd -d

Apr 30 17:01:54 rvaio systemd[1]: Starting TeamViewer remote control daemon...
Apr 30 17:01:55 rvaio systemd[1]: teamviewerd.service: PID file /var/run/teamviewerd.pid not readable (yet?) after start: No such file or directory
Apr 30 17:01:55 rvaio systemd[1]: Started TeamViewer remote control daemon. 

 TeamViewer ID:                        123456789

输出sudo netstat -ntap | grep teamviewer

tcp        0      0 0.0.0.0:5938            0.0.0.0:*               LISTEN      15521/teamviewerd
tcp        0      0 127.0.0.1:5940          0.0.0.0:*               LISTEN      15521/teamviewerd
tcp        0      0 127.0.0.1:5940          127.0.0.1:48475         ESTABLISHED 15521/teamviewerd
tcp6       0      0 :::5938                 :::*                    LISTEN      15521/teamviewerd
tcp6       0      0 2003:72:2d76:2701:46132 2a01:488:2001:1c01:5938 ESTABLISHED 15521/teamviewerd

如您所见,启动 GUI 会导致建立两个连接,这与仅有守护进程不同。

答案1

我也遇到了这个问题,发现可能是程序本身的问题。我的解决方案是使用 Ubuntu 中提供的名为 gDevilspie 的程序。

您必须在程序中设置两个规则来隐藏主窗口和联系人列表。 在此处输入图片描述

以下是我设置 TeamViewer 的方法

在此处输入图片描述

在此处输入图片描述

以下是我使用的设置:

对于 TeamViewer:

application_name equals Computers & Contacts 
window_name      equals Computers & Contacts 

屏幕截图显示了该窗口的操作

对于 TeamViewer2:

application_name equals TeamViewer 
window_name      equals TeamViewer 

我针对此规则使用的操作是:关闭

这是我的 TeamViewer 设置方式..这将关闭主窗口并使其在我的托盘中运行。

现在,即使它在托盘中运行...如果我想查看它,我无法单击图标并选择显示 TeamViewer,否则它会再次打开并关闭。我必须停止 gDevilspie 才能打开/查看程序...请记住这一点

答案2

扩展@JohnOrion 发布的内容,我有一个更可靠的解决方案。它不会一直关闭 TeamViewer 的窗口,而是在程序启动时关闭两个窗口,然后在以后不再关闭它们。您需要执行以下操作:

  1. 安装devilspieprocmail

    sudo apt-get install devilspie procmail
    
  2. 将其写入~/.devilspie/TeamViewer.ds

    (if
        (or
            (and
                (is (application_name) "TeamViewer")
                (is (window_name) "TeamViewer")
            )
            (and
                (is (application_name) "Computers & Contacts")
                (is (window_name) "Computers & Contacts")
            )
        )
        (begin
            (close)
            (spawn_async "~/bin/teamviewer/tvwindow")
        )
    )
    
  3. 创建一个要在其中放置一些脚本的目录。我选择了~/bin/teamviewer,但您可以选择任何您喜欢的目录。如果您更改此目录,请确保您也在步骤 2 中的脚本中对其进行更改。

    mkdir -p ~/bin/teamviewer
    
  4. 将这些内容写入~/bin/teamviewer/tvwindow(如果需要,可以再次更改目录):

    #!/usr/bin/env bash
    
    source "$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )/vars"
    
    lockfile teamviewerstartup.lock
    
    # read remaining windows
    REMAINING_WINDOWS=$(cat "$REMAINING_WINDOWS_FILE")
    REMAINING_WINDOWS_NOW=$(($REMAINING_WINDOWS - 1))
    
    if [ $REMAINING_WINDOWS_NOW -eq 0 ]; then
        # TeamViewer has started up completely, kill devilspie
        kill $(cat "$DEVILSPIE_PID_FILE")
        # Also remove temporary files
        rm -f "$DEVILSPIE_PID_FILE"
        rm -f "$REMAINING_WINDOWS_FILE"
    else
        # One or more windows to go, write the decremented value to the file
        echo -n "$REMAINING_WINDOWS_NOW" > "$REMAINING_WINDOWS_FILE"
    fi
    
    rm -f teamviewerstartup.lock
    
  5. 将这些内容写入~/bin/teamviewer/tvminimizedstart(如果需要,可以再次更改目录):

    #!/usr/bin/env bash
    
    source "$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )/vars"
    
    nohup devilspie > /dev/null 2>&1 &
    DEVILSPIE_PID=$!
    
    lockfile teamviewerstartup.lock
    
    # Write PID of devilspie process
    echo -n "$DEVILSPIE_PID" > "$DEVILSPIE_PID_FILE"
    # Set remaining to be closed windows to 2
    echo -n "2" > "$REMAINING_WINDOWS_FILE"
    
    rm -f teamviewerstartup.lock
    
    nohup teamviewer >/dev/null 2>&1 &
    
  6. 将这些内容写入~/bin/teamviewer/vars(如果需要,可以再次更改目录):

    #!/usr/bin/env bash
    
    DEVILSPIE_PID_FILE="$HOME/bin/teamviewer/devilspiepid"
    REMAINING_WINDOWS_FILE="$HOME/bin/teamviewer/remaining-windows"
    
  7. 使它们可执行。

    chmod +x ~/bin/teamviewer/tvwindow ~/bin/teamviewer/tvminimizedstart ~/bin/teamviewer/vars
    

使用此解决方案,运行tvminimizedstart脚本:

~/bin/teamviewer/tvminimizedstart

相关内容