Compare commits
10 Commits
Author | SHA1 | Date |
---|---|---|
wdlkmpx | f3ff2c62eb | |
wdlkmpx | f3043727dc | |
wdlkmpx | e8dd889f24 | |
wdlkmpx | 802a4bda50 | |
wdlkmpx | e390c1e063 | |
wdlkmpx | 0573d99082 | |
wdlkmpx | ee2560d57f | |
PRESFIL | 8e1c8718ae | |
wdlkmpx | c9e22f006a | |
wdlkmpx | 78cac66790 |
1
AUTHORS
1
AUTHORS
|
@ -10,6 +10,7 @@ Henning Schild
|
||||||
Makoto Nokata
|
Makoto Nokata
|
||||||
mishoo
|
mishoo
|
||||||
Paweł Błaszczyk
|
Paweł Błaszczyk
|
||||||
|
PRESFIL
|
||||||
R. Tyler Croy
|
R. Tyler Croy
|
||||||
Samuel Bauer
|
Samuel Bauer
|
||||||
sonofkojak
|
sonofkojak
|
||||||
|
|
17
ChangeLog
17
ChangeLog
|
@ -1,3 +1,20 @@
|
||||||
|
==========
|
||||||
|
gmrun 1.1w
|
||||||
|
==========
|
||||||
|
|
||||||
|
PRESFIL (1):
|
||||||
|
Fix xterm -e handling with multiword queryes
|
||||||
|
|
||||||
|
wdlkmpx (7):
|
||||||
|
restore system(3) call as the default option to run commands
|
||||||
|
main.c: ext_check(): escape spaces only if USE_XDG = 1
|
||||||
|
rename USE_XDG to USE_GLIB_XDG
|
||||||
|
gmrunrc: EXT syntax-> EXT:ext,etc = handler '%s'
|
||||||
|
main.c: main() gtk3.4+: hide cmd line args from GApplication
|
||||||
|
main.c (gtk3.4+): G_APPLICATION_NON_UNIQUE
|
||||||
|
merge data/zrelease into autogen.sh ..
|
||||||
|
|
||||||
|
|
||||||
==========
|
==========
|
||||||
gmrun 1.0w
|
gmrun 1.0w
|
||||||
==========
|
==========
|
||||||
|
|
16
autogen.sh
16
autogen.sh
|
@ -1,6 +1,22 @@
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
# Run this to generate all the initial makefiles, etc.
|
# Run this to generate all the initial makefiles, etc.
|
||||||
|
|
||||||
|
if test "$1" == "release" || test "$1" == "--release" ; then
|
||||||
|
pkg="$(grep -m1 AC_INIT configure.ac | cut -f 2 -d '[' | cut -f 1 -d ']')"
|
||||||
|
ver="$(grep -m1 AC_INIT configure.ac | cut -f 3 -d '[' | cut -f 1 -d ']')"
|
||||||
|
ver=$(echo $ver)
|
||||||
|
dir=${pkg}-${ver}
|
||||||
|
rm -rf ../$dir
|
||||||
|
mkdir -p ../$dir
|
||||||
|
cp -rf $PWD/* ../$dir
|
||||||
|
( cd ../$dir ; ./autogen.sh )
|
||||||
|
cd ..
|
||||||
|
tar -Jcf ${dir}.tar.xz $dir
|
||||||
|
exit
|
||||||
|
fi
|
||||||
|
|
||||||
|
#===========================================================================
|
||||||
|
|
||||||
srcdir=`dirname $0`
|
srcdir=`dirname $0`
|
||||||
test -z "$srcdir" && srcdir=.
|
test -z "$srcdir" && srcdir=.
|
||||||
cd $srcdir
|
cd $srcdir
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
# Process this file with autoconf to produce a configure script.
|
# Process this file with autoconf to produce a configure script.
|
||||||
|
|
||||||
AC_INIT([gmrun], [1.0w])
|
AC_INIT([gmrun], [1.1w])
|
||||||
AM_CONFIG_HEADER([config.h])
|
AM_CONFIG_HEADER([config.h])
|
||||||
AM_INIT_AUTOMAKE([-Wall foreign])
|
AM_INIT_AUTOMAKE([-Wall foreign])
|
||||||
AC_CONFIG_MACRO_DIR([m4])
|
AC_CONFIG_MACRO_DIR([m4])
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
.\" First parameter, NAME, should be all caps
|
.\" First parameter, NAME, should be all caps
|
||||||
.\" Second parameter, SECTION, should be 1-8, maybe w/ subsection
|
.\" Second parameter, SECTION, should be 1-8, maybe w/ subsection
|
||||||
.\" other parameters are allowed: see man(7), man(1)
|
.\" other parameters are allowed: see man(7), man(1)
|
||||||
.TH gmrun 1 "2020"
|
.TH gmrun 1.1w "2021"
|
||||||
.\" Please adjust this date whenever revising the manpage.
|
.\" Please adjust this date whenever revising the manpage.
|
||||||
.\"
|
.\"
|
||||||
.\" Some roff macros, for reference:
|
.\" Some roff macros, for reference:
|
||||||
|
@ -54,10 +54,10 @@ Whether to show the last command as initial text, or an empty textarea (1 or 0).
|
||||||
Whether the initial text should be selected or not (1 or 0).
|
Whether the initial text should be selected or not (1 or 0).
|
||||||
.SH URL/File HANDLING
|
.SH URL/File HANDLING
|
||||||
.TP
|
.TP
|
||||||
.B USE_XDG = 1
|
.B USE_GLIB_XDG = 1
|
||||||
For automatic URL and File handling using the freedesktop specification.
|
For automatic URL and File handling using the freedesktop specification.
|
||||||
.TP
|
.TP
|
||||||
See /etc/gmrunrc for custom URL and extension handlers (USE_XDG = 0)
|
See /etc/gmrunrc for custom URL and extension handlers (USE_GLIB_XDG = 0)
|
||||||
.TP
|
.TP
|
||||||
The included configuration files have a few examples which you can work with. You should also note that the protocol part of URL_protocol can be *anything*. You can set up "URL_foobarbazcustom", and so long as you enter in "foobarbazcustom:<whatever>", it will use the given program.
|
The included configuration files have a few examples which you can work with. You should also note that the protocol part of URL_protocol can be *anything*. You can set up "URL_foobarbazcustom", and so long as you enter in "foobarbazcustom:<whatever>", it will use the given program.
|
||||||
.SH SEE ALSO
|
.SH SEE ALSO
|
||||||
|
|
31
data/gmrunrc
31
data/gmrunrc
|
@ -28,26 +28,35 @@ ShowDotFiles = 0
|
||||||
# Set this to NULL if don't like this feature.
|
# Set this to NULL if don't like this feature.
|
||||||
TabTimeout = 0
|
TabTimeout = 0
|
||||||
|
|
||||||
|
# Use libc's system(3) to run commands, this includes any shell command
|
||||||
|
# and special stuff that only a shell interpreter can understand
|
||||||
|
# Set to 0 if you want a more conservative approach where the file to run
|
||||||
|
# is validated and errors running files are reported (without closing the gmrun window)
|
||||||
|
SHELL_RUN = 1
|
||||||
|
|
||||||
|
|
||||||
# use GLib XDG handling? (freedesktop specification)
|
# use GLib XDG handling? (freedesktop specification)
|
||||||
USE_XDG = 0
|
USE_GLIB_XDG = 0
|
||||||
|
|
||||||
#=======================================================================
|
#=======================================================================
|
||||||
# if not using XDG, you can specify URL and extension Handlers...
|
# USE_GLIB_XDG = 0, you can specify URL and extension Handlers...
|
||||||
#=======================================================================
|
#=======================================================================
|
||||||
|
|
||||||
# URL handlers
|
# URL handlers
|
||||||
# If the entered text is "http://www.google.com" then:
|
# If the entered text is "http://www.google.com" then:
|
||||||
# - %u gets replaced with the whole URL ("http://www.google.com")
|
# - %u gets replaced with the whole URL ("http://www.google.com")
|
||||||
# - %s gets replaced with "//www.google.com". This is useful for URL-s
|
# - %s gets replaced with "//www.google.com".
|
||||||
# like "man:printf" --> %s will get replaced with "printf"
|
# useful for URL's like "man:printf" --> %s becomes printf
|
||||||
URL_http = xdg-open %u
|
URL_http = xdg-open '%u'
|
||||||
URL_mailto = xdg-email %u
|
URL_mailto = xdg-email '%u'
|
||||||
URL_file = xdg-open %s
|
URL_file = xdg-open '%s'
|
||||||
URL_man = ${TermExec} 'man %s'
|
URL_man = ${TermExec} man %s
|
||||||
URL_info = ${TermExec} 'info %s'
|
URL_info = ${TermExec} info %s
|
||||||
URL_search = xdg-open 'http://www.google.com/search?q=%s'
|
URL_search = xdg-open 'http://www.google.com/search?q=%s'
|
||||||
|
|
||||||
# extension handlers
|
# extension handlers
|
||||||
# Customize your own extension handler.
|
# Customize your own extension handler.
|
||||||
EXT:doc,rtf,txt,cc,cpp,h,java,html,htm,epl,tex,latex,js,css,xml,xsl,am,ps,pdf = xdg-open %s
|
# syntax-> EXT:ext,etc = handler '%s'
|
||||||
|
EXT:doc,rtf,txt,cc,cpp,h,java,html,htm,epl,tex,latex,js,css,xml,xsl,am,ps,pdf = xdg-open '%s'
|
||||||
|
EXT:mkv,mp4,avi,asf,wmv = xdg-open '%s'
|
||||||
|
EXT:mp3,flac,ogg,aac,wav = xdg-open '%s'
|
||||||
|
|
|
@ -1,24 +0,0 @@
|
||||||
#!/bin/sh
|
|
||||||
|
|
||||||
pkg=gmrun
|
|
||||||
ver=$(grep AC_INIT configure.ac | cut -f 3 -d '[' | cut -f 1 -d ']')
|
|
||||||
|
|
||||||
dir=${pkg}-${ver}
|
|
||||||
|
|
||||||
mkdir -p ../$dir
|
|
||||||
|
|
||||||
cp -rf $PWD/* ../$dir
|
|
||||||
|
|
||||||
(
|
|
||||||
cd ../$dir
|
|
||||||
./autogen.sh
|
|
||||||
rm -rf autom4te.cache
|
|
||||||
#rm -rf m4
|
|
||||||
rm -f make-release
|
|
||||||
)
|
|
||||||
|
|
||||||
cd ..
|
|
||||||
|
|
||||||
tar -Jcf ${dir}.tar.xz $dir
|
|
||||||
|
|
||||||
### END ###
|
|
71
src/main.c
71
src/main.c
|
@ -31,6 +31,8 @@
|
||||||
#include "gtkcompletionline.h"
|
#include "gtkcompletionline.h"
|
||||||
#include "config_prefs.h"
|
#include "config_prefs.h"
|
||||||
|
|
||||||
|
#define CMD_LENGTH 1024
|
||||||
|
|
||||||
enum
|
enum
|
||||||
{
|
{
|
||||||
W_TEXT_STYLE_NORMAL,
|
W_TEXT_STYLE_NORMAL,
|
||||||
|
@ -50,7 +52,8 @@ GtkWidget * wlabel;
|
||||||
GtkWidget * wlabel_search;
|
GtkWidget * wlabel_search;
|
||||||
|
|
||||||
/* preferences */
|
/* preferences */
|
||||||
int USE_XDG = 0;
|
int USE_GLIB_XDG = 0;
|
||||||
|
int SHELL_RUN = 1;
|
||||||
|
|
||||||
/// BEGIN: TIMEOUT MANAGEMENT
|
/// BEGIN: TIMEOUT MANAGEMENT
|
||||||
|
|
||||||
|
@ -93,12 +96,30 @@ static void set_info_text_color (GtkWidget *w, const char *text, int spec)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
|
||||||
run_the_command (const char * cmd)
|
static void run_the_command (char * cmd)
|
||||||
{
|
{
|
||||||
#if DEBUG
|
#if DEBUG
|
||||||
fprintf (stderr, "command: %s\n", cmd);
|
fprintf (stderr, "command: %s\n", cmd);
|
||||||
#endif
|
#endif
|
||||||
|
if (SHELL_RUN)
|
||||||
|
{
|
||||||
|
// need to add extra &
|
||||||
|
if (strlen (cmd) < (CMD_LENGTH-10)) {
|
||||||
|
strcat (cmd, " &"); /* safe to use in this case */
|
||||||
|
}
|
||||||
|
int ret = system (cmd);
|
||||||
|
if (ret != -1) {
|
||||||
|
gmrun_exit ();
|
||||||
|
} else {
|
||||||
|
char errmsg[256];
|
||||||
|
snprintf (errmsg, sizeof(errmsg)-1, "ERROR: %s", strerror (errno));
|
||||||
|
set_info_text_color (wlabel, errmsg, W_TEXT_STYLE_NOTFOUND);
|
||||||
|
add_search_off_timeout (3000, NULL);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else // glib - more conservative approach and robust error reporting
|
||||||
|
{
|
||||||
GError * error = NULL;
|
GError * error = NULL;
|
||||||
gboolean success;
|
gboolean success;
|
||||||
int argc;
|
int argc;
|
||||||
|
@ -110,7 +131,6 @@ run_the_command (const char * cmd)
|
||||||
add_search_off_timeout (3000, NULL);
|
add_search_off_timeout (3000, NULL);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
success = g_spawn_async (NULL, argv, NULL,
|
success = g_spawn_async (NULL, argv, NULL,
|
||||||
G_SPAWN_SEARCH_PATH, NULL, NULL, NULL, &error);
|
G_SPAWN_SEARCH_PATH, NULL, NULL, NULL, &error);
|
||||||
if (argv) {
|
if (argv) {
|
||||||
|
@ -123,12 +143,14 @@ run_the_command (const char * cmd)
|
||||||
g_error_free (error);
|
g_error_free (error);
|
||||||
add_search_off_timeout (3000, NULL);
|
add_search_off_timeout (3000, NULL);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
on_ext_handler (GtkCompletionLine *cl, const char * filename)
|
on_ext_handler (GtkCompletionLine *cl, const char * filename)
|
||||||
{
|
{
|
||||||
if (USE_XDG) // GLib XDG handling (freedesktop specification)
|
if (USE_GLIB_XDG) // GLib XDG handling (freedesktop specification)
|
||||||
{
|
{
|
||||||
gchar * content_type, * mime_type, * msg;
|
gchar * content_type, * mime_type, * msg;
|
||||||
const gchar * handler;
|
const gchar * handler;
|
||||||
|
@ -172,9 +194,10 @@ on_ext_handler (GtkCompletionLine *cl, const char * filename)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void on_compline_runwithterm (GtkCompletionLine *cl)
|
static void on_compline_runwithterm (GtkCompletionLine *cl)
|
||||||
{
|
{
|
||||||
char cmd[512];
|
char cmd[CMD_LENGTH];
|
||||||
char * term;
|
char * term;
|
||||||
char * entry_text = g_strdup (gtk_entry_get_text (GTK_ENTRY(cl)));
|
char * entry_text = g_strdup (gtk_entry_get_text (GTK_ENTRY(cl)));
|
||||||
g_strstrip (entry_text);
|
g_strstrip (entry_text);
|
||||||
|
@ -285,7 +308,7 @@ static void xdg_app_run_command (GAppInfo *app, const gchar *args)
|
||||||
/* Handler for URLs */
|
/* Handler for URLs */
|
||||||
static gboolean url_check (GtkCompletionLine *cl, char * entry_text)
|
static gboolean url_check (GtkCompletionLine *cl, char * entry_text)
|
||||||
{
|
{
|
||||||
if (USE_XDG) // GLib XDG handling (freedesktop specification)
|
if (USE_GLIB_XDG) // GLib XDG handling (freedesktop specification)
|
||||||
{
|
{
|
||||||
char * delim;
|
char * delim;
|
||||||
const char * url, * protocol;
|
const char * url, * protocol;
|
||||||
|
@ -379,8 +402,7 @@ static gboolean url_check (GtkCompletionLine *cl, char * entry_text)
|
||||||
|
|
||||||
|
|
||||||
static char * escape_spaces (char * entry_text)
|
static char * escape_spaces (char * entry_text)
|
||||||
{ // this for EXT handlers: replace " " with "\ "
|
{ // run file with glib: replace " " with "\ "
|
||||||
// it's the only way to make the command run if the filename contains spaces
|
|
||||||
GRegex * regex;
|
GRegex * regex;
|
||||||
char * quoted;
|
char * quoted;
|
||||||
if (!strstr (entry_text, "\\ ")) {
|
if (!strstr (entry_text, "\\ ")) {
|
||||||
|
@ -396,7 +418,7 @@ static char * escape_spaces (char * entry_text)
|
||||||
/* Handler for extensions */
|
/* Handler for extensions */
|
||||||
static gboolean ext_check (GtkCompletionLine *cl, char * entry_text)
|
static gboolean ext_check (GtkCompletionLine *cl, char * entry_text)
|
||||||
{
|
{
|
||||||
if (USE_XDG) // GLib XDG handling (freedesktop specification)
|
if (USE_GLIB_XDG) // GLib XDG handling (freedesktop specification)
|
||||||
{
|
{
|
||||||
char *quoted, *content_type, *mime_type;
|
char *quoted, *content_type, *mime_type;
|
||||||
GAppInfo *app_info;
|
GAppInfo *app_info;
|
||||||
|
@ -432,7 +454,7 @@ static gboolean ext_check (GtkCompletionLine *cl, char * entry_text)
|
||||||
}
|
}
|
||||||
else //-------- custom EXTension handlers
|
else //-------- custom EXTension handlers
|
||||||
{
|
{
|
||||||
// example: file.html -> `xdg-open %s` -> `xdg-open file.html`
|
// example: file.html | xdg-open '%s' -> xdg-open 'file.html'
|
||||||
char * cmd, * quoted;
|
char * cmd, * quoted;
|
||||||
char * ext = strrchr (entry_text, '.');
|
char * ext = strrchr (entry_text, '.');
|
||||||
char * handler_format = NULL;
|
char * handler_format = NULL;
|
||||||
|
@ -440,11 +462,12 @@ static gboolean ext_check (GtkCompletionLine *cl, char * entry_text)
|
||||||
handler_format = config_get_handler_for_extension (ext);
|
handler_format = config_get_handler_for_extension (ext);
|
||||||
}
|
}
|
||||||
if (handler_format) {
|
if (handler_format) {
|
||||||
quoted = escape_spaces (entry_text);
|
quoted = g_strcompress (entry_text); /* unescape chars */
|
||||||
if (strchr (handler_format, '%')) { // xdg-open %s
|
if (strstr (handler_format, "%s")) {
|
||||||
cmd = g_strdup_printf (handler_format, quoted);
|
cmd = g_strdup_printf (handler_format, quoted);
|
||||||
} else { // xdg-open
|
}
|
||||||
cmd = g_strconcat (handler_format, " ", quoted, NULL);
|
else { // xdg-open
|
||||||
|
cmd = g_strconcat (handler_format, " '", quoted, "'", NULL);
|
||||||
}
|
}
|
||||||
history_append (cl->hist, entry_text);
|
history_append (cl->hist, entry_text);
|
||||||
run_the_command (cmd);
|
run_the_command (cmd);
|
||||||
|
@ -470,7 +493,7 @@ static void on_compline_activated (GtkCompletionLine *cl)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
char cmd[512];
|
char cmd[CMD_LENGTH];
|
||||||
char * AlwaysInTerm = NULL;
|
char * AlwaysInTerm = NULL;
|
||||||
char ** term_progs = NULL;
|
char ** term_progs = NULL;
|
||||||
char * selected_term_prog = NULL;
|
char * selected_term_prog = NULL;
|
||||||
|
@ -510,7 +533,6 @@ static void on_compline_activated (GtkCompletionLine *cl)
|
||||||
static void gmrun_activate(void)
|
static void gmrun_activate(void)
|
||||||
{
|
{
|
||||||
GtkWidget *dialog, * main_vbox;
|
GtkWidget *dialog, * main_vbox;
|
||||||
|
|
||||||
GtkWidget *label_search;
|
GtkWidget *label_search;
|
||||||
|
|
||||||
GtkWidget * window = gtk_application_window_new (gmrun_app);
|
GtkWidget * window = gtk_application_window_new (gmrun_app);
|
||||||
|
@ -546,6 +568,10 @@ static void gmrun_activate(void)
|
||||||
gtk_widget_set_name (compline, "gmrun_compline");
|
gtk_widget_set_name (compline, "gmrun_compline");
|
||||||
gtk_box_pack_start (GTK_BOX (main_vbox), compline, TRUE, TRUE, 0);
|
gtk_box_pack_start (GTK_BOX (main_vbox), compline, TRUE, TRUE, 0);
|
||||||
|
|
||||||
|
if (!config_get_int ("SHELL_RUN", &SHELL_RUN)) {
|
||||||
|
SHELL_RUN = 1;
|
||||||
|
}
|
||||||
|
|
||||||
// don't show files starting with "." by default
|
// don't show files starting with "." by default
|
||||||
if (!config_get_int ("ShowDotFiles", &(GTK_COMPLETION_LINE(compline)->show_dot_files))) {
|
if (!config_get_int ("ShowDotFiles", &(GTK_COMPLETION_LINE(compline)->show_dot_files))) {
|
||||||
GTK_COMPLETION_LINE(compline)->show_dot_files = 0;
|
GTK_COMPLETION_LINE(compline)->show_dot_files = 0;
|
||||||
|
@ -554,8 +580,8 @@ static void gmrun_activate(void)
|
||||||
if (!config_get_int ("TabTimeout", &tmp)) {
|
if (!config_get_int ("TabTimeout", &tmp)) {
|
||||||
((GtkCompletionLine*)compline)->tabtimeout = tmp;
|
((GtkCompletionLine*)compline)->tabtimeout = tmp;
|
||||||
}
|
}
|
||||||
if (!config_get_int ("USE_XDG", &USE_XDG)) {
|
if (!config_get_int ("USE_GLIB_XDG", &USE_GLIB_XDG)) {
|
||||||
USE_XDG = 0;
|
USE_GLIB_XDG = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
g_signal_connect(G_OBJECT(compline), "cancel",
|
g_signal_connect(G_OBJECT(compline), "cancel",
|
||||||
|
@ -731,8 +757,11 @@ int main(int argc, char **argv)
|
||||||
config_init ();
|
config_init ();
|
||||||
parse_command_line (argc, argv);
|
parse_command_line (argc, argv);
|
||||||
|
|
||||||
#if GTK_CHECK_VERSION(3, 0, 0)
|
#if GTK_CHECK_VERSION(3, 4, 0)
|
||||||
gmrun_app = gtk_application_new ("org.gtk.gmrun", G_APPLICATION_FLAGS_NONE);
|
// Handling cmd line args with GApplication is a nightmare
|
||||||
|
// follow this: https://developer.gnome.org/gtkmm-tutorial/stable/sec-multi-item-containers.html.en#boxes-command-line-options
|
||||||
|
argc = 1; /* hide args from GApplication */
|
||||||
|
gmrun_app = gtk_application_new ("org.gtk.gmrun", G_APPLICATION_NON_UNIQUE);
|
||||||
g_signal_connect (gmrun_app, "activate", gmrun_activate, NULL);
|
g_signal_connect (gmrun_app, "activate", gmrun_activate, NULL);
|
||||||
status = g_application_run (G_APPLICATION (gmrun_app), argc, argv);
|
status = g_application_run (G_APPLICATION (gmrun_app), argc, argv);
|
||||||
g_object_unref (gmrun_app);
|
g_object_unref (gmrun_app);
|
||||||
|
|
Loading…
Reference in New Issue