Skip to content

Commit 0ec26d8

Browse files
author
okay
committed
[genie] add support for /opt/etc/genie.conf.d/ directory
1 parent ab33462 commit 0ec26d8

File tree

1 file changed

+22
-6
lines changed

1 file changed

+22
-6
lines changed

src/genie/main.cpy

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -55,29 +55,45 @@ class App:
5555
// fingers=2
5656
// command="/home/root/swipes/swipeup.sh"
5757

58-
def setup_gestures(App &app):
58+
HAS_GESTURES := false
59+
def setup_gestures(App &app, string filename):
5960
string line
60-
ifstream infile(INFILE)
61+
ifstream infile(filename)
6162
vector<string> lines
6263

6364
while getline(infile, line):
6465
lines.push_back(line)
6566

6667
gestures := parse_config(lines)
67-
if gestures.size() == 0:
68-
debug "NO GESTURES"
69-
exit(0)
68+
if gestures.size() > 0:
69+
HAS_GESTURES = true
70+
else:
71+
debug "NO GESTURES IN", filename
72+
return
7073

7174
for auto g : gestures:
7275
ui::MainLoop::gestures.push_back(g)
7376

77+
def read_genie_conf_d(App &app):
78+
config_dir := "/opt/etc/genie.conf.d/"
79+
filenames := util::lsdir(config_dir)
80+
sort(filenames.begin(), filenames.end())
81+
for auto f : filenames:
82+
debug "READING CONFIG", f
83+
setup_gestures(app, config_dir + f)
84+
85+
7486
def main(int argc, char **argv):
7587
App app
7688

7789
if argc > 1:
7890
INFILE = argv[1]
7991
debug "USING", INFILE, "AS CONFIG FILE"
8092

81-
setup_gestures(app)
93+
setup_gestures(app, INFILE)
94+
read_genie_conf_d(app)
8295

96+
if not HAS_GESTURES:
97+
debug "NO GESTURES FOUND, PLEASE SET SOME UP"
98+
exit(0)
8399
app.run()

0 commit comments

Comments
 (0)