1import platform
2from pathlib import Path
3from sys import exit, stderr
4
5from xdg import BaseDirectory # type: ignore
6
7
8def error(msg: str) -> None:
9 print(f"Error: {msg}", file=stderr)
10
11
12def user_data_dir() -> Path:
13 if platform.system() == "Linux":
14 return Path(BaseDirectory.xdg_data_home) / "qutebrowser"
15 if platform.system() == "Darwin":
16 return Path.home() / "Library" / "Application Support" / "qutebrowser"
17 error("This operation is only implemented for linux and macOS.")
18 print(
19 "If you're interested in adding support for another OS, send a PR "
20 "to github.com/pvsr/qpm adding the location of qutebrowser data such "
21 "as history.sqlite on your OS to user_data_dir() in qpm/utils.py.",
22 file=stderr,
23 )
24 exit(1)
25
26
27def user_config_dir() -> Path:
28 return Path(BaseDirectory.xdg_config_home) / "qutebrowser"