Skip to content

Commit 6ca7f73

Browse files
committed
Respect XDG_CONFIG_HOME if set
Signed-off-by: Samir Benmendil <me@rmz.io>
1 parent f42b568 commit 6ca7f73

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

podman_compose.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1746,10 +1746,12 @@ def compose_systemd(compose, args):
17461746
later you can add a compose stack by running `podman-compose -a register`
17471747
then you can start/stop your stack with `systemctl --user start podman-compose@<PROJ>`
17481748
"""
1749-
stacks_dir = ".config/containers/compose/projects"
1749+
config_home = os.environ.get("XDG_CONFIG_HOME", "~/.config")
1750+
config_home = os.path.expanduser(config_home)
1751+
stacks_dir = "containers/compose/projects"
17501752
if args.action == "register":
17511753
proj_name = compose.project_name
1752-
fn = os.path.expanduser(f"~/{stacks_dir}/{proj_name}.env")
1754+
fn = f"{config_home}/{stacks_dir}/{proj_name}.env"
17531755
os.makedirs(os.path.dirname(fn), exist_ok=True)
17541756
print(f"writing [{fn}]: ...")
17551757
with open(fn, "w", encoding="utf-8") as f:
@@ -1783,7 +1785,7 @@ def compose_systemd(compose, args):
17831785
"""
17841786
)
17851787
elif args.action in ("list", "ls"):
1786-
ls = glob.glob(os.path.expanduser(f"~/{stacks_dir}/*.env"))
1788+
ls = glob.glob(f"{config_home}/{stacks_dir}/*.env")
17871789
for i in ls:
17881790
print(os.path.basename(i[:-4]))
17891791
elif args.action == "create-unit":
@@ -1796,7 +1798,7 @@ def compose_systemd(compose, args):
17961798
17971799
[Service]
17981800
Type=simple
1799-
EnvironmentFile=%h/{stacks_dir}/%i.env
1801+
EnvironmentFile=%E/{stacks_dir}/%i.env
18001802
ExecStartPre=-{script} up --no-start
18011803
ExecStartPre=/usr/bin/podman pod start pod_%i
18021804
ExecStart={script} wait

0 commit comments

Comments
 (0)