@@ -161,6 +161,20 @@ function printMenu() {
161161 echo " -------- pause | bash=$XBAR_PLUGIN param1=pauseContainer param2=$name param3=$container terminal=false refresh=true"
162162 echo " -------- unpause | bash=$XBAR_PLUGIN param1=unpauseContainer param2=$name param3=$container terminal=false refresh=true"
163163 done
164+ for stopped in $( vmContainers ' Created' )
165+ do
166+ echo " ---- $stopped "
167+ echo " ------ Stopped"
168+ echo " -------- rm | bash=$XBAR_PLUGIN param1=rmContainer param2=$name param3=$stopped terminal=false refresh=true"
169+ echo " -------- start | bash=$XBAR_PLUGIN param1=startContainer param2=$name param3=$stopped terminal=false refresh=true"
170+ done
171+ for stopped in $( vmContainers ' Exited' )
172+ do
173+ echo " ---- $stopped "
174+ echo " ------ Stopped"
175+ echo " -------- rm | bash=$XBAR_PLUGIN param1=rmContainer param2=$name param3=$stopped terminal=false refresh=true"
176+ echo " -------- start | bash=$XBAR_PLUGIN param1=startContainer param2=$name param3=$stopped terminal=false refresh=true"
177+ done
164178
165179 echo " -- Images"
166180 for image in $( vmImages)
@@ -189,14 +203,20 @@ function vmContainers() {
189203 export LIMA_INSTANCE=" $VM "
190204 fi
191205 # shellcheck disable=SC2001,SC2046,SC2005
192- containerList=" [$( echo $( lima nerdctl ps --format ' {{json .}},' ) | sed ' s/,$//' ) ]"
206+ containerList=" [$( echo $( lima nerdctl ps -a - -format ' {{json .}},' ) | sed ' s/,$//' ) ]"
193207 # Can have spaces in our data, deal by using base64 (ugly)
194208 for row in $( echo " ${containerList} " | jq -r ' .[] | @base64' ) ; do
195209 _jq () {
196210 echo " ${row} " | base64 --decode | jq -r " ${1} "
197211 }
198212 if [[ $( _jq ' .Status' ) == " $wantedStatus " ]]; then
199- _jq ' .Names'
213+ name=$( _jq ' .Names' )
214+ id=$( _jq ' .ID' )
215+ if [[ " $name " != " " ]]; then
216+ echo " $name "
217+ else
218+ echo " $id "
219+ fi
200220 fi
201221 done
202222}
@@ -253,6 +273,24 @@ function rmImage() {
253273 fi
254274}
255275
276+ function startContainer() {
277+ # arg1 = container
278+ # arg2 = VM
279+ local containerName
280+ local VM
281+ containerName=" $1 "
282+ VM=" $2 "
283+ if [[ " $VM " != ' default' ]]; then
284+ export LIMA_INSTANCE=" $VM "
285+ fi
286+ displayNotification lima " Starting ${containerName} on ${VM} ..."
287+ if lima nerdctl container start " ${containerName} " ; then
288+ displayNotification Lima " Started ${containerName} "
289+ else
290+ displayAlert Lima " Failed to start ${containerName} on ${VM} "
291+ fi
292+ }
293+
256294function stopContainer() {
257295 # arg1 = container
258296 # arg2 = VM
@@ -289,6 +327,24 @@ function killContainer() {
289327 fi
290328}
291329
330+ function rmContainer() {
331+ # arg1 = container
332+ # arg2 = VM
333+ local containerName
334+ local VM
335+ containerName=" $1 "
336+ VM=" $2 "
337+ if [[ " $VM " != ' default' ]]; then
338+ export LIMA_INSTANCE=" $VM "
339+ fi
340+ displayNotification lima " Removing ${containerName} on ${VM} ..."
341+ if lima nerdctl container rm " ${containerName} " ; then
342+ displayNotification Lima " Removed ${containerName} "
343+ else
344+ displayAlert Lima " Failed to remove ${containerName} on ${VM} "
345+ fi
346+ }
347+
292348function pauseContainer() {
293349 # arg1 = container
294350 # arg2 = VM
@@ -333,6 +389,9 @@ function processMenuCommand() {
333389 pull)
334390 pullImage " $3 " " $2 " # pull imagename vmname
335391 ;;
392+ startContainer)
393+ startContainer " $3 " " $2 " # stopContainer containerName VMname
394+ ;;
336395 stopContainer)
337396 stopContainer " $3 " " $2 " # stopContainer containerName VMname
338397 ;;
@@ -342,6 +401,9 @@ function processMenuCommand() {
342401 pauseContainer)
343402 pauseContainer " $3 " " $2 " # pauseContainer containerName VMname
344403 ;;
404+ rmContainer)
405+ rmContainer " $3 " " $2 " # pauseContainer containerName VMname
406+ ;;
345407 unpauseContainer)
346408 unpauseContainer " $3 " " $2 " # unpauseContainer containerName VMname
347409 ;;
0 commit comments