Skip to content

Commit cfbdc62

Browse files
committed
devices widget: open file manager on dispvm block attach
Uses new_dispvm.log for logging, consistent with existing patterns in the codebase. Fixes QubesOS/qubes-issues#10709
1 parent d56bb9e commit cfbdc62

1 file changed

Lines changed: 30 additions & 0 deletions

File tree

qui/devices/actionable_widgets.py

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,13 @@
2626
import asyncio
2727
import functools
2828
import pathlib
29+
import logging
2930
from typing import Iterable, Callable, Optional, List
3031

3132
import qubesadmin
3233
import qubesadmin.devices
3334
import qubesadmin.vm
35+
from qubesadmin import exc
3436

3537
import gi
3638

@@ -40,6 +42,8 @@
4042
from . import backend
4143
import time
4244

45+
logger = logging.getLogger(__name__)
46+
4347

4448
def load_icon(icon_name: str, backup_name: str, size: int = 24):
4549
"""Load icon from provided name/path, if available. If not, load backup
@@ -324,6 +328,19 @@ async def widget_action(self, *_args):
324328

325329
self.device.attach_to_vm(backend.VM(new_dispvm))
326330

331+
if self.device.device_class == "block":
332+
try:
333+
new_dispvm.run_service(
334+
"qubes.StartApp+qubes-open-file-manager",
335+
wait=False,
336+
)
337+
except exc.QubesException as ex:
338+
new_dispvm.log.exception(
339+
"Failed to open file manager in %s: %s",
340+
new_dispvm.name,
341+
ex,
342+
)
343+
327344

328345
class DetachAndAttachDisposableWidget(ActionableWidget, VMWithIcon):
329346
"""Detach from all current attachments and attach to new disposable"""
@@ -340,6 +357,19 @@ async def widget_action(self, *_args):
340357

341358
self.device.attach_to_vm(backend.VM(new_dispvm))
342359

360+
if self.device.device_class == "block":
361+
try:
362+
new_dispvm.run_service(
363+
"qubes.StartApp+qubes-open-file-manager",
364+
wait=False,
365+
)
366+
except exc.QubesException as ex:
367+
new_dispvm.log.exception(
368+
"Failed to open file manager in %s: %s",
369+
new_dispvm.name,
370+
ex,
371+
)
372+
343373

344374
class ToggleFeatureItem(ActionableWidget, SimpleActionWidget):
345375
def __init__(

0 commit comments

Comments
 (0)