Skip to content

Instantly share code, notes, and snippets.

@Bouni
Last active June 13, 2022 11:50
Show Gist options
  • Select an option

  • Save Bouni/cf1e5fde1d35ddd71f98d12781353897 to your computer and use it in GitHub Desktop.

Select an option

Save Bouni/cf1e5fde1d35ddd71f98d12781353897 to your computer and use it in GitHub Desktop.
import json
import os
import re
appdata = os.getenv("appdata")
basepath = os.path.join(appdata, "kicad", "6.99")
jsonpath = os.path.join(basepath, "kicad_common.json")
fplibpath = os.path.join(basepath, "fp-lib-table")
symlibpath = os.path.join(basepath, "sym-lib-table")
with open(jsonpath) as f:
j = json.load(f)
if "EASYEDA2KICAD" in j["environment"]["vars"]:
print("EASYEDA2KICAD env var already set")
else:
print("EASYEDA2KICAD env var not set!")
with open(fplibpath) as f:
match = re.search(r"EASYEDA2KICAD", f.read())
if "EASYEDA2KICAD" in j["environment"]["vars"]:
print("EASYEDA2KICAD footprint lib already set")
else:
print("EASYEDA2KICAD footprint lib not set!")
with open(symlibpath) as f:
match = re.search(r"EASYEDA2KICAD", f.read())
if "EASYEDA2KICAD" in j["environment"]["vars"]:
print("EASYEDA2KICAD symbol lib already set")
else:
print("EASYEDA2KICAD symbol lib not set!")
@Bouni
Copy link
Author

Bouni commented Jun 7, 2022

Known issues:

  • Is Kicad always installed on drive C: !?
  • Whats the version number, 6.0 or 6.99 !? Add for both!?
  • Figure out how to do this for other platforms, linux -> easy, MacOS -> no clue, Flatpack etc -> pain in the ass

@uPesy
Copy link

uPesy commented Jun 7, 2022

Whats the version number, 6.0 or 6.99 !? Add for both!? -> Ideally, for all kicad version
Is Kicad always installed on drive C: !? -> if it's fail to do it automatically, the user will be warned and must do it manually

@Bouni
Copy link
Author

Bouni commented Jun 7, 2022

Maybe you could create some kind of install script that has a wizard which guides the user throug the process and asks for the correct values!?

@Bouni
Copy link
Author

Bouni commented Jun 7, 2022

Is Kicad always installed on drive C: !?

Actually this doesnt matter as the Roaming directory is always at the same place and can be looked up using the env var %appdata%!

@Bouni
Copy link
Author

Bouni commented Jun 7, 2022

Just updated the head of the script to use the appdata env var

@uPesy
Copy link

uPesy commented Jun 7, 2022

That's really great !
But works only for Windows. I don't know how are located files in linux os.

@Bouni
Copy link
Author

Bouni commented Jun 7, 2022

Let me see if I can figure that out, but need to waid for the lunch break to do that 😅

@uPesy
Copy link

uPesy commented Jun 7, 2022

Sure :)

@Bouni
Copy link
Author

Bouni commented Jun 7, 2022

I just create a Ubuntu VM and installed Kicad 6.0, there the config path is ~/.config/kicad/6.0/ and the 3 files are in there.

@uPesy
Copy link

uPesy commented Jun 7, 2022

Okay thanks a lot !

@ayourk
Copy link

ayourk commented Jun 10, 2022

I just create a Ubuntu VM and installed Kicad 6.0, there the config path is ~/.config/kicad/6.0/ and the 3 files are in there.

That only works for Kicad versions 6.x+ Kicad 5.x uses something different. Also, I think Kicad 6.x+ uses ~/.local/share/kicad/6.0/* by default.

@Bouni
Copy link
Author

Bouni commented Jun 13, 2022

@ayourk this maybe differs between distros 🤔

@ayourk
Copy link

ayourk commented Jun 13, 2022

I do have both a ~/.config/kicad/6.0/ and a ~/.local/share/kicad/6.0/. Maybe I'm confusing the 2?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment