echawk / kiss-xorg

A KISS Linux Repository for Xorg
MIT License
34 stars 9 forks source link

xfiles: add custom config, update deps #116

Closed apprehensions closed 1 year ago

apprehensions commented 1 year ago

the requirement of imagemagick is required for thumbnail generation. i have also added my own custom config.c due to upstream disagreement.

hovercats commented 1 year ago

why arent we patching the config.c instead of adding the whole file? Im just curious of the reasoning. imo, a patch would be preferable

apprehensions commented 1 year ago

because we are using git source, it also will most likely not even make that big of a difference; even in size, or will make it harder to update.

hovercats commented 1 year ago

I see. we could just pin it to a certain commit though. which would solve the issue. is your patch prone to breaking though? I checked the commit log for config.c, and didnt seem like it had that many changes to it anyway. I mean, if the patch is unlikely to break often, I dont see any reason why we cant just use a patch. you will probably end up having to fix the config.c anyway, at some point as the project moves on.

apprehensions commented 1 year ago

having a single file is easier than having to maintain a patch. I'm not very good at maintaining patches in a complicated manner

hovercats commented 1 year ago

Thats up for debate tbh.. With this file, its not clear what has been changed, without fetching the original file. And then diffing it to see the differences. With a patch, we see immediatly what changes youre making. Its more transparrent than just shipping the file when a patch might make more sense. Also, when the file changes upstream, how are you going to keep up with upstream changes unless you fully know what changes youve done?

In any case, its up to @ehawkvu to decide this anyway. This is just my 2 cents..

echawk commented 1 year ago

I'm with @hovercats on this one - I think a patch or a sed call would be simpler. I wonder about the long term maintainability of having just a 'config.c' file, since upstream could change what all they expect to be present in the file.

apprehensions commented 1 year ago
--- ok
+++ config.c
@@ -11,7 +11,6 @@
 #include "icons/file-archive.xpm"
 #include "icons/file-audio.xpm"
 #include "icons/file-code.xpm"
-#include "icons/file-core.xpm"
 #include "icons/file-config.xpm"
 #include "icons/file-gear.xpm"
 #include "icons/file-image.xpm"
@@ -37,181 +36,74 @@
 #include "icons/folder-video.xpm"
 #include "icons/folder.xpm"

