From 99c14df7fa7725bda690b6398cf92ea83f47a81e Mon Sep 17 00:00:00 2001 From: Markus Katharina Brechtel Date: Thu, 25 Nov 2021 18:16:14 +0100 Subject: [PATCH] vncserver socket based connections --- tasks/vnc.yaml | 30 ------------------------------ templates/vnc/Xvnc-session.j2 | 7 ------- templates/vnc/config.j2 | 1 - templates/vnc/vnc.conf.j2 | 4 ---- templates/vnc/vncserver.env.j2 | 3 --- templates/vnc/vncserver.service.j2 | 10 ++++++---- templates/vnc/xsession.j2 | 5 ----- templates/x11/xsession.j2 | 2 +- vars/main.yaml | 11 +++++++++++ 9 files changed, 18 insertions(+), 55 deletions(-) delete mode 100644 templates/vnc/Xvnc-session.j2 delete mode 100644 templates/vnc/config.j2 delete mode 100644 templates/vnc/vnc.conf.j2 delete mode 100644 templates/vnc/vncserver.env.j2 delete mode 100644 templates/vnc/xsession.j2 diff --git a/tasks/vnc.yaml b/tasks/vnc.yaml index 847c92e..d4ddfc9 100644 --- a/tasks/vnc.yaml +++ b/tasks/vnc.yaml @@ -6,24 +6,6 @@ state: directory mode: 0700 -- name: vnc config - template: - src: vnc/config.j2 - dest: ~/.vnc/config - mode: 0644 - -- name: vnc env - template: - src: vnc/vncserver.env.j2 - dest: ~/.vnc/vncserver.env - mode: 0644 - -- name: vnc server config - template: - src: vnc/vnc.conf.j2 - dest: ~/.vnc/vnc.conf - mode: 0644 - - name: vnc passwd copy: content: "{{ lookup('pipe','pwgen 24 1' )}}" @@ -54,15 +36,3 @@ src: vnc/vncserver.service.j2 dest: ~/.config/systemd/user/vncserver@.service notify: systemd daemon-reload - -- name: Xvnc-session script - template: - src: vnc/Xvnc-session.j2 - dest: ~/.vnc/Xvnc-session - mode: 0755 - -- name: vnc xsession script - template: - src: vnc/xsession.j2 - dest: ~/.vnc/xsession - mode: 0755 diff --git a/templates/vnc/Xvnc-session.j2 b/templates/vnc/Xvnc-session.j2 deleted file mode 100644 index ac23dbb..0000000 --- a/templates/vnc/Xvnc-session.j2 +++ /dev/null @@ -1,7 +0,0 @@ -#!/bin/sh - -{{ansible_managed|comment}} - -xrandr --output VNC-0 --primary - -exec /etc/X11/Xsession ~/.vnc/xsession diff --git a/templates/vnc/config.j2 b/templates/vnc/config.j2 deleted file mode 100644 index 5c02948..0000000 --- a/templates/vnc/config.j2 +++ /dev/null @@ -1 +0,0 @@ -{{ ansible_managed | comment }} diff --git a/templates/vnc/vnc.conf.j2 b/templates/vnc/vnc.conf.j2 deleted file mode 100644 index ffb5dd8..0000000 --- a/templates/vnc/vnc.conf.j2 +++ /dev/null @@ -1,4 +0,0 @@ -{{ ansible_managed | comment }} - -$desktopName = "{{inventory_hostname}}$ENV{DISPLAY}"; -$geometry = "{{home_vncserver_geometry}}"; diff --git a/templates/vnc/vncserver.env.j2 b/templates/vnc/vncserver.env.j2 deleted file mode 100644 index 118ccaa..0000000 --- a/templates/vnc/vncserver.env.j2 +++ /dev/null @@ -1,3 +0,0 @@ -{{ ansible_managed | comment }} - -VNCSERVER_OPTIONS="{{vncserver_options|replace('\n',' ')|trim}}" diff --git a/templates/vnc/vncserver.service.j2 b/templates/vnc/vncserver.service.j2 index 673badf..e58e82f 100644 --- a/templates/vnc/vncserver.service.j2 +++ b/templates/vnc/vncserver.service.j2 @@ -19,10 +19,12 @@ Description=vncserver service - display %i After=syslog.target network.target [Service] -EnvironmentFile=%h/.vnc/vncserver.env -Type=forking -ExecStart=/usr/bin/vncserver -autokill %i $VNCSERVER_OPTIONS -ExecStop=/usr/bin/vncserver -kill %i +WorkingDirectory=%h +Environment=DISPLAY=%i +ExecStart=Xtigervnc $DISPLAY {{vncserver_options|replace('\n',' ')|trim}} +ExecStartPost=fish -c "while not xdpyinfo > /dev/null 2> /dev/null; sleep 0.1; end" +ExecStartPost=xrandr --output VNC-0 --primary +ExecStartPost=systemctl --user start xsession.target [Install] WantedBy=default.target diff --git a/templates/vnc/xsession.j2 b/templates/vnc/xsession.j2 deleted file mode 100644 index 29ed55a..0000000 --- a/templates/vnc/xsession.j2 +++ /dev/null @@ -1,5 +0,0 @@ -#!/bin/sh - -{{ansible_managed|comment}} - -exec systemctl --user start --wait xsession.target diff --git a/templates/x11/xsession.j2 b/templates/x11/xsession.j2 index 39b9e14..968e57b 100644 --- a/templates/x11/xsession.j2 +++ b/templates/x11/xsession.j2 @@ -7,5 +7,5 @@ exec systemctl --user start --wait xsession.target {% else %} systemctl --user start vncserver@:{{home_vncserver_display_number}}.service i3 -c ~/.config/i3/null.config & -exec xtigervncviewer localhost:{{home_vncserver_display_number}} -PasswordFile ~/.vnc/passwd -FullScreen=1 -Maximize=1 +exec xtigervncviewer ~/.vnc/socket -PasswordFile ~/.vnc/passwd -FullScreen=1 -Maximize=1 {% endif %} diff --git a/vars/main.yaml b/vars/main.yaml index 67ed033..4141db5 100644 --- a/vars/main.yaml +++ b/vars/main.yaml @@ -135,6 +135,17 @@ timer_folder: ~/.timer timer_config: {} vncserver_options: | + -desktop %H%i + -auth %h/.Xauthority + -geometry {{home_vncserver_geometry}} + -depth 24 + -rfbwait 30000 + -rfbauth %h/.vnc/passwd + -rfbunixpath %h/.vnc/socket + -nolisten tcp + -pn + -localhost + -SecurityTypes VncAuth {% if not home_vncserver_allow_resize %} -AcceptSetDesktopSize=0 {% endif %}