Merge remote-tracking branch 'origin/pr/143'
* origin/pr/143: qvm-start-daemon: common_guid_args is now a staticmethod tests: kde_args are passed with property of launcher Fix missing semi-colon and new line Handle KDE with specific arg/desktop file
This commit is contained in:
		
						commit
						e0f17f1b4a
					
				
							
								
								
									
										1
									
								
								Makefile
									
									
									
									
									
								
							
							
						
						
									
										1
									
								
								Makefile
									
									
									
									
									
								
							| @ -12,6 +12,7 @@ install: | |||||||
| 	$(PYTHON) setup.py install -O1 $(PYTHON_PREFIX_ARG) --root $(DESTDIR) | 	$(PYTHON) setup.py install -O1 $(PYTHON_PREFIX_ARG) --root $(DESTDIR) | ||||||
| 	install -d $(DESTDIR)/etc/xdg/autostart | 	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.desktop $(DESTDIR)/etc/xdg/autostart/ | ||||||
|  | 	install -m 0644 etc/qvm-start-daemon-kde.desktop $(DESTDIR)/etc/xdg/autostart/ | ||||||
| 	install -d $(DESTDIR)/usr/bin | 	install -d $(DESTDIR)/usr/bin | ||||||
| 	ln -sf qvm-start-daemon $(DESTDIR)/usr/bin/qvm-start-gui | 	ln -sf qvm-start-daemon $(DESTDIR)/usr/bin/qvm-start-gui | ||||||
| 
 | 
 | ||||||
|  | |||||||
							
								
								
									
										9
									
								
								etc/qvm-start-daemon-kde.desktop
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										9
									
								
								etc/qvm-start-daemon-kde.desktop
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,9 @@ | |||||||
|  | [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; | ||||||
|  | 
 | ||||||
| @ -5,3 +5,5 @@ Icon=qubes | |||||||
| Exec=qvm-start-daemon --all --watch | Exec=qvm-start-daemon --all --watch | ||||||
| Terminal=false | Terminal=false | ||||||
| Type=Application | Type=Application | ||||||
|  | NotShowIn=KDE; | ||||||
|  | 
 | ||||||
|  | |||||||
| @ -53,6 +53,7 @@ class TC_00_qvm_start_gui(qubesadmin.tests.QubesTestCase): | |||||||
|         ] |         ] | ||||||
| 
 | 
 | ||||||