-/*
- * Then specify the file patterns.
- *
- * - Element [0] is type ("f" for regular file, "fx" for regular
- *   executable file, "d" for directory, etc).
- * - Elements [1] through [n-2] are globbing patterns.  Environment
- *   variables are not supported.   But a tilde in the beginning of
- *   the string expands to the home directory.
- * - Element [n-1] is the obligatory NULL.
- */
-static char *file_app[]        = { "fx", NULL };
-static char *file_archive[]    = { "f", "*.zip", "*.tar", "*.gz", "*.bz2", "*.rar", NULL };
-static char *file_audio[]      = { "f", "*.mp[23]", "*.m4a", "*.m3u", "*.ogg", "*.opus", "*.flac", NULL };
-static char *file_code[]       = { "f", "*.c", "*.h", "*.s", NULL };
-static char *file_core[]       = { "f", "*.core", NULL };
-static char *file_config[]     = { "f", "*.conf", "*.config", "*.yaml", "*.toml", "*.xml", "*.ini", NULL };
-#ifdef USE_NETPBM
-static char *file_xbm[]        = { "f", "*.xbm", NULL };
-static char *file__xpm[]       = { "f", "*.xpm", NULL };
-static char *file_ppm[]        = { "f", "*.p[bgp]m", NULL };
-static char *file_png[]        = { "f", "*.png", NULL };
-static char *file_bmp[]        = { "f", "*.bmp", NULL };
-static char *file_gif[]        = { "f", "*.gif", NULL };
-static char *file_tiff[]       = { "f", "*.tiff", NULL };
-static char *file_jpeg[]       = { "f", "*.jpeg", "*.jpg", NULL };
-#endif
-static char *file_image[]      = { "f", "*.x[pb]m", "*.png", "*.jpg", "*.jpeg", "*.p[bgp]m", "*.gif", NULL };
-static char *file_svg[]        = { "f", "*.svg", NULL };
-static char *file_manual[]     = { "f", "*.[1-9]", "*.3p", "README", "README.md", "COPYING", "LICENSE", "COPYRIGHT", NULL };
-static char *file_makefile[]   = { "f", "[Mm]akefile", "configure", NULL };
-static char *file_pdf[]        = { "f", "*.pdf", NULL };
-static char *file_object[]     = { "f", "*.o", "*.so", "*.a", "lib*", NULL };
-static char *file_text[]       = { "f", "*.epub", "*.txt", "*.ps", "*.eps", "*.djvu", NULL };
-static char *file_video[]      = { "f", "*.mp4", "*.webm", "*.mkv", "*.mov", "*.ogv", NULL };
-static char *folder_bin[]      = { "d", "~/usr", "~/bin", NULL };
-static char *folder_code[]     = { "d", "~/prj", "~/proj", "~/code", "~/[Pp]rojects", NULL };
-static char *folder_db[]       = { "d", "~/var", "~/.local", "~/.local/share", NULL };
-static char *folder_docs[]     = { "d", "~/doc", "~/docs", "~/[Dd]ox", "~/[Dd]ocuments", NULL };
-static char *folder_download[] = { "d", "~/tmp", "~/dl", "~/[Dd]ownloads", NULL };
-static char *folder_game[]     = { "d", "~/game", "~/[Gg]ames", NULL };
-static char *folder_image[]    = { "d", "~/img", "~/[Pp]ix", "~/[Pp]ic*", "~/[Ii]mage*", NULL };
-static char *folder_config[]   = { "d", "~/.config", "/etc", "~/etc", "~/lib", NULL };
-static char *folder_meme[]     = { "d", "~/mem", "~/meme", "~/[Mm]emes", NULL };
-static char *folder_mount[]    = { "d", "~/mnt", "~/mount", "/[Mm]edia", "/mnt", NULL };
-static char *folder_music[]    = { "d", "~/mus", "~/music", "/[Mm]usic", NULL };
-static char *folder_video[]    = { "d", "~/vid", "~/[Vv]ideo", "/[Vv]ideos", NULL };
-static char *folder_home[]     = { "d", "~", NULL };
-static char *folder_up[]       = { "d", "..", NULL };
-static char *folder_link[]     = { "dl", NULL };
-static char *folder[]          = { "d", NULL };
+static char *file_app[]     = { "fx", NULL };
+static char *file_archive[] = { "f", "*.tar*", "*.t[bgx]z", "*.lzma", "*.lz", "*.zip", "*.rar", NULL };
+static char *file_audio[]   = { "f", "*.mp[23]", "*.m4a", "*.m3u", "*.ogg", "*.opus", "*.flac", NULL };
+static char *file_code[]    = { "f", "*.c", "*.cpp", "*.h", "*.go", "*.html", "*.css", "*.lua", "*.rs", "*.s", "*.*sh", "*.pl", "*.sed", "*.awk", NULL };
+static char *file_config[]  = { "f", "*.conf", "*.yaml", "*.toml", "*.xml", "*.ini", "*.json", "*rc", NULL };
+static char *file_image[]   = { "f", "*.png", "*.p[bgp]m", "*.x[bp]m", "*.jpeg", "*.jpg", "*.jpe", "*.jfi", "*.jfi[f]", "*.svg", NULL };
+static char *file_info[]    = { "f", "*.[1-9]", "*.scd", "*.3p", "README*", "COPYING*", "LICENSE*", "COPYRIGHT*", NULL };
+static char *file_gear[]    = { "f", "*akefile", "configure", "meson.build", "CMakeLists.txt", NULL };
+static char *file_object[]  = { "f", "*.o", "*.so", "*.a", "*.hex", "*.rom", NULL };
+static char *file_text[]    = { "f", "*.epub", "*.txt", "*.ps", "*.eps", "*.djvu", "*.md", "*.org", "*.pdf", "*.csv", NULL };
+static char *file_video[]   = { "f", "*.mp4", "*.gif", "*.avi", "*.webm", "*.mkv", "*.mov", "*.ogv", NULL };
+static char *folder_apps[]  = { "d", "bin", NULL };
+static char *folder_code[]  = { "d", "src", "[Pp]rojects", "[Pp]roj", "[Dd]evelopment", NULL };
+static char *folder_db[]    = { "d", "var", "~/.local", "~/.local/share", NULL };
+static char *folder_book[]  = { "d", "man", "doc[s]", "[Dd]ox", "[Dd]ocuments", NULL };
+static char *folder_dl[]    = { "d", "tmp", "dl", "[Dd]ownloads", NULL };
+static char *folder_game[]  = { "d", "games", "[Gg]ames", NULL };
+static char *folder_image[] = { "d", "img", "[Pp]ix", "[Pp]ic*", "[Ii]mage*", NULL };
+static char *folder_gear[]  = { "d", "etc", "~/.config", NULL };
+static char *folder_meme[]  = { "d", "[Mm]emes", NULL };
+static char *folder_mount[] = { "d", "mnt", "mount", "[Mm]edia", NULL };
+static char *folder_music[] = { "d", "mus", "music", "[Mm]usic", NULL };
+static char *folder_video[] = { "d", "vid", "[Vv]ideos", NULL };
+static char *folder_home[]  = { "d", "~", NULL };
+static char *folder_up[]    = { "d", "..", NULL };
+static char *folder_link[]  = { "dl", NULL };
+static char *folder[]       = { "d", NULL };

