lbonn / i3-quickterm

A small drop-down terminal for i3 and sway
MIT License
128 stars 13 forks source link

could create a default config on first run #15

Closed RafalSkolasinski closed 8 months ago

RafalSkolasinski commented 4 years ago

Just found your project, looks pretty cool! Though, when trying to run it for the first time it complains about lack of json config.

invalid config file: [Errno 2] No such file or directory: '/home/rskolasinski/.config/i3/i3-quickterm.json'
Traceback (most recent call last):
  File "./i3-quickterm", line 243, in <module>
    toggle_quickterm_select(conf)
  File "./i3-quickterm", line 188, in toggle_quickterm_select
    toggle_quickterm(conf, shell)
  File "./i3-quickterm", line 212, in toggle_quickterm
    os.execvp(term_cmd[0], term_cmd)
  File "/usr/lib/python3.7/os.py", line 572, in execvp
    _execvpe(file, args)
  File "/usr/lib/python3.7/os.py", line 614, in _execvpe
    raise last_exc
  File "/usr/lib/python3.7/os.py", line 605, in _execvpe
    exec_func(fullname, *argrest)
FileNotFoundError: [Errno 2] No such file or directory

maybe it would be a good idea to create that with default value?

RafalSkolasinski commented 4 years ago

Okay, lack of default config is not the root of error above, that was because default term is urxvt and that one I do not have installed : - )...

Still could consider writing a default config file if it does not exist.

lbonn commented 4 years ago

Thanks for your feedback!

The first step could be a clearer error message when the currently configured terminal emulator is not in $PATH. It should not be too hard to do.

Concerning the configuration, the defaults are taken from the program itself and then merged with the keys redefined by the user. Maybe that hurts discoverability (hence your issue), but one of the advantage is that defaults can be changed without having to update the local configurations in most cases.

Another common pattern is to supply a configuration file with all the default values commented-out, ready to be customized. But as json doesn't officially have comments, we would probably have to change the format and break existing configs.

lbonn commented 8 months ago

I have added an auto terminal detection with a proper error message in https://github.com/lbonn/i3-quickterm/commit/6cf0e5caf6519ac11b7a7b406b66a5bd9fb197e7