Enable xfce4-minicmd-plugin to launch web- and ftp-adresses

"Kristian Rumberg" <[email protected]>
Newsgroups gmane.comp.desktop.xfce.goodies.devel
Message-ID <[email protected]>
Hi

I'm very new at this, but I'v been using gnu/linux now and I know basic 
programming. I love Xfce4 but I found it frustrating that you couldn't 
launch a browser or ftp-client by entering that kind of address in the 
mini-command-line so I wrote a tiny hack :P  It's not very pretty code and 
I/you should make it configurable so that the user can select which browser 
to use for ftp sftp and http - maybe something for the settings manager?

Anyhow since I want to help but don't know where to send my code I post it 
here (it's not very long). Please send suggestions and tell where I should 
send my code

///// in command.c    I add these two functions

gboolean cmd_is_httpaddress(const char * cmd)
{
  return(!strncmp(cmd, "http://", 7) || !strncmp(cmd, "www.", 4));
}

gboolean cmd_is_ftpaddress(const char * cmd)
{
  return(!strncmp(cmd, "ftp://", 6) || !strncmp(cmd, "sftp://", 7) );
}

/// end code


Then I modify do_run  into this

static gboolean do_run(const char *cmd, gboolean in_terminal)
{
    gchar *execute, *path;
    gboolean success;

    g_return_val_if_fail(cmd != NULL, FALSE);


    /* check if the user has entered a http or www command */
    if (cmd_is_httpaddress(cmd))
    {
      execute = g_strconcat("firefox ", cmd, NULL);
      success = exec_command(execute);
      g_free(execute);

      return success;
    }

    /* check if the user has entered a sftp or ftp command */
    if (cmd_is_ftpaddress(cmd))
    {
      execute = g_strconcat("nautilus ", cmd, NULL);
      success = exec_command(execute);
      g_free(execute);

      return success;
    }

// and the function continues

What do you think? My solution is not very pretty but it sure works (not 
very safe though), and it can be modifies into becoming a lot more 
configurable, but I just needed this code for myself so I wrote it :P  Maybe 
you like it too?
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.