Skip to content

Commit

Permalink
support XDG for resources (#525), store colour scheme configuration (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
mintty committed Jun 28, 2016
1 parent ba3d71a commit b6ac0fc
Show file tree
Hide file tree
Showing 3 changed files with 68 additions and 11 deletions.
22 changes: 18 additions & 4 deletions docs/mintty.1
Expand Up @@ -577,6 +577,11 @@ from different instances, obviously they can overwrite each other; if
different mintty versions are run (e.g. from cygwin and msys sharing the same
home directory), options may even get dropped from the configuration file.

Additional resource files are used for colour schemes (option ThemeFile,
subdirectory \fIthemes\fP) and wave files (option BellFile, subdirectory \fIsounds\fP)
within the mintty resource directories \fI~/.mintty\fP, \fI~/.config/mintty\fP,
\fI$APPDATA/mintty\fP, \fI/usr/share/mintty\fP.

The following sections explain the settings on each pane of the options
dialog, followed by settings that do not appear in the dialog.
For each setting, its name in the config file is shown in parentheses,
Expand Down Expand Up @@ -606,8 +611,8 @@ Also X11 color names are supported.
\(en \fBCursor\fP (CursorColour=191,191,191)

\(en \fBTheme\fP (ThemeFile=):
The popup offers theme files as stored in the resource directory
\fI~/.mintty/themes\fP for selection as a colour scheme.
The popup offers theme files as stored in a resource subdirectory
\fIthemes\fP for selection as a colour scheme.
The option can also be set to a filename (like D:/.../solarized-light.minttyrc).

.TP
Expand Down Expand Up @@ -1045,8 +1050,8 @@ Mintty can also play wave sounds or frequency beeps.
\fB5\fP : Asterisk
.RE
\(en \fBWave\fP (BellFile=):
The popup offers wave files as stored in the resource directory
\fI~/.mintty/sounds\fP for selection. The option can also be set
The popup offers wave files as stored in a resource subdirectory
\fIsounds\fP for selection. The option can also be set
to a filename (like D:/.../soundfile.wav).
This setting overrides the Bell system sound except No Beep.
.br
Expand Down Expand Up @@ -1331,6 +1336,15 @@ Also X11 color names are supported.
.br
\(en \fBBoldWhite\fP=255,255,255

.TP
\fBDownloaded colour scheme\fP (ColourScheme=)
This setting is not intended for manual configuration. It can store a
colour scheme as downloaded from the Color Scheme Configurator via
drag-and-drop to the Options menu. If the colour scheme is stored
to a colour scheme file, this setting is not used anymore.
See the Tips wiki page \fIhttps://github.com/mintty/mintty/wiki/Tips\fP
about this mechanism.

.TP
\fBBold substitution colour\fP (BoldColour=)
The colour to be used instead of the bold attribute can be configured.
Expand Down
29 changes: 23 additions & 6 deletions src/config.c 100644 → 100755
Expand Up @@ -658,7 +658,7 @@ get_resource_file(wstring sub, wstring res, bool towrite)

char * resfn = path_win_w_to_posix(rf);
free(rf);
fd = open(resfn, towrite ? O_CREAT | O_EXCL | O_WRONLY | O_BINARY : O_RDONLY | O_BINARY);
fd = open(resfn, towrite ? O_CREAT | O_EXCL | O_WRONLY | O_BINARY : O_RDONLY | O_BINARY, 0644);
if (fd >= 0) {
close(fd);
return resfn;
Expand Down Expand Up @@ -1168,7 +1168,6 @@ add_file_resources(control *ctrl, wstring pattern)
if (GetLastError() == ERROR_FILE_NOT_FOUND) // empty valid dir
break;
}
//check also win_bell() and load_theme() !!

while (ok) {
if (ffd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) {
Expand Down Expand Up @@ -1304,8 +1303,8 @@ theme_handler(control *ctrl, int event)
static void
scheme_saver(control *ctrl, int event)
{
wstring theme_name = new_cfg.theme_file;
if (event == EVENT_REFRESH) {
wstring theme_name = new_cfg.theme_file;
enable_widget(ctrl,
*new_cfg.colour_scheme && *theme_name
&& !wcschr(theme_name, L'/') && !wcschr(theme_name, L'\\')
Expand All @@ -1315,9 +1314,27 @@ scheme_saver(control *ctrl, int event)
#ifdef debug_dragndrop
printf("%ls <- <%s>\n", new_cfg.theme_file, new_cfg.colour_scheme);
#endif
if (*new_cfg.colour_scheme && *new_cfg.theme_file) {
// save colour_scheme to theme_file
}
if (*new_cfg.colour_scheme && *theme_name)
if (!wcschr(theme_name, L'/') && !wcschr(theme_name, L'\\')) {
char * sn = get_resource_file(L"themes", theme_name, true);
if (sn) {
// save colour_scheme to theme_file
FILE * thf = fopen(sn, "w");
free(sn);
if (thf) {
char * sch = (char *)new_cfg.colour_scheme;
for (int i = 0; sch[i]; i++) {
if (sch[i] == ';')
sch[i] = '\n';
}
fprintf(thf, "%s", sch);
fclose(thf);

strset(&new_cfg.colour_scheme, "");
enable_widget(store_button, false);
}
}
}
}
}

Expand Down
28 changes: 27 additions & 1 deletion wiki/Tips.md
@@ -1,5 +1,23 @@


## Configuring mintty ##

Mintty supports a number of common places to look for and save its
configuration and resources.

For its configuration file, it reads ```/etc/minttyrc```, ```$APPDATA/mintty/config```,
```~/.config/mintty/config```, ```~/.minttyrc```, in this order.

For resource files to configure a colour scheme or wave file for the bell character,
it looks for subfolders ```themes``` or ```sounds```, respectively, in one
of the directories ```~/.mintty```, ```~/.config/mintty```,
```$APPDATA/mintty```, ```/usr/share/mintty```, whichever is found first.

The ~/.config/mintty folder is the XDG default base directory.
The $APPDATA/mintty folder is especially useful to share common configuration
for various installations of mintty (e.g. cygwin 32/64 Bit, MSYS, Git Bash).


## Using desktop shortcuts to start mintty ##

The Cygwin [setup.exe](http://cygwin.com/setup.exe) package for mintty
Expand Down Expand Up @@ -280,11 +298,19 @@ which loads a configuration file read-only, i.e. configuration changes
are not saved to this file, or with the new setting _ThemeFile_.

In the Options menu, section _Looks_, the _Theme_ popup offers theme files
as stored in the resource directory $HOME/.mintty/themes for selection.
as stored in a resource directory for selection.

There is an excellent colour scheme designer available:
[4bit Terminal Color Scheme Designer](http://ciembor.github.io/4bit/#)
which lets you download a tuned colour scheme (top-right button “Get Scheme”).
Click on the button “Color Scheme Designer” below the Theme field
to open the designer page and start your design. You can either download
the scheme file (“Get Scheme” – “mintty”) or drag-and-drop the download link
directly to the mintty Options menu, to either the Theme field or the
Color Scheme Designer button. You can then click Apply to test the design
and if you like it, you can enter a theme name in the Theme field and then
click the “Store” button to store the colour scheme.

A number of colour schemes have been published for mintty, e.g.
https://github.com/oumu/mintty-color-schemes or
https://github.com/mavnn/mintty-colors-solarized .
Expand Down

0 comments on commit b6ac0fc

Please sign in to comment.