Skip to content

Instantly share code, notes, and snippets.

@michaelbehan
Created December 23, 2022 14:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save michaelbehan/6d65ff4c7b934ada13d547b8df9a2fee to your computer and use it in GitHub Desktop.
Save michaelbehan/6d65ff4c7b934ada13d547b8df9a2fee to your computer and use it in GitHub Desktop.
Firefox Profile Launcher
"""
Firefox profile launcher.
Setup:
python3 -m pip install PySimpleGUI
Usage: python3 ./firefox_profile.py
"""
import os
import sys
import PySimpleGUI as sg
firefox = os.path.join(
os.environ["PROGRAMFILES"],
"Mozilla Firefox",
"firefox.exe"
)
profiles_directory = os.path.join(
os.environ["APPDATA"], "Mozilla", "Firefox", "Profiles"
)
profiles = []
profile_buttons = []
if not os.path.exists(firefox):
layout = [[sg.Text("Firefox not found")], [sg.Button("QUIT")]]
elif os.path.isdir(profiles_directory):
for directory in os.listdir(profiles_directory):
profile = directory.split(".")[1]
profiles.append(profile)
profile_buttons.append(sg.Button(profile))
layout = [[sg.Text("Please select a profile:")], profile_buttons]
else:
layout = [
[sg.Text("Firefox profile folder not found")],
[sg.Button("QUIT")]
]
window = sg.Window("Firefox Profiles", layout)
while True:
event, values = window.read()
if event == "QUIT" or event == sg.WIN_CLOSED:
break
if event in profiles:
command = f"cmd.exe /c & \"{firefox}\" -p \"{event}\""
os.system(command)
break
window.close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment