@@ -161,6 +161,20 @@ function printMenu() {
161
161
echo " -------- pause | bash=$XBAR_PLUGIN param1=pauseContainer param2=$name param3=$container terminal=false refresh=true"
162
162
echo " -------- unpause | bash=$XBAR_PLUGIN param1=unpauseContainer param2=$name param3=$container terminal=false refresh=true"
163
163
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
164
178
165
179
echo " -- Images"
166
180
for image in $( vmImages)
@@ -189,14 +203,20 @@ function vmContainers() {
189
203
export LIMA_INSTANCE=" $VM "
190
204
fi
191
205
# 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/,$//' ) ]"
193
207
# Can have spaces in our data, deal by using base64 (ugly)
194
208
for row in $( echo " ${containerList} " | jq -r ' .[] | @base64' ) ; do
195
209
_jq () {
196
210
echo " ${row} " | base64 --decode | jq -r " ${1} "
197
211
}
198
212
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
200
220
fi
201
221
done
202
222
}
@@ -253,6 +273,24 @@ function rmImage() {
253
273
fi
254
274
}
255
275
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
+
256
294
function stopContainer() {
257
295
# arg1 = container
258
296
# arg2 = VM
@@ -289,6 +327,24 @@ function killContainer() {
289
327
fi
290
328
}
291
329
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
+
292
348
function pauseContainer() {
293
349
# arg1 = container
294
350
# arg2 = VM
@@ -333,6 +389,9 @@ function processMenuCommand() {
333
389
pull)
334
390
pullImage " $3 " " $2 " # pull imagename vmname
335
391
;;
392
+ startContainer)
393
+ startContainer " $3 " " $2 " # stopContainer containerName VMname
394
+ ;;
336
395
stopContainer)
337
396
stopContainer " $3 " " $2 " # stopContainer containerName VMname
338
397
;;
@@ -342,6 +401,9 @@ function processMenuCommand() {
342
401
pauseContainer)
343
402
pauseContainer " $3 " " $2 " # pauseContainer containerName VMname
344
403
;;
404
+ rmContainer)
405
+ rmContainer " $3 " " $2 " # pauseContainer containerName VMname
406
+ ;;
345
407
unpauseContainer)
346
408
unpauseContainer " $3 " " $2 " # unpauseContainer containerName VMname
347
409
;;
0 commit comments