-/*
- * Finally, link file patterns with icons.
- *
- * Last element must have null pattern.
- */
 char **icons[][2] = {
-   { file_app,        file_app_xpm,        },
-   { file_archive,    file_archive_xpm,    },
-   { file_audio,      file_audio_xpm,      },
-   { file_code,       file_code_xpm,       },
-   { file_core,       file_core_xpm,       },
-   { file_config,     file_config_xpm,     },
-   { file_makefile,   file_gear_xpm,       },
-   { file_image,      file_image_xpm,      },
-   { file_svg,        file_image_xpm,      },
-   { file_manual,     file_info_xpm,       },
-   { file_object,     file_object_xpm,     },
-   { file_pdf,        file_text_xpm,       },
-   { file_text,       file_text_xpm,       },
-   { file_video,      file_video_xpm,      },
-   { folder_up,       folder_up_xpm,       },
-   { folder_bin,      folder_apps_xpm,     },
-   { folder_code,     folder_code_xpm,     },
-   { folder_db,       folder_db_xpm,       },
-   { folder_docs,     folder_book_xpm,     },
-   { folder_download, folder_download_xpm, },
-   { folder_game,     folder_game_xpm,     },
-   { folder_image,    folder_image_xpm,    },
-   { folder_config,   folder_gear_xpm,     },
-   { folder_home,     folder_home_xpm,     },
-   { folder_meme,     folder_meme_xpm,     },
-   { folder_mount,    folder_mount_xpm,    },
-   { folder_music,    folder_music_xpm,    },
-   { folder_video,    folder_video_xpm,    },
-   { folder_link,     folder_link_xpm,     },
-   { folder,          folder_xpm,          },
-   { NULL,            file_xpm,            },
+   { file_app,     file_app_xpm,        },
+   { file_archive, file_archive_xpm,    },
+   { file_audio,   file_audio_xpm,      },
+   { file_code,    file_code_xpm,       },
+   { file_config,  file_config_xpm,     },
+   { file_gear,    file_gear_xpm,       },
+   { file_image,   file_image_xpm,      },
+   { file_info,    file_info_xpm,       },
+   { file_object,  file_object_xpm,     },
+   { file_text,    file_text_xpm,       },
+   { file_video,   file_video_xpm,      },
+   { folder_up,    folder_up_xpm,       },
+   { folder_apps,  folder_apps_xpm,     },
+   { folder_code,  folder_code_xpm,     },
+   { folder_db,    folder_db_xpm,       },
+   { folder_book,  folder_book_xpm,     },
+   { folder_dl,    folder_download_xpm, },
+   { folder_game,  folder_game_xpm,     },
+   { folder_image, folder_image_xpm,    },
+   { folder_gear,  folder_gear_xpm,     },
+   { folder_home,  folder_home_xpm,     },
+   { folder_meme,  folder_meme_xpm,     },
+   { folder_mount, folder_mount_xpm,    },
+   { folder_music, folder_music_xpm,    },
+   { folder_video, folder_video_xpm,    },
+   { folder_link,  folder_link_xpm,     },
+   { folder,       folder_xpm,          },
+   { NULL,         file_xpm,            },
 };
 size_t nicons = LEN(icons);

