From 92e87b122ea0d6d6e503596b787b302f891257a7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Pierret=20=28fepitre=29?= Date: Wed, 24 Jun 2020 10:51:39 +0200 Subject: [PATCH] Handle KDE with specific arg/desktop file --- Makefile | 1 + etc/qvm-start-daemon-kde.desktop | 8 ++++ etc/qvm-start-daemon.desktop | 1 + qubesadmin/tools/qvm_start_daemon.py | 55 ++++++++++++------------ rpm_spec/qubes-core-admin-client.spec.in | 1 + 5 files changed, 39 insertions(+), 27 deletions(-) create mode 100644 etc/qvm-start-daemon-kde.desktop diff --git a/Makefile b/Makefile index 5f97ebd..5fe4645 100644 --- a/Makefile +++ b/Makefile @@ -12,6 +12,7 @@ install: $(PYTHON) setup.py install -O1 $(PYTHON_PREFIX_ARG) --root $(DESTDIR) install -d $(DESTDIR)/etc/xdg/autostart install -m 0644 etc/qvm-start-daemon.desktop $(DESTDIR)/etc/xdg/autostart/ + install -m 0644 etc/qvm-start-daemon-kde.desktop $(DESTDIR)/etc/xdg/autostart/ install -d $(DESTDIR)/usr/bin ln -sf qvm-start-daemon $(DESTDIR)/usr/bin/qvm-start-gui diff --git a/etc/qvm-start-daemon-kde.desktop b/etc/qvm-start-daemon-kde.desktop new file mode 100644 index 0000000..f9c7f3d --- /dev/null +++ b/etc/qvm-start-daemon-kde.desktop @@ -0,0 +1,8 @@ +[Desktop Entry] +Name=Qubes Guid/Pacat +Comment=Starts GUI/AUDIO daemon for Qubes VMs in KDE +Icon=qubes +Exec=qvm-start-daemon --all --watch --kde +Terminal=false +Type=Application +OnlyShowIn=KDE \ No newline at end of file diff --git a/etc/qvm-start-daemon.desktop b/etc/qvm-start-daemon.desktop index 4bcf4dd..949fb36 100644 --- a/etc/qvm-start-daemon.desktop +++ b/etc/qvm-start-daemon.desktop @@ -5,3 +5,4 @@ Icon=qubes Exec=qvm-start-daemon --all --watch Terminal=false Type=Application +NotShowIn=KDE \ No newline at end of file diff --git a/qubesadmin/tools/qvm_start_daemon.py b/qubesadmin/tools/qvm_start_daemon.py index 7732bd8..fec7ef3 100644 --- a/qubesadmin/tools/qvm_start_daemon.py +++ b/qubesadmin/tools/qvm_start_daemon.py @@ -149,6 +149,7 @@ class DAEMONLauncher: """ self.app = app self.started_processes = {} + self.kde = False @asyncio.coroutine def send_monitor_layout(self, vm, layout=None, startup=False): @@ -215,33 +216,28 @@ class DAEMONLauncher: """Return KDE-specific arguments for gui-daemon, if applicable""" guid_cmd = [] - # Avoid using environment variables for checking the current session, - # because this script may be called with cleared env (like with sudo). - if subprocess.check_output( - ['xprop', '-root', '-notype', 'KWIN_RUNNING']) == \ - b'KWIN_RUNNING = 0x1\n': - # native decoration plugins is used, so adjust window properties - # accordingly - guid_cmd += ['-T'] # prefix window titles with VM name - # get owner of X11 session - session_owner = None - for line in subprocess.check_output(['xhost']).splitlines(): - if line == b'SI:localuser:root': - pass - elif line.startswith(b'SI:localuser:'): - session_owner = line.split(b':')[2].decode() - if session_owner is not None: - data_dir = os.path.expanduser( - '~{}/.local/share'.format(session_owner)) - else: - # fallback to current user - data_dir = os.path.expanduser('~/.local/share') + # native decoration plugins is used, so adjust window properties + # accordingly + guid_cmd += ['-T'] # prefix window titles with VM name + # get owner of X11 session + session_owner = None + for line in subprocess.check_output(['xhost']).splitlines(): + if line == b'SI:localuser:root': + pass + elif line.startswith(b'SI:localuser:'): + session_owner = line.split(b':')[2].decode() + if session_owner is not None: + data_dir = os.path.expanduser( + '~{}/.local/share'.format(session_owner)) + else: + # fallback to current user + data_dir = os.path.expanduser('~/.local/share') - guid_cmd += ['-p', - '_KDE_NET_WM_COLOR_SCHEME=s:{}'.format( - os.path.join(data_dir, - 'qubes-kde', - vm.label.name + '.colors'))] + guid_cmd += ['-p', + '_KDE_NET_WM_COLOR_SCHEME=s:{}'.format( + os.path.join(data_dir, + 'qubes-kde', + vm.label.name + '.colors'))] return guid_cmd def common_guid_args(self, vm): @@ -262,7 +258,6 @@ class DAEMONLauncher: if vm.features.check_with_template('rpc-clipboard', False): guid_cmd.extend(['-Q']) - guid_cmd += self.kde_guid_args(vm) return guid_cmd @staticmethod @@ -295,6 +290,8 @@ class DAEMONLauncher: local X server. """ guid_cmd = self.common_guid_args(vm) + if self.kde: + guid_cmd.extend(self.kde_guid_args(vm)) guid_cmd.extend(['-d', str(vm.xid)]) if vm.virt_mode == 'hvm': @@ -495,6 +492,8 @@ parser.add_argument('--notify-monitor-layout', action='store_true', parser.add_argument('--set-keyboard-layout', action='store_true', help='Set keyboard layout values into GuiVM features.' 'This option is implied by --watch') +parser.add_argument('--kde', action='store_true', + help='Set KDE specific arguments to gui-daemon.') # Add it for the help only parser.add_argument('--force', action='store_true', default=False, help='Force running daemon without enabled services' @@ -521,6 +520,8 @@ def main(args=None): guivm = args.app.domains.get_blind(args.app.local_name) set_keyboard_layout(guivm) launcher = DAEMONLauncher(args.app) + if args.kde: + launcher.kde = True if args.watch: if not have_events: parser.error('--watch option require Python >= 3.5') diff --git a/rpm_spec/qubes-core-admin-client.spec.in b/rpm_spec/qubes-core-admin-client.spec.in index 9b3282f..0e0bb93 100644 --- a/rpm_spec/qubes-core-admin-client.spec.in +++ b/rpm_spec/qubes-core-admin-client.spec.in @@ -53,6 +53,7 @@ make -C doc DESTDIR=$RPM_BUILD_ROOT \ %defattr(-,root,root,-) %doc LICENSE %config /etc/xdg/autostart/qvm-start-daemon.desktop +%config /etc/xdg/autostart/qvm-start-daemon-kde.desktop %{_bindir}/qubes-* %{_bindir}/qvm-* %{_mandir}/man1/qvm-*.1*