|         args = self.launcher.kde_guid_args(self.app.domains['test-vm']) |         args = self.launcher.kde_guid_args(self.app.domains['test-vm']) | ||||||
|  |         self.launcher.kde = True | ||||||
|         self.assertEqual(args, ['-T', '-p', |         self.assertEqual(args, ['-T', '-p', | ||||||
|                                 '_KDE_NET_WM_COLOR_SCHEME=s:' + |                                 '_KDE_NET_WM_COLOR_SCHEME=s:' + | ||||||
|                                 os.path.expanduser( |                                 os.path.expanduser( | ||||||
| @ -60,19 +61,6 @@ class TC_00_qvm_start_gui(qubesadmin.tests.QubesTestCase): | |||||||
| 
 | 
 | ||||||
|         self.assertAllCalled() |         self.assertAllCalled() | ||||||
| 
 | 
 | ||||||
|     @unittest.mock.patch('subprocess.check_output') |  | ||||||
|     def test_001_kde_args_none(self, proc_mock): |  | ||||||
|         self.app.expected_calls[ |  | ||||||
|             ('dom0', 'admin.vm.List', None, None)] = \ |  | ||||||
|             b'0\x00test-vm class=AppVM state=Running\n' |  | ||||||
| 
 |  | ||||||
|         proc_mock.side_effect = [b''] |  | ||||||
| 
 |  | ||||||
|         args = self.launcher.kde_guid_args(self.app.domains['test-vm']) |  | ||||||
|         self.assertEqual(args, []) |  | ||||||
| 
 |  | ||||||
|         self.assertAllCalled() |  | ||||||
| 
 |  | ||||||
|     def test_010_common_args(self): |     def test_010_common_args(self): | ||||||
|         self.app.expected_calls[ |         self.app.expected_calls[ | ||||||
|             ('dom0', 'admin.vm.List', None, None)] = \ |             ('dom0', 'admin.vm.List', None, None)] = \ | ||||||
|  | |||||||
| @ -149,6 +149,7 @@ class DAEMONLauncher: | |||||||
|         """ |         """ | ||||||
|         self.app = app |         self.app = app | ||||||
|         self.started_processes = {} |         self.started_processes = {} | ||||||
|  |         self.kde = False | ||||||
| 
 | 
 | ||||||
|     @asyncio.coroutine |     @asyncio.coroutine | ||||||
|     def send_monitor_layout(self, vm, layout=None, startup=False): |     def send_monitor_layout(self, vm, layout=None, startup=False): | ||||||
| @ -215,36 +216,32 @@ class DAEMONLauncher: | |||||||
|         """Return KDE-specific arguments for gui-daemon, if applicable""" |         """Return KDE-specific arguments for gui-daemon, if applicable""" | ||||||
| 
 | 
 | ||||||
|         guid_cmd = [] |         guid_cmd = [] | ||||||
|         # Avoid using environment variables for checking the current session, |         # native decoration plugins is used, so adjust window properties | ||||||
|         #  because this script may be called with cleared env (like with sudo). |         # accordingly | ||||||
|         if subprocess.check_output( |         guid_cmd += ['-T']  # prefix window titles with VM name | ||||||
|                 ['xprop', '-root', '-notype', 'KWIN_RUNNING']) == \ |         # get owner of X11 session | ||||||
|                 b'KWIN_RUNNING = 0x1\n': |         session_owner = None | ||||||
|             # native decoration plugins is used, so adjust window properties |         for line in subprocess.check_output(['xhost']).splitlines(): | ||||||
|             # accordingly |             if line == b'SI:localuser:root': | ||||||
|             guid_cmd += ['-T']  # prefix window titles with VM name |                 pass | ||||||
|             # get owner of X11 session |             elif line.startswith(b'SI:localuser:'): | ||||||
|             session_owner = None |                 session_owner = line.split(b':')[2].decode() | ||||||
|             for line in subprocess.check_output(['xhost']).splitlines(): |         if session_owner is not None: | ||||||
|                 if line == b'SI:localuser:root': |             data_dir = os.path.expanduser( | ||||||
|                     pass |                 '~{}/.local/share'.format(session_owner)) | ||||||
|                 elif line.startswith(b'SI:localuser:'): |         else: | ||||||
|                     session_owner = line.split(b':')[2].decode() |             # fallback to current user | ||||||
|             if session_owner is not None: |             data_dir = os.path.expanduser('~/.local/share') | ||||||
|                 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', |         guid_cmd += ['-p', | ||||||
|                          '_KDE_NET_WM_COLOR_SCHEME=s:{}'.format( |                         '_KDE_NET_WM_COLOR_SCHEME=s:{}'.format( | ||||||
|                              os.path.join(data_dir, |                             os.path.join(data_dir, | ||||||
|                                           'qubes-kde', |                                         'qubes-kde', | ||||||
|                                           vm.label.name + '.colors'))] |                                         vm.label.name + '.colors'))] | ||||||
|         return guid_cmd |         return guid_cmd | ||||||
| 
 | 
 | ||||||
|     def common_guid_args(self, vm): |     @staticmethod | ||||||
|  |     def common_guid_args(vm): | ||||||
|         """Common qubes-guid arguments for PV(H), HVM and Stubdomain""" |         """Common qubes-guid arguments for PV(H), HVM and Stubdomain""" | ||||||
| 
 | 
 | ||||||
|         guid_cmd = [GUI_DAEMON_PATH, |         guid_cmd = [GUI_DAEMON_PATH, | ||||||
| @ -262,7 +259,6 @@ class DAEMONLauncher: | |||||||
|         if vm.features.check_with_template('rpc-clipboard', False): |         if vm.features.check_with_template('rpc-clipboard', False): | ||||||
|             guid_cmd.extend(['-Q']) |             guid_cmd.extend(['-Q']) | ||||||
| 
 | 
 | ||||||
|         guid_cmd += self.kde_guid_args(vm) |  | ||||||
|         return guid_cmd |         return guid_cmd | ||||||
| 
 | 
 | ||||||
|     @staticmethod |     @staticmethod | ||||||
| @ -295,6 +291,8 @@ class DAEMONLauncher: | |||||||
|             local X server. |             local X server. | ||||||
|         """ |         """ | ||||||
|         guid_cmd = self.common_guid_args(vm) |         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)]) |         guid_cmd.extend(['-d', str(vm.xid)]) | ||||||
| 
 | 
 | ||||||
|         if vm.virt_mode == 'hvm': |         if vm.virt_mode == 'hvm': | ||||||
| @ -495,6 +493,8 @@ parser.add_argument('--notify-monitor-layout', action='store_true', | |||||||
| parser.add_argument('--set-keyboard-layout', action='store_true', | parser.add_argument('--set-keyboard-layout', action='store_true', | ||||||
|                     help='Set keyboard layout values into GuiVM features.' |                     help='Set keyboard layout values into GuiVM features.' | ||||||
|                          'This option is implied by --watch') |                          '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 | # Add it for the help only | ||||||
| parser.add_argument('--force', action='store_true', default=False, | parser.add_argument('--force', action='store_true', default=False, | ||||||
|                     help='Force running daemon without enabled services' |                     help='Force running daemon without enabled services' | ||||||
| @ -521,6 +521,8 @@ def main(args=None): | |||||||
|         guivm = args.app.domains.get_blind(args.app.local_name) |         guivm = args.app.domains.get_blind(args.app.local_name) | ||||||
|         set_keyboard_layout(guivm) |         set_keyboard_layout(guivm) | ||||||
|     launcher = DAEMONLauncher(args.app) |     launcher = DAEMONLauncher(args.app) | ||||||
|  |     if args.kde: | ||||||
|  |         launcher.kde = True | ||||||
|     if args.watch: |     if args.watch: | ||||||
|         if not have_events: |         if not have_events: | ||||||
|             parser.error('--watch option require Python >= 3.5') |             parser.error('--watch option require Python >= 3.5') | ||||||
|  | |||||||
| @ -53,6 +53,7 @@ make -C doc DESTDIR=$RPM_BUILD_ROOT \ | |||||||
| %defattr(-,root,root,-) | %defattr(-,root,root,-) | ||||||
| %doc LICENSE | %doc LICENSE | ||||||
| %config /etc/xdg/autostart/qvm-start-daemon.desktop | %config /etc/xdg/autostart/qvm-start-daemon.desktop | ||||||
|  | %config /etc/xdg/autostart/qvm-start-daemon-kde.desktop | ||||||
| %{_bindir}/qubes-* | %{_bindir}/qubes-* | ||||||
| %{_bindir}/qvm-* | %{_bindir}/qvm-* | ||||||
| %{_mandir}/man1/qvm-*.1* | %{_mandir}/man1/qvm-*.1* | ||||||
|  | |||||||
		Loading…
	
		Reference in New Issue
	
	Block a user
	 Marek Marczykowski-Górecki
						Marek Marczykowski-Górecki