Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RFE: Allow predefined option sets #218

Closed
mviereck opened this issue Jan 29, 2020 · 4 comments
Closed

RFE: Allow predefined option sets #218

mviereck opened this issue Jan 29, 2020 · 4 comments

Comments

@mviereck
Copy link
Owner

mviereck commented Jan 29, 2020

Coming from #217

@eine wrote:

Actually, I think this would be a nice CLI feature for x11docker:

x11docker --preset interactive_as_root IMAGE

x11docker --preset as_root IMAGE xterm

x11docker --preset interactive_as_root_port5000 IMAGE

x11docker --preset interactive_as_root -p 5000 IMAGE
@mviereck
Copy link
Owner Author

mviereck commented Jan 29, 2020

As a quick shot I've added an experimental option --preset.

It expects a file name as an argument. The file should exist either in $HOME/.config/preset or in the current directory.
The file must contain one line only with the options you'd like to have.
Example:

$ cat  $HOME/.config/x11docker/preset/multimedia
--gpu --pulseaudio --webcam

Run e.g. x11docker --preset multimedia x11docker/check

Edit: Some behaviour must be checked, especially presets with -- in it.
I am not entirely sure about the best location for storage of the preset files. The options are parsed before the host user is checked. $HOME might not be right.

@mviereck
Copy link
Owner Author

I've made some fixes for --.
A preset file like this should work:

-i --user 0 -- -p 5000 --

@eine
Copy link
Contributor

eine commented Jan 29, 2020

I am not entirely sure about the best location for storage of the preset files. The options are parsed before the host user is checked. $HOME might not be right.

Two thoughts:

  • Requiring an absolute path, just as docker's volumes. --preset $(pwd)/filename or --preset $HOME/.config/x11dockerpresets is not so long compared to writing all the args.
  • Allowing multiple lines per file, so that a single file is enough for most use cases.

Hence, the syntax would be x11docker --preset /abs/path/to/file LINENUM.

@mviereck
Copy link
Owner Author

mviereck commented Jan 30, 2020

I've included --preset as a regular option.
From x11docker --help:

     --preset FILE     Read a set of predefined options stored in file FILE.
                       FILE is searched in directory /etc/x11docker/preset,
                       in directory ~/.config/x11docker/preset or absolute.
                       Multiple lines in FILE are allowed. 
                       Comment lines must begin with #

Thanks for your suggestions.
I've decided to keep the setup with one file for each preset. That allows meaningful file names.
Using the predefined folders is possible as well as an absolute path.

Multiple lines are allowed in the preset files. Newlines are just replaced with whitespaces.
That allows a readable preset file with one option per line.

--preset can be specified multiple times and can be combined with regular options.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants