From b11817a997a7ec96f051b2affa6c4454cd0ba62c Mon Sep 17 00:00:00 2001 From: jpattWPC Date: Fri, 19 Aug 2022 21:12:03 -0500 Subject: [PATCH] Custom parameter support Add support for custom remote-viewer paramters: https://www.mankier.com/1/remote-viewer --- vdiclient.ini.example | 9 +++++++++ vdiclient.py | 10 +++++++++- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/vdiclient.ini.example b/vdiclient.ini.example index c842d9e..b1b2dd1 100644 --- a/vdiclient.ini.example +++ b/vdiclient.ini.example @@ -40,3 +40,12 @@ pve1.example.com = 8006 # 1. Use the inidebug and read the current proxy=pve1.example.com:3128 # 2. Add your proxmox ip to the right side e.g. 123.123.123.123:6000 pve1.example.com:3128 = 123.123.123.123:6000 + +#[AdditionalParameters] +# If you wish to define additional parameters to pass to virt-viewer you may define them here +# More parameter definitions here: https://www.mankier.com/1/remote-viewer +# Some Examples: +# Enable USB passthrough +#enable-usbredir = true +# Enable auto USB device sharing +#enable-usb-autoshare = true diff --git a/vdiclient.py b/vdiclient.py index 4a227d1..0fbefb3 100644 --- a/vdiclient.py +++ b/vdiclient.py @@ -36,6 +36,7 @@ class G: verify_ssl = True icon = None inidebug = False + addl_params = None theme = 'LightBlue' def get_dpi(): @@ -140,6 +141,10 @@ def loadconfig(config_location = None): if 'SpiceProxyRedirect' in config: for key in config['SpiceProxyRedirect']: G.spiceproxy_conv[key] = config['SpiceProxyRedirect'][key] + if 'AdditionalParameters' in config: + G.addl_params = {} + for key in config['AdditionalParameters']: + G.addl_params[key] = config['AdditionalParameters'][key] return True def win_popup(message): @@ -263,7 +268,7 @@ def vmaction(vmnode, vmid, vmtype): spiceconfig = G.proxmox.nodes(vmnode).lxc(str(vmid)).spiceproxy.post() confignode = ConfigParser() confignode['virt-viewer'] = {} - for key,value in spiceconfig.items(): + for key, value in spiceconfig.items(): if key == 'proxy': val = value[7:].lower() if val in G.spiceproxy_conv: @@ -272,6 +277,9 @@ def vmaction(vmnode, vmid, vmtype): confignode['virt-viewer'][key] = f'{value}' else: confignode['virt-viewer'][key] = f'{value}' + if G.addl_params: + for key, value in G.addl_params.items(): + confignode['virt-viewer'][key] = f'{value}' inifile = StringIO('') confignode.write(inifile) inifile.seek(0)