@@ -34,7 +34,7 @@ RUNNING_VM_COLOR = "#29cc00"
34
34
# Stopped VM color (default red)
35
35
STOPPED_VM_COLOR = "#ff0033"
36
36
37
- VERSION = "1.2 .0"
37
+ VERSION = "1.3 .0"
38
38
39
39
40
40
def logSetup (level : str = "INFO" ):
@@ -90,7 +90,7 @@ def parseCLI():
90
90
parser .add_argument ("--pull-new-image" , action = "store_true" )
91
91
parser .add_argument (
92
92
"--vm-action" ,
93
- choices = ["start" , "stop" ],
93
+ choices = ["start" , "stop" , "lima" ],
94
94
help = "Action to perform on vm" ,
95
95
)
96
96
cliArgs = parser .parse_args ()
@@ -348,6 +348,28 @@ def imageOps(action: str, image: str, vm: str = "default"):
348
348
displayNotification (title = "Task complete" , message = " " .join (command ))
349
349
350
350
351
+ def limaCommand (vm : str ):
352
+ """
353
+ Run an arbitrary command with lima
354
+
355
+ :param str vm: Which vm to run the command in
356
+ """
357
+ env = prep_environment_for_lima (vm = vm )
358
+ user_command = inputDialog (
359
+ user_prompt = f"What lima command do you want to run in the { vm } VM?"
360
+ )
361
+
362
+ if user_command != "" :
363
+ lima_command = ["lima" ] + user_command .split ()
364
+ displayNotification (
365
+ title = f"Running '{ user_command } '" , message = " " .join (lima_command )
366
+ )
367
+ runCommand (command = lima_command , env = env )
368
+ displayNotification (title = f"Ran '{ user_command } ' in { vm } " , message = "Completed" )
369
+ else :
370
+ displayAlert (title = "Error!" , message = "No nerdctl command specified" )
371
+
372
+
351
373
def vmOps (action : str , vm : str = "default" ):
352
374
"""
353
375
Handle VM operations
@@ -361,13 +383,19 @@ def vmOps(action: str, vm: str = "default"):
361
383
362
384
env = prep_environment_for_lima (vm = vm )
363
385
364
- command = ["limactl" , action , vm ]
365
- logging .warning ("command: %s" , command )
366
- displayNotification (title = "Lima VM" , message = " " .join (command ))
367
- output = runCommand (command = command , env = env )
368
- logging .debug (output )
369
- logging .warning ("%s complete" , action )
370
- displayNotification (title = "Task completed" , message = " " .join (command ))
386
+ if action == "lima" :
387
+ limaCommand (vm = vm )
388
+
389
+ if action in ["start" , "stop" ]:
390
+ command = ["limactl" , action , vm ]
391
+ logging .info ("command: %s" , command )
392
+
393
+ displayNotification (title = "Lima VM" , message = " " .join (command ))
394
+ output = runCommand (command = command , env = env )
395
+ logging .debug (output )
396
+
397
+ logging .info ("%s complete" , action )
398
+ displayNotification (title = "Task completed" , message = " " .join (command ))
371
399
372
400
373
401
def pullNewImage (vm : str = "default" ):
@@ -401,7 +429,7 @@ def xbar_icon(vms: dict = {}):
401
429
402
430
:param dict vms: Data about Lima VMs
403
431
"""
404
- menuBarIcon = f"🐋 ⛔ | color={ STOPPED_VM_COLOR } "
432
+ menuBarIcon = f"🐋❗ | color={ STOPPED_VM_COLOR } "
405
433
for vm in vms :
406
434
logging .debug ("vm: %s" , vm )
407
435
if vms [vm ]["status" ] == "Running" :
@@ -432,7 +460,6 @@ def vmContainerSubMenu(vm: str = "default"):
432
460
433
461
:param str vm:
434
462
"""
435
- # plugin_f = __file__.replace(" ", "\ ")
436
463
plugin_f = __file__
437
464
containers = listContainers (vm = vm )
438
465
@@ -505,12 +532,15 @@ def vmMenu(vmData: dict = {}):
505
532
if vmData [vm ]["status" ] != "Running" :
506
533
print ("%s VM is stopped | color=%s" % (vm , STOPPED_VM_COLOR ))
507
534
print (
508
- f"""-- ⛔ Start { vm } VM | shell=\" { plugin_f } \" param1='--vm=default ' param2='--vm-action=start' terminal=false refresh=true"""
535
+ f"""-- ▶️ Start { vm } VM | shell=\" { plugin_f } \" param1='--vm={ vm } ' param2='--vm-action=start' terminal=false refresh=true"""
509
536
)
510
537
else :
511
538
print (f"{ vm } VM (running) | color={ RUNNING_VM_COLOR } " )
512
539
print (
513
- f"""-- ⛔ Stop { vm } VM | color={ STOPPED_VM_COLOR } bash="{ __file__ } " shell=\" { plugin_f } \" param1='--vm=default' param2='--vm-action=stop' terminal=false refresh=true"""
540
+ f"""-- ❌ Stop { vm } VM | color={ STOPPED_VM_COLOR } shell=\" { plugin_f } \" param1='--vm={ vm } ' param2='--vm-action=stop' terminal=false refresh=true"""
541
+ )
542
+ print (
543
+ f"""-- 🐚 Run lima command | shell=\" { plugin_f } \" param1='--vm={ vm } ' param2='--vm-action=lima' terminal=false refresh=true"""
514
544
)
515
545
vmContainerSubMenu (vm = vm )
516
546
vmImageSubMenu (vm = vm )
0 commit comments