3131import qubesadmin
3232import qubesadmin .devices
3333import qubesadmin .vm
34+ from qubesadmin import exc
3435
3536import gi
3637
4142import time
4243
4344
45+
4446def load_icon (icon_name : str , backup_name : str , size : int = 24 ):
4547 """Load icon from provided name/path, if available. If not, load backup
4648 icon. If icon not found in any of the above ways, load a blank icon of
@@ -324,6 +326,19 @@ async def widget_action(self, *_args):
324326
325327 self .device .attach_to_vm (backend .VM (new_dispvm ))
326328
329+ if self .device .device_class == "block" :
330+ try :
331+ new_dispvm .run_service (
332+ "qubes.StartApp+qubes-open-file-manager" ,
333+ wait = False ,
334+ )
335+ except exc .QubesException as ex :
336+ new_dispvm .log .exception (
337+ "Failed to open file manager in %s: %s" ,
338+ new_dispvm .name ,
339+ ex ,
340+ )
341+
327342
328343class DetachAndAttachDisposableWidget (ActionableWidget , VMWithIcon ):
329344 """Detach from all current attachments and attach to new disposable"""
@@ -340,6 +355,19 @@ async def widget_action(self, *_args):
340355
341356 self .device .attach_to_vm (backend .VM (new_dispvm ))
342357
358+ if self .device .device_class == "block" :
359+ try :
360+ new_dispvm .run_service (
361+ "qubes.StartApp+qubes-open-file-manager" ,
362+ wait = False ,
363+ )
364+ except exc .QubesException as ex :
365+ new_dispvm .log .exception (
366+ "Failed to open file manager in %s: %s" ,
367+ new_dispvm .name ,
368+ ex ,
369+ )
370+
343371
344372class ToggleFeatureItem (ActionableWidget , SimpleActionWidget ):
345373 def __init__ (
0 commit comments