Skip to content

Commit 1adcc00

Browse files
committed
Added configuration instructions to README
Mostly copied from Emulsion website.
1 parent 3c0305a commit 1adcc00

File tree

1 file changed

+327
-4
lines changed

1 file changed

+327
-4
lines changed

README.md

Lines changed: 327 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,9 @@
11
## Alloy
2+
23
Image viewer based on (now-discontinued) [Emulsion].
34

45
Alloy targets Windows, Mac, and Linux (with more targets to come!).
56

6-
A note for Linux users: Wayland support is limited (for now), so for example
7-
expect high CPU usage and the title text not being shown. However X is fully
8-
supported.
9-
107
Releases will be made as needed, with no set schedule. Merging of bugfix PRs
118
will warrant an immediate new release. Related features may be grouped together
129
in a release.
@@ -36,6 +33,332 @@ Alloy is not currently distributed officially on crates.io or through GitHub
3633
releases (for Mac and Windows) and Flathub (for Linux), but will be in the
3734
future.
3835

36+
## Configuration
37+
38+
The `config.toml` file allows for some modifications in the behaviour of
39+
alloy.
40+
41+
Depending on the platform, this file can be created at one of the following
42+
locations.
43+
44+
- Windows: `%appdata%\Alloy\config\config.toml`
45+
- MacOS: `$HOME/Library/Application Support/Alloy/config.toml`
46+
- Linux: `$XDG_CONFIG_HOME/alloy/config.toml` or `$HOME/.config/alloy/config.toml`
47+
48+
The contents of the `config.toml` file may for example be the following:
49+
50+
```toml
51+
[window]
52+
title_folders = 1
53+
start_fullscreen = true
54+
55+
[bindings]
56+
img_next = ["k"]
57+
img_prev = ["j"]
58+
```
59+
60+
All sections in this file are optional, meaning that if for example only
61+
`[window]` is specified then every other section will be using their default
62+
values.
63+
64+
## Section `[window]`
65+
66+
Field name | Default | Description
67+
--------------|------------|-------------------------------------------------
68+
title_folders | `0` | Number of folders from the path to display in title
69+
mode | `"Normal"` | Window mode to start: `"Fullscreen"` / `"Maximized"`
70+
71+
## Section `[image]`
72+
73+
Field name | Type | Default | Description
74+
-------------|------------------|---------|------------
75+
scaling | unsigned integer | `0` | Number of folders from the path to display in the title.
76+
antialiasing | `true`, `false` | `false` | If true, startup in full-screen mode.
77+
78+
## Section `[bindings]`
79+
80+
Input bindings can be overridden in this section. These are the default
81+
values:
82+
83+
```toml
84+
img_next = ["d", "right", "pagedown"]
85+
img_prev = ["a", "left", "pageup"]
86+
img_orig = ["q", "1"]
87+
img_fit_best = ["e"]
88+
img_fit = ["f"]
89+
img_del = ["delete"]
90+
img_copy = ["cmdctrl+C"]
91+
92+
pan = ["space"]
93+
play_anim = ["alt+a", "alt+v"]
94+
play_present = ["p"]
95+
play_present_rnd = ["alt+p"]
96+
toggle_fullscreen = ["F11", "return"]
97+
toggle_antialias = ["s"]
98+
automatic_antialias = ["alt+s"]
99+
escape = ["Escape"]
100+
101+
# Zoom and pan the camera using keyboard input
102+
# (Not bound by default)
103+
zoom_in = []
104+
zoom_out = []
105+
pan_left = []
106+
pan_right = []
107+
pan_up = []
108+
pan_down = []
109+
```
110+
111+
Note that all items in this section are optional so it’s fully valid to only
112+
specify one of the actions. In this case all the rest will use the default
113+
bindings. For example
114+
115+
```toml
116+
[bindings]
117+
img_next = ["space", "right"]
118+
pan = []
119+
```
120+
121+
The names of the actions are case sensitive but the input strings are not.
122+
123+
It is valid to specify an empty array like `img_del = []` in which case the
124+
action will never be triggered.
125+
126+
A config file with bindings will look like the following.
127+
128+
```toml
129+
[bindings]
130+
img_next = ["d", "right"]
131+
img_prev = ["a", "left"]
132+
img_orig = ["q"]
133+
img_fit = ["f"]
134+
img_del = ["delete"]
135+
pan = ["space"]
136+
play_anim = ["alt+a", "alt+v"]
137+
play_present = ["p"]
138+
play_present_rnd = ["alt+p"]
139+
```
140+
141+
Modifiers may be specified separated by `+` characters. For example `"ctrl+x"`
142+
or `"ctrl+alt+u"`. Spaces are trimmed from each element and so `" ctrl+ x"` or
143+
`"ctrl + alt+u "` are equally valid.
144+
145+
The following modifiers are valid:
146+
147+
- `alt`: The Alt key
148+
- `ctrl`: The Control key
149+
- `logo`: The Command key on macOS; the Windows key on Windows
150+
- `cmdctrl`: The Command key on macOS; the Control key elsewhere
151+
152+
There are a few special cases for typeable characters:
153+
154+
- `' '` must be specified as `space`
155+
- `'+'` must be specified as `add`
156+
- `'-'` must be specified as `subtract`
157+
158+
The following list contains all supported non-typeable key names.
159+
160+
```toml
161+
# The Escape key
162+
Escape,
163+
164+
F1,
165+
F2,
166+
F3,
167+
F4,
168+
F5,
169+
F6,
170+
F7,
171+
F8,
172+
F9,
173+
F10,
174+
F11,
175+
F12,
176+
F13,
177+
F14,
178+
F15,
179+
F16,
180+
F17,
181+
F18,
182+
F19,
183+
F20,
184+
F21,
185+
F22,
186+
F23,
187+
F24,
188+
189+
# Print Screen/SysRq
190+
Snapshot,
191+
# Scroll Lock
192+
Scroll,
193+
#Pause/Break key, next to Scroll lock
194+
Pause,
195+
196+
# `Insert`, next to Backspace
197+
Insert,
198+
Home,
199+
Delete,
200+
End,
201+
PageDown,
202+
PageUp,
203+
204+
Left,
205+
Up,
206+
Right,
207+
Down,
208+
209+
Back,
210+
# The Enter key
211+
Return,
212+
213+
# The "Compose" key on Linux
214+
Compose,
215+
216+
Numlock,
217+
Numpad0,
218+
Numpad1,
219+
Numpad2,
220+
Numpad3,
221+
Numpad4,
222+
Numpad5,
223+
Numpad6,
224+
Numpad7,
225+
Numpad8,
226+
Numpad9,
227+
228+
Apps,
229+
Ax,
230+
Calculator,
231+
Capital,
232+
Convert,
233+
Decimal,
234+
Kana,
235+
Kanji,
236+
LAlt,
237+
LControl,
238+
LShift,
239+
LWin,
240+
Mail,
241+
MediaSelect,
242+
MediaStop,
243+
Mute,
244+
MyComputer,
245+
NavigateForward, # also called "Prior"
246+
NavigateBackward, # also called "Next"
247+
NextTrack,
248+
NoConvert,
249+
OEM102,
250+
PlayPause,
251+
Power,
252+
PrevTrack,
253+
RAlt,
254+
RControl,
255+
RShift,
256+
RWin,
257+
Sleep,
258+
Stop,
259+
Sysrq,
260+
Unlabeled,
261+
VolumeDown,
262+
VolumeUp,
263+
Wake,
264+
WebBack,
265+
WebFavorites,
266+
WebForward,
267+
WebHome,
268+
WebRefresh,
269+
WebSearch,
270+
WebStop,
271+
Yen,
272+
Copy,
273+
Paste,
274+
Cut,
275+
```
276+
277+
## Commands
278+
279+
Any number of `[[commands]]` sections may exist.
280+
281+
To add a shortcut for opening the current image with Gimp on Windows, add the
282+
following:
283+
284+
```toml
285+
# Note the double brackets!
286+
[[commands]]
287+
input = ["alt+t", "u"]
288+
program = "cmd"
289+
# Note that the Gimp exe path is between single quotation marks (')
290+
args = ["/C", "start", "", 'C:\Program Files\GIMP 2\bin\gimp-2.10.exe', "${img}"]
291+
```
292+
293+
A very simple command might look like the one below.
294+
295+
```toml
296+
# Note the double brackets!
297+
[[commands]]
298+
input = ["alt+k"]
299+
program = "git"
300+
```
301+
302+
With the above added to the `config.toml` file, whenever the `alt+k` key
303+
combination is pressed, alloy executes git which prints the default git cli
304+
help message to the standard output. As you can see input is an array, meaning
305+
that a single command can be bound to any number of different inputs. See the
306+
bindings section for more on specifying inputs.
307+
308+
Any command is only executed when there’s an image open.
309+
310+
It’s important that alloy doesn’t execute these commands in a particular shell.
311+
This means that many programs which are available from your preferred command
312+
line interface, are not available to alloy. With that said it is possible to
313+
execute shell commands if we specify the shell as the program itself. For
314+
example the following will print “Hello World” to the “hello.txt” file when
315+
executed from Windows.
316+
317+
```toml
318+
[[commands]]
319+
input = ["alt+k"]
320+
program = "cmd"
321+
args = ["/C", "echo Hello World > hello.txt"]
322+
```
323+
324+
As it was previously stated, any number of `[[commands]]` can be specified.
325+
326+
```toml
327+
[[commands]]
328+
input = ["alt+k"]
329+
program = "git"
330+
331+
# Every command definition must start with [[commands]], even
332+
# if the previous section was also a [[commands]] section.
333+
[[commands]]
334+
input = ["alt+l"]
335+
program = "git"
336+
args = ["status"]
337+
```
338+
339+
There are two more parameters for each command.
340+
341+
- `args`: an array of arguments passed on to the program
342+
- `envs`: an array of environment variable definitions
343+
344+
Within the args, one may use `${img}` and `${folder}` for the currently open
345+
image file path and its parent folder path respectively. Note that these are
346+
substituted with a simple find and replace so there’s no need to escape dollar
347+
signs ($) and they have to be typed in the exact format specified here.
348+
349+
The following example specifies a single environment variable and invokes cmd
350+
with three command line arguments.
351+
352+
```toml
353+
[[commands]]
354+
input = ["alt+t", "u"]
355+
program = "cmd"
356+
args = ["/C", "echo", "%TEST_VAR% ${img}"]
357+
envs = [{name = "TEST_VAR", value = "Wohoo :D"}]
358+
```
359+
360+
This might for example print: `Wohoo :D \\?\D:\MyImages\mountain.jpg`
361+
39362
## Reporting Bugs
40363

41364
If Alloy closes unexpectedly please locate the `"panic.txt"` file. This file has

0 commit comments

Comments
 (0)