Skip to content

Commit d8a3bb8

Browse files
committed
Add 'start sys-usb' if sys-usb is not running to qui-devices
fixes QubesOS/qubes-issues#7612
1 parent a6af11d commit d8a3bb8

3 files changed

Lines changed: 34 additions & 0 deletions

File tree

qui/devices/actionable_widgets.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -361,6 +361,22 @@ async def widget_action(self, *_args):
361361
)
362362

363363

364+
#### Start sys-usb
365+
366+
367+
class StartSysUsb(ActionableWidget, SimpleActionWidget):
368+
def __init__(self, sysusb: backend.VM, variant: str = "dark"):
369+
super().__init__(
370+
icon_name=sysusb.icon_name,
371+
text="<b>List USB Devices " "(start sys-usb)</b>",
372+
variant=variant,
373+
)
374+
self.sysusb = sysusb
375+
376+
async def widget_action(self, *_args):
377+
self.sysusb.vm_object.start()
378+
379+
364380
#### Configuration-related actions
365381

366382

qui/devices/backend.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,8 @@ def __init__(self, vm: qubesadmin.vm.QubesVM):
5050
self._vm = vm
5151
self.name = vm.name
5252
self.vm_class = vm.klass
53+
self.is_running = True # in most cases, this is just True, unless we're at
54+
# sysusb
5355

5456
def __str__(self):
5557
return self.name

qui/devices/device_widget.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,9 @@ def initialize_vm_data(self):
243243
self.vms.add(wrapped_vm)
244244
if wrapped_vm.is_dispvm_template:
245245
self.dispvm_templates.add(wrapped_vm)
246+
if vm.name == "sys-usb":
247+
self.sysusb = wrapped_vm
248+
self.sysusb.is_running = vm.is_running()
246249
except qubesadmin.exc.QubesException:
247250
# we don't have access to VM state
248251
pass
@@ -424,6 +427,8 @@ def vm_start(self, vm, _event, **_kwargs):
424427
wrapped_vm = backend.VM(vm)
425428
if wrapped_vm.is_attachable:
426429
self.vms.add(wrapped_vm)
430+
if wrapped_vm == self.sysusb:
431+
self.sysusb.is_running = True
427432

428433
for devclass in DEV_TYPES:
429434
try:
@@ -437,6 +442,9 @@ def vm_start(self, vm, _event, **_kwargs):
437442

438443
def vm_shutdown(self, vm, _event, **_kwargs):
439444
wrapped_vm = backend.VM(vm)
445+
if wrapped_vm == self.sysusb:
446+
self.sysusb.is_running = False
447+
440448
self.vms.discard(wrapped_vm)
441449
self.dispvm_templates.discard(wrapped_vm)
442450

@@ -508,6 +516,14 @@ def show_menu(self, _unused, _event):
508516

509517
menu_items.append(device_item)
510518

519+
if not self.sysusb.is_running:
520+
sysusb_item = actionable_widgets.generate_wrapper_widget(
521+
Gtk.MenuItem,
522+
"activate",
523+
actionable_widgets.StartSysUsb(self.sysusb, theme),
524+
)
525+
menu_items.append(sysusb_item)
526+
511527
for item in menu_items:
512528
tray_menu.add(item)
513529

0 commit comments

Comments
 (0)