Skip to content

Commit ab0e43d

Browse files
committed
added info about global vars in config in readme
1 parent 92d9b89 commit ab0e43d

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

README.md

+33
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ and copy `dxhd` executable file to somewhere in your `$PATH`
5151
* in-place reloading (`dxhd -r`)
5252
* calculating the time parsing a config file took (`dxhd -p`)
5353
* support for any shell scripting language (sh, bash, ksh, zsh, python, perl etc.) given as a shebang
54+
* support for global variable declarations in a config
5455
* support for scripting, as much as a user wishes!
5556

5657
### Demo
@@ -75,6 +76,8 @@ A dxhd config file should contain a shebang (defaults to `/bin/sh`) on top of a
7576
```
7677
#!/shebang
7778
79+
test=5 # a globally declared variable for each keybinding command
80+
7881
## a comment
7982
######### also a comment
8083
@@ -126,6 +129,7 @@ that was one of the main reasons I started developing dxhd
126129

127130
* dxhd uses shebang to determine which shell to use (so you don't have to set an environment variable)
128131
* dxhd config file syntax matches shell, python, perl and probably some other languages syntax
132+
* dxhd config lets you declare global variables for each keybinding command
129133
* dxhd is great with scripting, because of it's elegant syntax. multi line scripts do not need `\` at the end of line
130134
* dxhd allows you to have different range in a keybinding's action, for example, `1-9` in a keybinding, and `11-19` in it's action
131135
* dxhd has support for mouse bindings out of the box, no patching required!
@@ -162,6 +166,35 @@ echo world
162166

163167
Yes! And no. dxhd has released key events and ranges, but no chords (yet - [wip](https://github.com/dakyskye/dxhd/issues/8))
164168

169+
### How does global variables inside a config file work
170+
171+
Everything after (if there is) the shebang before the first comment/keybinding is collected and passed to each keybinding command
172+
173+
A shell example:
174+
175+
```sh
176+
#!/bin/sh
177+
178+
INFO="$(wmctrl -m)"
179+
180+
## print info about my WM
181+
# super + i
182+
echo "Info about your WM:"
183+
echo "$INFO"
184+
```
185+
186+
A Python example:
187+
188+
```py
189+
#!/usr/bin/python
190+
191+
foo="foo bar"
192+
193+
## print the value of foo variable
194+
# super + i
195+
print(foo)
196+
```
197+
165198
### Is dxhd faster than sxhkd
166199

167200
They haven't benchmarked yet, so I don't know.

0 commit comments

Comments
 (0)