You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+11-1
Original file line number
Diff line number
Diff line change
@@ -2,6 +2,16 @@
2
2
3
3
[Lima](https://github.com/lima-vm/lima) is an alternative to using Docker Desktop on your Mac.
4
4
5
+
## Description
6
+
7
+

8
+
5
9
This plugin is compatible with [xbar](https://xbarapp.com/) and [SwiftBar](https://github.com/swiftbar/SwiftBar), and lets you start and stop lima VMs from the menubar.
6
10
7
-

11
+
## Installation
12
+
13
+
### Dependencies
14
+
15
+
-[xbar](https://xbarapp.com/) - Allows you to make custom menubar apps with just scripts
16
+
17
+
-[jq](https://stedolan.github.io/jq/) - `brew install jq` - Used to parse the output of `limactl`
warnings=$(printf "${warnings}limactl is not in your PATH! - click to get started | color=$STOPPED_VM_COLOR href=https://github.com/lima-vm/lima#getting-started\n")
75
+
depsOK=0
76
+
fi
77
+
if! has jq;then
78
+
warnings=$(printf "${warnings}\njq is not in your PATH! - click for installation instructions | color=$STOPPED_VM_COLOR href=https://stedolan.github.io/jq/download/\n")
79
+
depsOK=0
80
+
fi
81
+
if [[ depsOK -eq 0 ]];then
82
+
echo"🐋 ⛔ | color=$STOPPED_VM_COLOR"
83
+
echo'---'
84
+
echo"$warnings"
85
+
exit 0
86
+
fi
87
+
}
88
+
89
+
functionprintMenuBarIcon() {
69
90
# Bar title
91
+
local menuBarIcon
70
92
menuBarIcon="🐋 ⛔ | color=$STOPPED_VM_COLOR"
71
-
forlimavmin$(limactl list | grep -v 'NAME STATUS SSH ARCH DIR'| awk '{ print $1 }')
93
+
94
+
forvmin$(limactl list --json | jq -r '.status')
72
95
do
73
-
vmstatus=$(limactl list | grep -v 'NAME STATUS SSH ARCH DIR'| grep "$limavm"| awk '{ print $2 }')
74
-
if [[ "$vmstatus"=='Running' ]];then
96
+
if [[ "$vm"=='Running' ]];then
75
97
menuBarIcon="🐋 🏃 | color=$RUNNING_VM_COLOR"
76
98
fi
77
99
done
78
100
echo"$menuBarIcon"
79
101
echo'---'
102
+
}
80
103
81
-
forlimavmin$(limactl list | grep -v 'NAME STATUS SSH ARCH DIR'| awk '{ print $1 }')
104
+
functionprintMenu() {
105
+
warnIfMissingDependencies
106
+
107
+
printMenuBarIcon
108
+
109
+
local name
110
+
local vmstatus
111
+
112
+
forrawin$(limactl list --json)
82
113
do
83
-
vmstatus=$(limactl list | grep -v 'NAME STATUS SSH ARCH DIR'| grep "$limavm"| awk '{ print $2 }')
84
-
if [[ "$vmstatus"=='Running' ]];then
85
-
menuItem="$limavm VM is running - ⛔ | color=$RUNNING_VM_COLOR | bash=$XBAR_PLUGIN param1=stop param2=$limavm terminal=false refresh=true"
114
+
name=$(echo "$raw"| jq -r '.name')
115
+
vmstatus=$(echo "$raw"| jq -r '.status')
116
+
if [[ $vmstatus=='Running' ]];then
117
+
menuItem="$name VM is running - ⛔ | color=$RUNNING_VM_COLOR | bash=$XBAR_PLUGIN param1=stop param2=$name terminal=false refresh=true"
86
118
else
87
-
menuItem="$limavm VM is stopped - ▶️ | color=$STOPPED_VM_COLOR | bash=$XBAR_PLUGIN param1=start param2=$limavm terminal=false refresh=true"
119
+
menuItem="$name VM is stopped - ▶️ | color=$STOPPED_VM_COLOR | bash=$XBAR_PLUGIN param1=start param2=$name terminal=false refresh=true"
0 commit comments