-/*
- * The following are commands to be run to generate thumbnails.
- */
-#define PNMSCALE " 2>/dev/null | pnmscalefixed -xysize "THUMBSIZE" "THUMBSIZE" "
-
-#ifdef USE_NETPBM
-static char *ppmtoppm[NCMDARGS] = {
-   "/bin/sh", "-c",
-   "<\"${1}\" ppmtoppm"PNMSCALE">\"${2}\""
-};
-static char *xbmtopbm[NCMDARGS] = {
-   "/bin/sh", "-c",
-   "<\"${1}\" xbmtopbm | ppmtoppm"PNMSCALE">\"${2}\""
-};
-static char *xpmtoppm[NCMDARGS] = {
-   "/bin/sh", "-c",
-   "<\"${1}\" xpmtoppm"PNMSCALE">\"${2}\""
-};
-static char *pngtopnm[NCMDARGS] = {
-   "/bin/sh", "-c",
-   "<\"${1}\" pngtopnm"PNMSCALE">\"${2}\""
-};
-static char *bmptopnm[NCMDARGS] = {
-   "/bin/sh", "-c",
-   "<\"${1}\" bmptopnm"PNMSCALE">\"${2}\""
-};
-static char *giftopnm[NCMDARGS] = {
-   "/bin/sh", "-c",
-   "<\"${1}\" giftopnm"PNMSCALE">\"${2}\""
-};
-static char *tifftopnm[NCMDARGS] = {
-   "/bin/sh", "-c",
-   "<\"${1}\" tifftopnm"PNMSCALE">\"${2}\""
-};
-static char *jpegtopnm[NCMDARGS] = {
-   "/bin/sh", "-c",
-   "<\"${1}\" jpegtopnm"PNMSCALE">\"${2}\""
-};
-#else
 static char *imagemagick[NCMDARGS] = {
    "/bin/sh", "-c",
-   "convert \"${1}[0]\" -background '#0A0A0A' -flatten " \
-   "-format ppm -thumbnail \""THUMBSIZE"x"THUMBSIZE"\" " \
+   "convert \"${1}[0]\" -thumbnail \""THUMBSIZE"x"THUMBSIZE"\" " \
    "-define filename:literal=true \"${2}\"",
 };
-#endif
-static char *ffmpegthumb[NCMDARGS] = {
-   "/bin/sh", "-c",
-   "ffmpegthumbnailer -c png -i \"${1}\" " \
-   "-o - -s "THUMBSIZE" | convert - -define " \
-   "filename:literal=true -format ppm \"${2}\"",
-};
-static char *rsvgconvert[NCMDARGS] = {
-   "/bin/sh", "-c",
-   "rsvg-convert -h "THUMBSIZE" \"${1}\" " \
-   "| convert - -format ppm \"${2}\"",
-};
-static char *pdftoppm[NCMDARGS] = {
-   "/bin/sh", "-c",
-   "pdftoppm -f 1 -l 1 -scale-to "THUMBSIZE" " \
-   "-singlefile \"${1}\" \"${2%.ppm}\"",
-};

-/*
- * The following table links file patterns with commands to be run to
- * generate thumbnails.
- *
- * Last element must be all NULL.
- */
 char **thumbs[][2] = {
-   { file_video,      ffmpegthumb, },
-#ifdef USE_NETPBM
-   { file_xbm,        xbmtopbm, },
-   { file__xpm,       xpmtoppm, },
-   { file_ppm,        ppmtoppm, },
-   { file_png,        pngtopnm, },
-   { file_bmp,        bmptopnm, },
-   { file_gif,        giftopnm, },
-   { file_tiff,       tifftopnm, },
-   { file_jpeg,       jpegtopnm, },
-#else
+   { file_video,      imagemagick, },
    { file_image,      imagemagick, },
-#endif
-   { file_svg,        rsvgconvert, },
-   { file_pdf,        pdftoppm,    },
    { NULL,            NULL, },
 };

i'm not sure whats the point of showing whats been changed. how about i just stick to a specific commit? ( the diff between the original is basically the entire file had changed... if the format or method of configuration has changed, what would be better?

both would still require a PR; i might as well just use my own git fork of xfiles.

hovercats commented 1 year ago

i'm not sure whats the point of showing whats been changed.

As stated earlier, to see what changes has been made. In just about every distro (the ones Ive peeked at anyway) have patches (or seds) clearly visible, making it clear what is being done, and why its being done (like fixing a CVE, or issues with musl, and so on). This makes it so users dont have to comb through issues, PRs, irc logs and so on to figure out why a patch or a change is being applied. if this was a personal repo, no one would care, but seeing as this is a repo used by alot of people (presumably anyway, I dont have the stats..), we have to do it correctly.

how about i just stick to a specific commit?

This I also said earlier. if we pin it to a certain commit, the patch wont break. however, as new commits gets pushed, we eventually have to stay on top of those, and bump to a newer commit. This might break the patch, in that case, just fix it in the same PR. It is more reliable to do it this way, but its a bit more work, seeing as one have to regularly check if any new commits have been pushed, and then fix possible issues. As opposed to just use upstream.

Why are you making these changes anyway? what wrong with the original file?

apprehensions commented 1 year ago

Why are you making these changes anyway? what wrong with the original file?

thanks for this statement, i've realized that most of these are personal changes; although the original config.c file was made explicitly for the maintainer's needs and not users.

i will maintain my own xfiles package.