1
0
Fork 0

get-firefox-profiles

This commit is contained in:
dece 2022-08-29 00:20:55 +02:00
parent 38d24bdb33
commit 392727e169

30
get-firefox-profiles.py Executable file
View file

@ -0,0 +1,30 @@
#!/usr/bin/env python3
import re
from argparse import ArgumentParser
from configparser import ConfigParser
from pathlib import Path
profile_section_re = re.compile(r"Profile\d+")
parser = ArgumentParser()
parser.add_argument("-p", "--path", help="get path for a profile name")
args = parser.parse_args()
firefox_dir = Path.home() / ".mozilla" / "firefox"
config = ConfigParser()
config.read(firefox_dir / "profiles.ini")
if profile_name := args.path:
for section in config.sections():
if (
profile_section_re.fullmatch(section)
and config[section]["Name"] == profile_name
):
print(firefox_dir / config[section]["Path"])
break
else:
exit("No profile with this name")
else:
for section in config.sections():
if profile_section_re.fullmatch(section):
print(config[section]["Name"])