JonnyHaystack/i3-resurrect

~/.i3/i3-resurrect does not exist

teto opened this issue · 4 comments

teto commented

Describe the bug
I just packaged i3-resurrect for nixos, and tried to launch ls as my first command and it failed.

result/bin/i3-resurrect ls                                                                                          ~/nixpkgs
Traceback (most recent call last):
  File "/nix/store/2gjiv1kl57nb1ji9w2gjawiradhqjnxh-i3-resurrect-1.4.3/bin/.i3-resurrect-wrapped", line 9, in <module>
    sys.exit(main())
  File "/nix/store/s27sv0bd4aq9id6qcg18sr2h6g3fmrsy-python3.7-click-7.1.1/lib/python3.7/site-packages/click/core.py", line 829, in __call__
    return self.main(*args, **kwargs)
  File "/nix/store/s27sv0bd4aq9id6qcg18sr2h6g3fmrsy-python3.7-click-7.1.1/lib/python3.7/site-packages/click/core.py", line 782, in main
    rv = self.invoke(ctx)
  File "/nix/store/s27sv0bd4aq9id6qcg18sr2h6g3fmrsy-python3.7-click-7.1.1/lib/python3.7/site-packages/click/core.py", line 1259, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/nix/store/s27sv0bd4aq9id6qcg18sr2h6g3fmrsy-python3.7-click-7.1.1/lib/python3.7/site-packages/click/core.py", line 1066, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/nix/store/s27sv0bd4aq9id6qcg18sr2h6g3fmrsy-python3.7-click-7.1.1/lib/python3.7/site-packages/click/core.py", line 610, in invoke
    return callback(*args, **kwargs)
  File "/nix/store/2gjiv1kl57nb1ji9w2gjawiradhqjnxh-i3-resurrect-1.4.3/lib/python3.7/site-packages/i3_resurrect/main.py", line 141, in list_workspaces
    for entry in directory.iterdir():
  File "/nix/store/lm0w36273v76nnph1518gwbv1g45sl8w-python3-3.7.7/lib/python3.7/pathlib.py", line 1102, in iterdir
    for name in self._accessor.listdir(self):
FileNotFoundError: [Errno 2] No such file or directory: '/home/teto/.i3/i3-resurrect'

Seems like one has to call save/load first.

Expected behavior
no error

Screenshots
If applicable, add screenshots to help explain your problem.

System information (please complete the following information):

  • Linux distribution: www.nixos.org
  • i3-resurrect version (output of i3-resurrect --version): 1.4.c
  • i3 version (output of i3 -v): 4.18

Additional context
Also my i3 config is in $XDG_CONFIG_HOME/i3 (~/.config/i3) so I would prefer i3-resurrect to use that one (or its own ~/.config/i3-resurrect)

Hi, thanks for the bug report.

Seems like one has to call save/load first.

Yeah, I didn't think to handle that potential exception I guess.

Also my i3 config is in $XDG_CONFIG_HOME/i3 (~/.config/i3) so I would prefer i3-resurrect to use that one (or its own ~/.config/i3-resurrect)

i3-resurrect stores its configuration in ~/.config/i3-resurrect. It's just the saved layouts/programs that get stored in ~/.i3/i3-resurrect/. You can change which directory workspaces are saved to by using the -d/--directory option. I've been meaning to add a config file option for that, but I've not had much spare time recently.

teto commented

I see thanks.

I think maybe we should leave this open until I fix the bug 😛

I'm not sure how best to handle it though. I could make it create the directory when using the ls command if it doesn't exist, or I could just give a friendlier error message. It seems like you were expecting it to do the former, so that might be the way to go.

Coming back to this now, I think having an "ls" command create a directory is unintuitive. I also think the current error message thrown by Python itself is informative and friendly enough. It shouldn't break scripts because it's printed to stderr. There will be no output to stdout which is what a script would expect. So I think for now at least I'm going to leave it how it is, because at least it lets a user know if they have mistyped a directory name.