From ccc1ff8e032fb1fcd88a18e69d27ab71ce8f1129 Mon Sep 17 00:00:00 2001 From: Markus Katharina Brechtel Date: Sun, 10 Jan 2021 06:44:55 +0100 Subject: [PATCH] vnc client to localhost for vdesk profile --- defaults/main.yaml | 5 +++-- tasks/i3.yaml | 5 +++++ tasks/main.yaml | 4 ++-- tasks/vnc.yaml | 2 +- templates/i3/i3.null.config.j2 | 15 +++++++++++++++ templates/vnc/vncserver.service.j2 | 1 - templates/vnc/xsession.j2 | 5 +++++ templates/workspaces/workspace.space.fish.j2 | 2 +- templates/x11/xsession.j2 | 6 ++++++ 9 files changed, 38 insertions(+), 7 deletions(-) create mode 100644 templates/i3/i3.null.config.j2 create mode 100644 templates/vnc/xsession.j2 diff --git a/defaults/main.yaml b/defaults/main.yaml index 63e6196..da87e2c 100644 --- a/defaults/main.yaml +++ b/defaults/main.yaml @@ -12,8 +12,9 @@ kanboard_api_settings: "{{ lookup('file', '~/.kanboard_api_settings.json') }}" # kanboard_api_url: https://kanboard.katyx.net/jsonrpc.php # kanboard_api_user: ka # kanboard_api_key: xxx -home_vdesk_started_and_enabled: false -home_vdesk_display_number: 47 +home_vncserver_started_and_enabled: "{{ home_profile == 'vdesk' }}" +home_vncserver_display_number: 47 +home_xsession_vncviewer: "{{ home_profile == 'vdesk' }}" home_profile: desktop diff --git a/tasks/i3.yaml b/tasks/i3.yaml index 6c8f380..f8b9ee3 100644 --- a/tasks/i3.yaml +++ b/tasks/i3.yaml @@ -10,6 +10,11 @@ src: i3/i3.config.j2 dest: ~/.config/i3/config +- name: i3 null config + template: + src: i3/i3.null.config.j2 + dest: ~/.config/i3/null.config + - name: check i3 config command: i3 -c ~/.config/i3/config -C changed_when: false diff --git a/tasks/main.yaml b/tasks/main.yaml index cc0423f..8b52008 100644 --- a/tasks/main.yaml +++ b/tasks/main.yaml @@ -28,8 +28,8 @@ - name: enable and start vncserver user service systemd: - name: vncserver@:{{home_vdesk_display_number}}.service + name: vncserver@:{{home_vncserver_display_number}}.service state: started enabled: true scope: user - when: home_vdesk_started_and_enabled + when: home_vncserver_started_and_enabled diff --git a/tasks/vnc.yaml b/tasks/vnc.yaml index 434fb9f..8676edd 100644 --- a/tasks/vnc.yaml +++ b/tasks/vnc.yaml @@ -45,6 +45,6 @@ - name: vnc xsession script template: - src: x11/xsession.j2 + src: vnc/xsession.j2 dest: ~/.vnc/xsession mode: 0755 diff --git a/templates/i3/i3.null.config.j2 b/templates/i3/i3.null.config.j2 new file mode 100644 index 0000000..30dad45 --- /dev/null +++ b/templates/i3/i3.null.config.j2 @@ -0,0 +1,15 @@ +{{ ansible_managed | comment }} + +# i3 config file (v4) +# +# Please see http://i3wm.org/docs/userguide.html for a complete reference! + +font pango:monospace 10 + +bar { + mode invisible +} + +default_border none +hide_edge_borders both +workspace_layout tabbed diff --git a/templates/vnc/vncserver.service.j2 b/templates/vnc/vncserver.service.j2 index de2fabe..deea768 100644 --- a/templates/vnc/vncserver.service.j2 +++ b/templates/vnc/vncserver.service.j2 @@ -20,7 +20,6 @@ After=syslog.target network.target [Service] Type=forking -ExecStartPre=/usr/bin/vncserver -kill %i ExecStart=/usr/bin/vncserver %i ExecStop=/usr/bin/vncserver -kill %i diff --git a/templates/vnc/xsession.j2 b/templates/vnc/xsession.j2 new file mode 100644 index 0000000..29ed55a --- /dev/null +++ b/templates/vnc/xsession.j2 @@ -0,0 +1,5 @@ +#!/bin/sh + +{{ansible_managed|comment}} + +exec systemctl --user start --wait xsession.target diff --git a/templates/workspaces/workspace.space.fish.j2 b/templates/workspaces/workspace.space.fish.j2 index 1e4bfd2..024e7aa 100644 --- a/templates/workspaces/workspace.space.fish.j2 +++ b/templates/workspaces/workspace.space.fish.j2 @@ -3,7 +3,7 @@ {% if workspaces[workspace].type == "vdesk" %} -xtigervncviewer localhost:{{workspaces[workspace].display|default(home_vdesk_display_number)}} -via {{workspaces[workspace].host}} -PasswordFile ~/.vnc/passwd.{{workspaces[workspace].host}} +xtigervncviewer localhost:{{workspaces[workspace].display|default(home_vncserver_display_number)}} -via {{workspaces[workspace].host}} -PasswordFile ~/.vnc/passwd.{{workspaces[workspace].host}} {% elif workspaces[workspace].type == "tmux" %} diff --git a/templates/x11/xsession.j2 b/templates/x11/xsession.j2 index 29ed55a..39b9e14 100644 --- a/templates/x11/xsession.j2 +++ b/templates/x11/xsession.j2 @@ -2,4 +2,10 @@ {{ansible_managed|comment}} +{% if not home_xsession_vncviewer %} 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 +{% endif %}