Created
December 17, 2025 02:05
-
-
Save ysard/e45e03845a826896d592b840c1eb3c29 to your computer and use it in GitHub Desktop.
Filter Firefox profiles for Profile-Sync-Daemon (PSD)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env python3 | |
| """ | |
| Search Firefox profiles that are only enabled for Profile-Sync-Daemon (PSD) | |
| Installation: Put this script into this folder: $HOME/.mozilla/firefox/ | |
| Usage from shell: eval "$(python /tmp/test.py)" | |
| Usage in profiles.ini: Set IsPsdEnabled=1/true/yes to enable PSD on this profile, | |
| set 0/false/no or nothing to disable PSD on this profile. | |
| Modify /usr/share/psd/browsers/firefox internal loop with: | |
| eval "$(python $HOME/.mozilla/firefox/psd_wrapper.py)" | |
| WARNING: shutdown the service before: | |
| $ systemctl stop --user psd.service | |
| """ | |
| import configparser | |
| from pathlib import Path | |
| FIREFOX_PROFILE_PATH = ".mozilla/firefox/" | |
| profile_ini_path = Path.home() / FIREFOX_PROFILE_PATH / "profiles.ini" | |
| config = configparser.ConfigParser() | |
| config.read(profile_ini_path) | |
| enabled_profiles = [] | |
| for section in config.sections(): | |
| cfg_section = config[section] | |
| if "IsPsdEnabled" in cfg_section: | |
| # print(section, cfg_section["IsPsdEnabled"]) | |
| # By default, if IsPsdEnabled is not set, the profile will not be supported | |
| if not cfg_section.getboolean("IsPsdEnabled") or not "Path" in cfg_section: | |
| continue | |
| # We need the absolute path of the profile | |
| profile_path = Path(cfg_section["Path"]) | |
| if not profile_path.is_relative_to("/"): | |
| profile_path = Path.home() / FIREFOX_PROFILE_PATH / profile_path | |
| # print("=>", profile_path) | |
| enabled_profiles.append(str(profile_path)) | |
| # print(enabled_profiles) | |
| print("DIRArr=(" + " ".join(f'"{path}"' for path in enabled_profiles) + ")") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment