From ff88d3d6d7673ee3d703e66590f837a641828010 Mon Sep 17 00:00:00 2001 From: Dave Davenport Date: Fri, 6 Jan 2017 14:45:45 +0100 Subject: [PATCH 1/2] Issue: #521. Add -[no]-show-match to manpage. --- doc/rofi-manpage.markdown | 5 +++++ doc/rofi.1 | 10 ++++++++-- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/doc/rofi-manpage.markdown b/doc/rofi-manpage.markdown index d159b87a..8d3957d4 100644 --- a/doc/rofi-manpage.markdown +++ b/doc/rofi-manpage.markdown @@ -48,6 +48,7 @@ [ -no-click-to-exit ] [ -threads *num* ] [ -config *filename* ] +[ -no-show-match ] ## DESCRIPTION @@ -204,6 +205,10 @@ Load alternative configuration file. Select the scrolling method. 0: Per page, 1: continuous. +`-no-show-match` + +Hide the indicator that shows what part of the string is matched. + ### Theming All colors are either hex #rrggbb, #aarrggbb or argb:aarrggbbvalues or X11 color names. diff --git a/doc/rofi.1 b/doc/rofi.1 index fbd20911..3217a6a2 100644 --- a/doc/rofi.1 +++ b/doc/rofi.1 @@ -1,13 +1,13 @@ .\" generated with Ronn/v0.7.3 .\" http://github.com/rtomayko/ronn/tree/0.7.3 . -.TH "ROFI\-MANPAGE" "" "2016-12-23" "" "" +.TH "ROFI\-MANPAGE" "" "January 2017" "" "" . .SH "NAME" \fBrofi\fR \- A window switcher, run launcher, ssh dialog and dmenu replacement . .SH "SYNOPSIS" -\fBrofi\fR [ \-width \fIpct_scr\fR ] [ \-lines \fIlines\fR ] [ \-columns \fIcolumns\fR ] [ \-font \fIpangofont\fR ] [ \-terminal \fIterminal\fR ] [ \-location \fIposition\fR ] [ \-fixed\-num\-lines ] [ \-padding \fIpadding\fR ] [ \-display \fIdisplay\fR ] [ \-bw \fIwidth\fR ] [ \-dmenu [ \-p \fIprompt\fR ] [ \-sep \fIseparator\fR ] [ \-l \fIselected line\fR ] [ \-mesg ] [ \-select ] [ \-input \fIinput\fR ] ] [ \-filter \fIfilter\fR ] [ \-ssh\-client \fIclient\fR ] [ \-ssh\-command \fIcommand\fR ] [ \-window\-command \fIcommand\fR ] [ \-disable\-history ] [ \-levenshtein\-sort ] [ \-case\-sensitive ] [ \-cycle ] [ \-show \fImode\fR ] [ \-modi \fImode1,mode2\fR ] [ \-eh \fIelement height\fR ] [ \-e \fImessage\fR] [ \-a \fIrow\fR ] [ \-u \fIrow\fR ] [ \-pid \fIpath\fR ] [ \-version ] [ \-help ] [ \-dump\-xresources ] [ \-dump\-xresources\-theme ] [ \-auto\-select ] [ \-parse\-hosts ] [ \-no\-parse\-known\-hosts ] [ \-combi\-modi \fImode1,mode2\fR ] [ \-normal\-window ] [ \-fake\-transparency ] [ \-matching \fImethod\fR ] [ \-tokenize ] [ \-no\-click\-to\-exit ] [ \-threads \fInum\fR ] [ \-config \fIfilename\fR ] +\fBrofi\fR [ \-width \fIpct_scr\fR ] [ \-lines \fIlines\fR ] [ \-columns \fIcolumns\fR ] [ \-font \fIpangofont\fR ] [ \-terminal \fIterminal\fR ] [ \-location \fIposition\fR ] [ \-fixed\-num\-lines ] [ \-padding \fIpadding\fR ] [ \-display \fIdisplay\fR ] [ \-bw \fIwidth\fR ] [ \-dmenu [ \-p \fIprompt\fR ] [ \-sep \fIseparator\fR ] [ \-l \fIselected line\fR ] [ \-mesg ] [ \-select ] [ \-input \fIinput\fR ] ] [ \-filter \fIfilter\fR ] [ \-ssh\-client \fIclient\fR ] [ \-ssh\-command \fIcommand\fR ] [ \-window\-command \fIcommand\fR ] [ \-disable\-history ] [ \-levenshtein\-sort ] [ \-case\-sensitive ] [ \-cycle ] [ \-show \fImode\fR ] [ \-modi \fImode1,mode2\fR ] [ \-eh \fIelement height\fR ] [ \-e \fImessage\fR] [ \-a \fIrow\fR ] [ \-u \fIrow\fR ] [ \-pid \fIpath\fR ] [ \-version ] [ \-help ] [ \-dump\-xresources ] [ \-dump\-xresources\-theme ] [ \-auto\-select ] [ \-parse\-hosts ] [ \-no\-parse\-known\-hosts ] [ \-combi\-modi \fImode1,mode2\fR ] [ \-normal\-window ] [ \-fake\-transparency ] [ \-matching \fImethod\fR ] [ \-tokenize ] [ \-no\-click\-to\-exit ] [ \-threads \fInum\fR ] [ \-config \fIfilename\fR ] [ \-no\-show\-match ] . .SH "DESCRIPTION" \fBrofi\fR is an X11 popup window switcher, run dialog, dmenu replacement and more\. It focuses on being fast to use and have minimal distraction\. It supports keyboard and mouse navigation, type to filter, tokenized search and more\. @@ -294,6 +294,12 @@ Load alternative configuration file\. .P Select the scrolling method\. 0: Per page, 1: continuous\. . +.P +\fB\-no\-show\-match\fR +. +.P +Hide the indicator that shows what part of the string is matched\. +. .SS "Theming" All colors are either hex #rrggbb, #aarrggbb or argb:aarrggbbvalues or X11 color names\. . From c98b67ed0d14c26bc0e022461f3a432c64c9cd80 Mon Sep 17 00:00:00 2001 From: Dave Davenport Date: Sat, 7 Jan 2017 10:35:36 +0100 Subject: [PATCH 2/2] Make lazy-key-grab an option, add --release for i3 to manpage. --- doc/rofi-manpage.markdown | 13 +++++++++++++ doc/rofi.1 | 12 ++++++++++++ source/rofi.c | 23 ++++++++++++++++++----- 3 files changed, 43 insertions(+), 5 deletions(-) diff --git a/doc/rofi-manpage.markdown b/doc/rofi-manpage.markdown index 8d3957d4..f0179355 100644 --- a/doc/rofi-manpage.markdown +++ b/doc/rofi-manpage.markdown @@ -209,6 +209,10 @@ Select the scrolling method. 0: Per page, 1: continuous. Hide the indicator that shows what part of the string is matched. +`-lazy-grab` + +When fail to grab keyboard, don't block but retry later in background. + ### Theming All colors are either hex #rrggbb, #aarrggbb or argb:aarrggbbvalues or X11 color names. @@ -886,6 +890,15 @@ Use `qalc` to get a simple calculator in **rofi**: rofi -show calc -modi "calc:qalc +u8 -nocurrencies" +## I3 + +In [I3](http://i3wm.org/) you want to bind rofi to be launched on key-release. Otherwise it cannot grab the keyboard. +See also the I3 [manual](http://i3wm.org/docs/userguide.html): + +Some tools (such as import or xdotool) might be unable to run upon a KeyPress event, because the keyboard/pointer is +still grabbed. For these situations, the --release flag can be used, which will execute the command after the keys have +been released. + ## LICENSE MIT/X11 diff --git a/doc/rofi.1 b/doc/rofi.1 index 3217a6a2..dea91f1e 100644 --- a/doc/rofi.1 +++ b/doc/rofi.1 @@ -300,6 +300,12 @@ Select the scrolling method\. 0: Per page, 1: continuous\. .P Hide the indicator that shows what part of the string is matched\. . +.P +\fB\-lazy\-grab\fR +. +.P +When fail to grab keyboard, don\'t block but retry later in background\. +. .SS "Theming" All colors are either hex #rrggbb, #aarrggbb or argb:aarrggbbvalues or X11 color names\. . @@ -1469,6 +1475,12 @@ Use \fBqalc\fR to get a simple calculator in \fBrofi\fR: . .IP "" 0 . +.SH "I3" +In I3 \fIhttp://i3wm\.org/\fR you want to bind rofi to be launched on key\-release\. Otherwise it cannot grab the keyboard\. See also the I3 manual \fIhttp://i3wm\.org/docs/userguide\.html\fR: +. +.P +Some tools (such as import or xdotool) might be unable to run upon a KeyPress event, because the keyboard/pointer is still grabbed\. For these situations, the \-\-release flag can be used, which will execute the command after the keys have been released\. +. .SH "LICENSE" . .nf diff --git a/source/rofi.c b/source/rofi.c index 2d2e11e7..ebd16168 100644 --- a/source/rofi.c +++ b/source/rofi.c @@ -252,6 +252,7 @@ static void print_main_application_options ( int is_term ) print_help_msg ( "-markup", "", "Enable pango markup where possible.", NULL, is_term ); print_help_msg ( "-normal-window", "", "In dmenu mode, behave as a normal window. (experimental)", NULL, is_term ); print_help_msg ( "-show", "[mode]", "Show the mode 'mode' and exit. The mode has to be enabled.", NULL, is_term ); + print_help_msg ( "-lazy-grab", "", "When fail to grab keyboard, don't block but retry later.", NULL, is_term ); } static void help ( G_GNUC_UNUSED int argc, char **argv ) { @@ -625,11 +626,23 @@ static gboolean startup ( G_GNUC_UNUSED gpointer data ) // We grab this using the rootwindow (as dmenu does it). // this seems to result in the smallest delay for most people. if ( ( window_flags & MENU_NORMAL_WINDOW ) == 0 ) { - if ( !take_keyboard ( xcb_stuff_get_root_window ( xcb), 0) ){ - g_timeout_add ( 1,lazy_grab_keyboard, NULL); - } - if ( !take_pointer ( xcb_stuff_get_root_window ( xcb ), 0 )) { - g_timeout_add ( 1,lazy_grab_pointer, NULL); + if ( find_arg ( "-lazy-grab") >= 0 ){ + if ( !take_keyboard ( xcb_stuff_get_root_window ( xcb), 0) ){ + g_timeout_add ( 1,lazy_grab_keyboard, NULL); + } + if ( !take_pointer ( xcb_stuff_get_root_window ( xcb ), 0 )) { + g_timeout_add ( 1,lazy_grab_pointer, NULL); + } + } else { + if ( !take_keyboard ( xcb_stuff_get_root_window ( xcb), 500) ){ + fprintf ( stderr, "Failed to grab keyboard, even after %d uS.", 500 * 1000 ); + g_main_loop_quit ( main_loop ); + return G_SOURCE_REMOVE; + } + if ( ! take_pointer ( xcb_stuff_get_root_window ( xcb ), 100 ) ) { + fprintf ( stderr, "Failed to grab mouse pointer, even after %d uS.", 100*1000); + } + } } TICK_N ( "Grab keyboard" );