diff --git a/doc/rofi-manpage.markdown b/doc/rofi-manpage.markdown index 6e2a6b1b..aea63610 100644 --- a/doc/rofi-manpage.markdown +++ b/doc/rofi-manpage.markdown @@ -329,6 +329,14 @@ the following keys can be used that will be replaced at runtime: * `{ssh-client}`: The configured ssh client (See -ssh-client) * `{cmd}`: The command to execute. +## Dmenu replacemnt + +If `argv[0]` (calling command) is dmenu, **rofi** will start in dmenu mode. +This way it can be used as a drop-in replacement for dmenu. just copy or symlink **rofi** to dmenu in `$PATH`. + + + ln -s /usr/bin/dmenu /usr/bin/rofi + ## Keybindings Rofi supports the following keybindings: diff --git a/doc/rofi.1 b/doc/rofi.1 index 6f0b669f..3e343ec8 100644 --- a/doc/rofi.1 +++ b/doc/rofi.1 @@ -412,6 +412,16 @@ the following keys can be used that will be replaced at runtime: .IP \(bu 2 \fB\fC{cmd}\fR: The command to execute. .RE +.SH Dmenu replacemnt +.PP +If \fB\fCargv[0]\fR (calling command) is dmenu, \fBrofi\fP will start in dmenu mode. +This way it can be used as a drop\-in replacement for dmenu. just copy or symlink \fBrofi\fP to dmenu in \fB\fC$PATH\fR\&. +.PP +.RS +.nf +ln \-s /usr/bin/dmenu /usr/bin/rofi +.fi +.RE .SH Keybindings .PP Rofi supports the following keybindings: @@ -456,18 +466,14 @@ Rofi supports the following keybindings: .SH WEBSITE .PP \fBrofi\fP website can be found at here -.UR https://davedavenport.github.io/rofi/ -.UE +\[la]https://davedavenport.github.io/rofi/\[ra] .PP \fBrofi\fP bugtracker can be found here -.UR https://github.com/DaveDavenport/rofi/issues -.UE +\[la]https://github.com/DaveDavenport/rofi/issues\[ra] .SH AUTHOR .PP Qball Cow -.MT qball@gmpclient.org -.ME +\[la]qball@gmpclient.org\[ra] .PP Original code based on work by: Sean Pringle -.MT sean.pringle@gmail.com -.ME +\[la]sean.pringle@gmail.com\[ra] diff --git a/source/rofi.c b/source/rofi.c index c6594530..5682daa8 100644 --- a/source/rofi.c +++ b/source/rofi.c @@ -75,10 +75,10 @@ int config_i3_mode = 0; char *i3_socket_path = NULL; #endif -const char *cache_dir = NULL; -unsigned int NumlockMask = 0; -Display *display = NULL; -char *display_str = NULL; +const char *cache_dir = NULL; +unsigned int NumlockMask = 0; +Display *display = NULL; +char *display_str = NULL; typedef struct _Switcher @@ -1895,7 +1895,7 @@ SwitcherMode run_switcher_window ( char **input, G_GNUC_UNUSED void *data ) } else{ #endif - sprintf ( pattern, "%%-%ds %%-%ds %%s", desktops < 10 ? 1 : 2, MAX ( 5, classfield ) ); + sprintf ( pattern, "%%-%ds %%-%ds %%s", desktops < 10 ? 1 : 2, MAX ( 5, classfield ) ); #ifdef HAVE_I3_IPC_H } #endif @@ -2320,7 +2320,7 @@ static void config_sanity_check ( void ) exit ( 1 ); } if ( config.element_height < 1 ) { - fprintf( stderr, "config.element_height is invalid. It needs to be atleast 1 line high.\n"); + fprintf ( stderr, "config.element_height is invalid. It needs to be atleast 1 line high.\n" ); exit ( 1 ); } if ( config.menu_columns == 0 ) { @@ -2477,7 +2477,15 @@ int main ( int argc, char *argv[] ) // flags to run immediately and exit char *sname = NULL; - if ( find_arg_str ( argc, argv, "-show", &sname ) == TRUE ) { + if ( find_arg ( argc, argv, "-dmenu" ) >= 0 || strcmp ( argv[0], "dmenu" ) == 0 ) { + find_arg_str ( argc, argv, "-p", &dmenu_prompt ); + int retv = run_dmenu (); + // User cancelled the operation. + if ( retv == FALSE ) { + return EXIT_FAILURE; + } + } + else if ( find_arg_str ( argc, argv, "-show", &sname ) == TRUE ) { int index = switcher_get ( sname ); if ( index >= 0 ) { run_switcher ( FALSE, index ); @@ -2514,14 +2522,6 @@ int main ( int argc, char *argv[] ) fprintf ( stderr, "The ssh dialog has not been enabled\n" ); } } - else if ( find_arg ( argc, argv, "-dmenu" ) >= 0 ) { - find_arg_str ( argc, argv, "-p", &dmenu_prompt ); - int retv = run_dmenu (); - // User cancelled the operation. - if ( retv == FALSE ) { - return EXIT_FAILURE; - } - } else{ // Daemon mode, Listen to key presses.. if ( switcher_get ( "window" ) >= 0 ) {