aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorRobin Haberkorn <robin.haberkorn@googlemail.com>2025-03-03 01:44:34 +0300
committerRobin Haberkorn <robin.haberkorn@googlemail.com>2025-03-03 23:35:04 +0300
commit1b907dae072f2aa93d75d8c056a9bd02555a17f8 (patch)
treea34f9cec995db63e61e9d70c93bc375fce303f25 /src
parentbe368b6f79148720b798cc98222ac86829a53724 (diff)
downloadsciteco-1b907dae072f2aa93d75d8c056a9bd02555a17f8.tar.gz
rename sample.teco_ini to fallback.teco_ini and mung it by default
* After installation, SciTECO will therefore start into a more userfriendly mode even if the user does not create a custom ~/.teco_ini. It is hoped that this will scare away less of new users, who are not willing to read through all of the documentation. Still, users are warned in the absence of ~/.teco_ini. This warning however, might not be immediately visible, especially not when running gsciteco without an attached console. (This will change once I redo the UI and allow a number of messages to be queued in the message area.) * Theoretically, you could also just extend fallback.teco_ini from ~/.teco_ini, but that would require installing it into $SCITECOPATH. * Since the fallback profile will now be munged automatically on a wide range of systems, we set up xclip only when detecting X11 ($DISPLAY is non-empty). E.g. when running under Wayland or the Linux console, you still won't get the clipboard registers, which is probably better than having the clipboard operations fail once you try to use them. * xclip is now "suggested" on Debian/Ubuntu. Unfortunately we cannot pull it in only in the presence of X11.
Diffstat (limited to 'src')
-rw-r--r--src/main.c26
1 files changed, 24 insertions, 2 deletions
diff --git a/src/main.c b/src/main.c
index 7849798..0a33d64 100644
--- a/src/main.c
+++ b/src/main.c
@@ -465,11 +465,33 @@ main(int argc, char **argv)
goto cleanup;
}
- if (!mung_filename && teco_mung_profile)
+ if (!mung_filename && teco_mung_profile) {
/* NOTE: Still safe to use g_getenv() */
mung_filename = g_build_filename(g_getenv("SCITECOCONFIG"), INI_FILE, NULL);
+ if (!g_file_test(mung_filename, G_FILE_TEST_IS_REGULAR)) {
+ g_autofree gchar *datadir = teco_file_get_datadir();
+ gchar *fallback = g_build_filename(datadir, "fallback.teco_ini", NULL);
+ if (g_file_test(fallback, G_FILE_TEST_IS_REGULAR)) {
+ teco_interface_msg(TECO_MSG_WARNING,
+ "Profile \"%s\" not found: Falling back to \"%s\".",
+ mung_filename, fallback);
+ g_free(mung_filename);
+ mung_filename = fallback;
+ } else {
+ teco_interface_msg(TECO_MSG_WARNING,
+ "No profile found to mung.");
+ g_free(mung_filename);
+ g_free(fallback);
+ mung_filename = NULL;
+ }
+ }
+ }
- if (mung_filename && g_file_test(mung_filename, G_FILE_TEST_IS_REGULAR)) {
+ if (mung_filename) {
+ /*
+ * NOTE: Theoretically there is a small timeframe when the file could
+ * disappear, in which case there will be an error.
+ */
if (!teco_execute_file(mung_filename, &local_qregs, &error) &&
!g_error_matches(error, TECO_ERROR, TECO_ERROR_QUIT))
goto error;