summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--nsis/Makefile.am2
-rw-r--r--src/unix/read_cfg.c110
-rw-r--r--src/windows/read_cfg.c107
3 files changed, 121 insertions, 98 deletions
diff --git a/nsis/Makefile.am b/nsis/Makefile.am
index 3f47a9f..72f8ab9 100644
--- a/nsis/Makefile.am
+++ b/nsis/Makefile.am
@@ -1,4 +1,4 @@
-EXTRA_DIST = installer.nsi.in
+EXTRA_DIST = find_dlls.sh installer.nsi.in
CLEANFILES = $(PACKAGE_NAME)-Setup.exe deps/*
diff --git a/src/unix/read_cfg.c b/src/unix/read_cfg.c
index 6f75ddc..602c750 100644
--- a/src/unix/read_cfg.c
+++ b/src/unix/read_cfg.c
@@ -78,56 +78,66 @@ void mkconfig_wizard(char *path){
exit(1);
}
- //write to file
- fprintf(fp, "# This file was auto-generated by terminal-media-launcher. See docs/terminal-media-launcher-config.md or terminal-media-launcher-config(5) for documentation\n"
- "# The default launcher is set to \"xdg-open\" which will open files based on the relevant default application set through xdg\n\n"
- "# Recursively add files from %s%cMusic%c to Music group\n"
- "addGroup Music\n"
- "setLauncher Music xdg-open\n", home, sep, sep);
- fprintf(fp, "addR %s%cMusic%c*.aac Music\n", home, sep, sep);
- fprintf(fp, "addR %s%cMusic%c*.aiff Music\n", home, sep, sep);
- fprintf(fp, "addR %s%cMusic%c*.alac Music\n", home, sep, sep);
- fprintf(fp, "addR %s%cMusic%c*.au Music\n", home, sep, sep);
- fprintf(fp, "addR %s%cMusic%c*.flac Music\n", home, sep, sep);
- fprintf(fp, "addR %s%cMusic%c*.m4a Music\n", home, sep, sep);
- fprintf(fp, "addR %s%cMusic%c*.mp3 Music\n", home, sep, sep);
- fprintf(fp, "addR %s%cMusic%c*.ogg Music\n", home, sep, sep);
- fprintf(fp, "addR %s%cMusic%c*.pcm Music\n", home, sep, sep);
- fprintf(fp, "addR %s%cMusic%c*.wav Music\n", home, sep, sep);
- fprintf(fp, "addR %s%cMusic%c*.wma Music\n\n", home, sep, sep);
- fprintf(fp, "# Recursively add files from %s%cPictures%c to Pictures group\n"
- "addGroup Pictures\n"
- "setLauncher Pictures xdg-open\n", home, sep, sep);
- fprintf(fp, "addR %s%cPictures%c*.epi Pictures\n", home, sep, sep);
- fprintf(fp, "addR %s%cPictures%c*.eps Pictures\n", home, sep, sep);
- fprintf(fp, "addR %s%cPictures%c*.eps2 Pictures\n", home, sep, sep);
- fprintf(fp, "addR %s%cPictures%c*.eps3 Pictures\n", home, sep, sep);
- fprintf(fp, "addR %s%cPictures%c*.epsf Pictures\n", home, sep, sep);
- fprintf(fp, "addR %s%cPictures%c*.epsi Pictures\n", home, sep, sep);
- fprintf(fp, "addR %s%cPictures%c*.ept Pictures\n", home, sep, sep);
- fprintf(fp, "addR %s%cPictures%c*.gif Pictures\n", home, sep, sep);
- fprintf(fp, "addR %s%cPictures%c*.gfa Pictures\n", home, sep, sep);
- fprintf(fp, "addR %s%cPictures%c*.giff Pictures\n", home, sep, sep);
- fprintf(fp, "addR %s%cPictures%c*.jpeg Pictures\n", home, sep, sep);
- fprintf(fp, "addR %s%cPictures%c*.jpg Pictures\n", home, sep, sep);
- fprintf(fp, "addR %s%cPictures%c*.png Pictures\n", home, sep, sep);
- fprintf(fp, "addR %s%cPictures%c*.svg Pictures\n", home, sep, sep);
- fprintf(fp, "addR %s%cPictures%c*.svgz Pictures\n", home, sep, sep);
- fprintf(fp, "addR %s%cPictures%c*.tif Pictures\n", home, sep, sep);
- fprintf(fp, "addR %s%cPictures%c*.tiff Pictures\n\n", home, sep, sep);
- fprintf(fp, "# Recursively add files from %s%cVideos%c to Videos group\n"
- "addGroup Videos\n"
- "setLauncher Videos xdg-open\n", home, sep, sep);
- fprintf(fp, "addR %s%cVideos%c*.asf Videos\n", home, sep, sep);
- fprintf(fp, "addR %s%cVideos%c*.avi Videos\n", home, sep, sep);
- fprintf(fp, "addR %s%cVideos%c*.flv Videos\n", home, sep, sep);
- fprintf(fp, "addR %s%cVideos%c*.mk3d Videos\n", home, sep, sep);
- fprintf(fp, "addR %s%cVideos%c*.mkv Videos\n", home, sep, sep);
- fprintf(fp, "addR %s%cVideos%c*.mov Videos\n", home, sep, sep);
- fprintf(fp, "addR %s%cVideos%c*.mp4 Videos\n", home, sep, sep);
- fprintf(fp, "addR %s%cVideos%c*.qt Videos\n", home, sep, sep);
- fprintf(fp, "addR %s%cVideos%c*.webm Videos\n", home, sep, sep);
- fprintf(fp, "addR %s%cVideos%c*.wmv Videos\n", home, sep, sep);
+ fprintf(fp,
+ "-- This file was auto-generated by terminal-media-launcher. See docs/terminal-media-launcher-config.md or terminal-media-launcher-config(5) for documentation\n"
+ "-- The default launcher is set to \"xdg-open\" which will open files based on the relevant default application set through xdg\n\n"
+ "local lfs = require \"lfs\"\n"
+ "\n"
+ "local function addGroup(name, launcher, flags)\n"
+ " assert(type(name) == \"string\")\n"
+ "\n"
+ " -- create Groups table if needed\n"
+ " if Groups == nil then\n"
+ " Groups = {}\n"
+ " end\n"
+ "\n"
+ " local new_group = {}\n"
+ " new_group.name = name\n"
+ " new_group.Entries = {}\n"
+ " if launcher ~= nil then\n"
+ " new_group.Launcher = launcher\n"
+ " end\n"
+ " if flags ~= nil then\n"
+ " new_group.Flags = flags\n"
+ " end\n"
+ "\n"
+ " table.insert(Groups, new_group)\n"
+ " return new_group\n"
+ "end\n"
+ "\n"
+ "local function addEntries(parentGroup, startDir, filePattern, recursive)\n"
+ " -- recursive arg is a boolean for whether or not to descend into subdirectories (false by default)\n"
+ " assert(type(parentGroup) == \"table\")\n"
+ " assert(type(parentGroup.Entries) == \"table\")\n"
+ " assert(type(startDir) == \"string\")\n"
+ " assert(type(filePattern) == \"string\")\n"
+ "\n"
+ " for file in lfs.dir(startDir) do\n"
+ " local fullFilePath = startDir .. \"/\" .. file\n"
+ " if file ~= \".\" and file ~= \"..\" then\n"
+ " -- descend into subdirectory if recursive is set to true\n"
+ " if lfs.attributes(fullFilePath).mode == \"directory\" and recursive == true then\n"
+ " addEntries(parentGroup, fullFilePath, filePattern, recursive)\n"
+ " elseif lfs.attributes(fullFilePath).mode == \"file\" then\n"
+ " if string.match(file, filePattern) then\n"
+ " table.insert(parentGroup.Entries, {\n"
+ " name = file,\n"
+ " path = fullFilePath\n"
+ " })\n"
+ " end\n"
+ " end\n"
+ " end\n"
+ " end\n"
+ "end\n"
+ "\n"
+ "local music = addGroup(\"Music\", \"xdg-open\")\n"
+ "addEntries(music, os.getenv(\"HOME\") .. \"/Music\", \".*\", true)\n"
+ "\n"
+ "local pictures = addGroup(\"Pictures\", \"xdg-open\")\n"
+ "addEntries(pictures, os.getenv(\"HOME\") .. \"/Pictures\", \".*\", true)\n"
+ "\n"
+ "local videos = addGroup(\"Videos\", \"xdg-open\")\n"
+ "addEntries(videos, os.getenv(\"HOME\") .. \"/Videos\", \".*\", true)\n");
fclose(fp);
printf("done\nIt is highly recommended to further tweak the configuration file! [press any key to continue]");
diff --git a/src/windows/read_cfg.c b/src/windows/read_cfg.c
index bb337f0..79e56b7 100644
--- a/src/windows/read_cfg.c
+++ b/src/windows/read_cfg.c
@@ -81,53 +81,66 @@ void mkconfig_wizard(char *path){
exit(1);
}
- fprintf(fp, "# This file was auto-generated by terminal-media-launcher. See docs\\terminal-media-launcher-config.md or terminal-media-launcher-config(5) for documentation\n"
- "# By default, no launcher is specified for any group. When no launcher is specified on the Windows build of terminal-media-launcher, media files will be opened with their default application.\n"
- "# It is generally recommended to specify a launcher for groups containing media files using the \"setLauncher\" command\n\n"
- "# Recursively add files from %s%cMusic%c to Music group\n"
- "addGroup Music\n", home, sep, sep);
- fprintf(fp, "addR %s%cMusic%c*.aac Music\n", home, sep, sep);
- fprintf(fp, "addR %s%cMusic%c*.aiff Music\n", home, sep, sep);
- fprintf(fp, "addR %s%cMusic%c*.alac Music\n", home, sep, sep);
- fprintf(fp, "addR %s%cMusic%c*.au Music\n", home, sep, sep);
- fprintf(fp, "addR %s%cMusic%c*.flac Music\n", home, sep, sep);
- fprintf(fp, "addR %s%cMusic%c*.m4a Music\n", home, sep, sep);
- fprintf(fp, "addR %s%cMusic%c*.mp3 Music\n", home, sep, sep);
- fprintf(fp, "addR %s%cMusic%c*.ogg Music\n", home, sep, sep);
- fprintf(fp, "addR %s%cMusic%c*.pcm Music\n", home, sep, sep);
- fprintf(fp, "addR %s%cMusic%c*.wav Music\n", home, sep, sep);
- fprintf(fp, "addR %s%cMusic%c*.wma Music\n\n", home, sep, sep);
- fprintf(fp, "# Recursively add files from %s%cPictures%c to Pictures group\n"
- "addGroup Pictures\n", home, sep, sep);
- fprintf(fp, "addR %s%cPictures%c*.epi Pictures\n", home, sep, sep);
- fprintf(fp, "addR %s%cPictures%c*.eps Pictures\n", home, sep, sep);
- fprintf(fp, "addR %s%cPictures%c*.eps2 Pictures\n", home, sep, sep);
- fprintf(fp, "addR %s%cPictures%c*.eps3 Pictures\n", home, sep, sep);
- fprintf(fp, "addR %s%cPictures%c*.epsf Pictures\n", home, sep, sep);
- fprintf(fp, "addR %s%cPictures%c*.epsi Pictures\n", home, sep, sep);
- fprintf(fp, "addR %s%cPictures%c*.ept Pictures\n", home, sep, sep);
- fprintf(fp, "addR %s%cPictures%c*.gif Pictures\n", home, sep, sep);
- fprintf(fp, "addR %s%cPictures%c*.gfa Pictures\n", home, sep, sep);
- fprintf(fp, "addR %s%cPictures%c*.giff Pictures\n", home, sep, sep);
- fprintf(fp, "addR %s%cPictures%c*.jpeg Pictures\n", home, sep, sep);
- fprintf(fp, "addR %s%cPictures%c*.jpg Pictures\n", home, sep, sep);
- fprintf(fp, "addR %s%cPictures%c*.png Pictures\n", home, sep, sep);
- fprintf(fp, "addR %s%cPictures%c*.svg Pictures\n", home, sep, sep);
- fprintf(fp, "addR %s%cPictures%c*.svgz Pictures\n", home, sep, sep);
- fprintf(fp, "addR %s%cPictures%c*.tif Pictures\n", home, sep, sep);
- fprintf(fp, "addR %s%cPictures%c*.tiff Pictures\n\n", home, sep, sep);
- fprintf(fp, "# Recursively add files from %s%cVideos%c to Videos group\n"
- "addGroup Videos\n", home, sep, sep);
- fprintf(fp, "addR %s%cVideos%c*.asf Videos\n", home, sep, sep);
- fprintf(fp, "addR %s%cVideos%c*.avi Videos\n", home, sep, sep);
- fprintf(fp, "addR %s%cVideos%c*.flv Videos\n", home, sep, sep);
- fprintf(fp, "addR %s%cVideos%c*.mk3d Videos\n", home, sep, sep);
- fprintf(fp, "addR %s%cVideos%c*.mkv Videos\n", home, sep, sep);
- fprintf(fp, "addR %s%cVideos%c*.mov Videos\n", home, sep, sep);
- fprintf(fp, "addR %s%cVideos%c*.mp4 Videos\n", home, sep, sep);
- fprintf(fp, "addR %s%cVideos%c*.qt Videos\n", home, sep, sep);
- fprintf(fp, "addR %s%cVideos%c*.webm Videos\n", home, sep, sep);
- fprintf(fp, "addR %s%cVideos%c*.wmv Videos\n", home, sep, sep);
+ fprintf(fp,
+ "-- This file was auto-generated by terminal-media-launcher. See docs\\terminal-media-launcher-config.md or terminal-media-launcher-config(5) for documentation\n"
+ "-- By default, no launcher is specified for any group. When no launcher is specified on the Windows build of terminal-media-launcher, media files will be opened with their default application.\n\n"
+ "local lfs = require \"lfs\"\n"
+ "\n"
+ "local function addGroup(name, launcher, flags)\n"
+ " assert(type(name) == \"string\")\n"
+ "\n"
+ " -- create Groups table if needed\n"
+ " if Groups == nil then\n"
+ " Groups = {}\n"
+ " end\n"
+ "\n"
+ " local new_group = {}\n"
+ " new_group.name = name\n"
+ " new_group.Entries = {}\n"
+ " if launcher ~= nil then\n"
+ " new_group.Launcher = launcher\n"
+ " end\n"
+ " if flags ~= nil then\n"
+ " new_group.Flags = flags\n"
+ " end\n"
+ "\n"
+ " table.insert(Groups, new_group)\n"
+ " return new_group\n"
+ "end\n"
+ "\n"
+ "local function addEntries(parentGroup, startDir, filePattern, recursive)\n"
+ " -- recursive arg is a boolean for whether or not to descend into subdirectories (false by default)\n"
+ " assert(type(parentGroup) == \"table\")\n"
+ " assert(type(parentGroup.Entries) == \"table\")\n"
+ " assert(type(startDir) == \"string\")\n"
+ " assert(type(filePattern) == \"string\")\n"
+ "\n"
+ " for file in lfs.dir(startDir) do\n"
+ " local fullFilePath = startDir .. \"\\\\\" .. file\n"
+ " if file ~= \".\" and file ~= \"..\" then\n"
+ " -- descend into subdirectory if recursive is set to true\n"
+ " if lfs.attributes(fullFilePath).mode == \"directory\" and recursive == true then\n"
+ " addEntries(parentGroup, fullFilePath, filePattern, recursive)\n"
+ " elseif lfs.attributes(fullFilePath).mode == \"file\" then\n"
+ " if string.match(file, filePattern) then\n"
+ " table.insert(parentGroup.Entries, {\n"
+ " name = file,\n"
+ " path = fullFilePath\n"
+ " })\n"
+ " end\n"
+ " end\n"
+ " end\n"
+ " end\n"
+ "end\n"
+ "\n"
+ "local music = addGroup(\"Music\")\n"
+ "addEntries(music, os.getenv(\"USERPROFILE\") .. \"\\\\Music\", \".*\", true)\n"
+ "\n"
+ "local pictures = addGroup(\"Pictures\")\n"
+ "addEntries(pictures, os.getenv(\"USERPROFILE\") .. \"\\\\Pictures\", \".*\", true)\n"
+ "\n"
+ "local videos = addGroup(\"Videos\")\n"
+ "addEntries(videos, os.getenv(\"USERPROFILE\") .. \"\\\\Videos\", \".*\", true)\n");
fclose(fp);
printf("done\nIt is highly recommended to further tweak the configuration file! [press any key to continue]");