This is an automated email from the git hooks/post-receive script.

git pushed a commit to branch master
in repository efm2.

View the commit online.

commit ddc6dfa220c5511cc03d217246860cfc9628715d
Author: Carsten Haitzler (Rasterman) <[email protected]>
AuthorDate: Thu Feb 5 21:01:05 2026 +0000

    make tyopebuf desktop file cmds actually run and work with args
---
 src/backends/default/open.c | 35 ++++++++++++++++++-
 src/efm/efm_back_end.c      | 85 ++++++++++++++++++++++++---------------------
 2 files changed, 79 insertions(+), 41 deletions(-)

diff --git a/src/backends/default/open.c b/src/backends/default/open.c
index c127e20..47d9fed 100644
--- a/src/backends/default/open.c
+++ b/src/backends/default/open.c
@@ -1667,7 +1667,7 @@ do_handle_cmd(Cmd *c)
     {
       const char *op, *cpos_str, *line_str;
       int         cpos = -1;
-      char      **args = NULL, **p;
+      char      **args = NULL;
 
       // XXX: now handle typebuf commands in the backend
       // XXX: if its a valid cmd - tell front end
@@ -1734,6 +1734,14 @@ do_handle_cmd(Cmd *c)
             {
               Efreet_Desktop *d = efreet_util_desktop_exec_find(args[0]);
 
+              if (!d)
+                {
+                  char buf[1024];
+
+                  snprintf(buf, sizeof(buf), "%s.desktop", args[0]);
+                  d = efreet_util_desktop_file_id_find(buf);
+                }
+              if (!d) d = efreet_util_desktop_name_find(args[0]);
               if (d)
                 {
                   Eina_Strbuf *buf2 = eina_strbuf_new();
@@ -1744,6 +1752,31 @@ do_handle_cmd(Cmd *c)
                       _cmd_typebuf_icon_send(eina_strbuf_string_get(buf2));
                       eina_strbuf_free(buf2);
                     }
+                  if ((op) && (!strcmp(op, "run")))
+                    {
+                      Eina_Strbuf *strbuf = cmd_strbuf_new("file-run");
+
+                      if (strbuf)
+                        {
+                          int i;
+                          const char *mondir = ecore_file_monitor_path_get(mon);
+
+                          if (mondir)
+                            { // cwd is this dir for cmds
+                              cmd_strbuf_append(strbuf, "cwd", mondir);
+                              cmd_strbuf_append(strbuf, "open-with",
+                                                d->orig_path);
+                              // add args as files
+                              for (i = 1; args[i]; i++)
+                                {
+                                  if (args[i][0])
+                                    cmd_strbuf_append(strbuf, "path",args[i]);
+                                }
+                              // send file-run cmd back to front end
+                              cmd_strbuf_print_consume(strbuf);
+                            }
+                        }
+                    }
                   efreet_desktop_free(d);
                 }
             }
diff --git a/src/efm/efm_back_end.c b/src/efm/efm_back_end.c
index 4e4140d..2a05b5a 100644
--- a/src/efm/efm_back_end.c
+++ b/src/efm/efm_back_end.c
@@ -712,54 +712,59 @@ _cb_thread_notify(void *data, Ecore_Thread *th EINA_UNUSED, void *msg)
         Efreet_Desktop *d     = NULL;
         Eina_List      *files = NULL;
         const char     *file;
-
         const char     *open_with_desktop = cmd_key_find(c, "open-with");
+        const char     *cwd               = cmd_key_find(c, "cwd");
+        char            cwdbuf[PATH_MAX];
 
-        path = cmd_key_find(c, "path");
-
-        KEY_WALK_BEGIN
-        {
-          if (!strcmp(key, "path"))
-            {
-              plist = eina_str_split(kdata, "\n", -1);
-              for (p = plist; *p; p++)
-                {
-                  fprintf(stderr, "ADD [%s]\n", *p);
-                  files = eina_list_append(files, eina_stringshare_add(*p));
-                }
-              free(*plist);
-              free(plist);
-            }
-        }
-        KEY_WALK_END
-
-        if (open_with_desktop)
+        if (getcwd(cwdbuf, sizeof(cwdbuf)))
           {
-            if (!strcmp(open_with_desktop, "..DESKTOP.."))
-              { // run the .de3sktop file Exec line
-                _file_desktop_run(sd, files);
+            if (cwd) chdir(cwd); // change cwd if asked
+            path = cmd_key_find(c, "path");
+            KEY_WALK_BEGIN
+            {
+              if (!strcmp(key, "path"))
+                {
+                  plist = eina_str_split(kdata, "\n", -1);
+                  for (p = plist; *p; p++)
+                    {
+                      fprintf(stderr, "ADD [%s]\n", *p);
+                      files = eina_list_append(files, eina_stringshare_add(*p));
+                    }
+                 free(*plist);
+                 free(plist);
+                }
+            }
+            KEY_WALK_END
+
+            if (open_with_desktop)
+              {
+                if (!strcmp(open_with_desktop, "..DESKTOP.."))
+                  { // run the .de3sktop file Exec line
+                    _file_desktop_run(sd, files);
+                  }
+                else if (!strcmp(open_with_desktop, "..EXECUTE.."))
+                  { // execute the file itself
+                    _file_execute_run(sd, files);
+                  }
+                else
+                  {
+                    d = efreet_desktop_new(open_with_desktop);
+                  }
               }
-            else if (!strcmp(open_with_desktop, "..EXECUTE.."))
-              { // execute the file itself
-                _file_execute_run(sd, files);
+            if (d)
+              {
+                _file_run(sd, d, files);
+                efreet_desktop_unref(d);
               }
             else
-              {
-                d = efreet_desktop_new(open_with_desktop);
+              { // XXX: pop up dialog to ask what to open with...
               }
+            EINA_LIST_FREE(files, file)
+            {
+              eina_stringshare_del(file);
+            }
+            chdir(cwdbuf); // restore previous cwd
           }
-        if (d)
-          {
-            _file_run(sd, d, files);
-            efreet_desktop_unref(d);
-          }
-        else
-          { // XXX: pop up dialog to ask what to open with...
-          }
-        EINA_LIST_FREE(files, file)
-        {
-          eina_stringshare_del(file);
-        }
         CMD_DONE;
       }
     label = cmd_key_find(c, "link-label");

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.

Reply via email to