If argv[0] is dmenu, launch in dmenu mode.

This commit is contained in:
Dave Davenport 2014-11-05 10:27:46 +01:00
parent da7ba544fc
commit b27725834c
3 changed files with 37 additions and 23 deletions

View File

@ -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) * `{ssh-client}`: The configured ssh client (See -ssh-client)
* `{cmd}`: The command to execute. * `{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 ## Keybindings
Rofi supports the following keybindings: Rofi supports the following keybindings:

View File

@ -412,6 +412,16 @@ the following keys can be used that will be replaced at runtime:
.IP \(bu 2 .IP \(bu 2
\fB\fC{cmd}\fR: The command to execute. \fB\fC{cmd}\fR: The command to execute.
.RE .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 .SH Keybindings
.PP .PP
Rofi supports the following keybindings: Rofi supports the following keybindings:
@ -456,18 +466,14 @@ Rofi supports the following keybindings:
.SH WEBSITE .SH WEBSITE
.PP .PP
\fBrofi\fP website can be found at here \fBrofi\fP website can be found at here
.UR https://davedavenport.github.io/rofi/ \[la]https://davedavenport.github.io/rofi/\[ra]
.UE
.PP .PP
\fBrofi\fP bugtracker can be found here \fBrofi\fP bugtracker can be found here
.UR https://github.com/DaveDavenport/rofi/issues \[la]https://github.com/DaveDavenport/rofi/issues\[ra]
.UE
.SH AUTHOR .SH AUTHOR
.PP .PP
Qball Cow Qball Cow
.MT qball@gmpclient.org \[la]qball@gmpclient.org\[ra]
.ME
.PP .PP
Original code based on work by: Sean Pringle Original code based on work by: Sean Pringle
.MT sean.pringle@gmail.com \[la]sean.pringle@gmail.com\[ra]
.ME

View File

@ -75,10 +75,10 @@ int config_i3_mode = 0;
char *i3_socket_path = NULL; char *i3_socket_path = NULL;
#endif #endif
const char *cache_dir = NULL; const char *cache_dir = NULL;
unsigned int NumlockMask = 0; unsigned int NumlockMask = 0;
Display *display = NULL; Display *display = NULL;
char *display_str = NULL; char *display_str = NULL;
typedef struct _Switcher typedef struct _Switcher
@ -1895,7 +1895,7 @@ SwitcherMode run_switcher_window ( char **input, G_GNUC_UNUSED void *data )
} }
else{ else{
#endif #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 #ifdef HAVE_I3_IPC_H
} }
#endif #endif
@ -2320,7 +2320,7 @@ static void config_sanity_check ( void )
exit ( 1 ); exit ( 1 );
} }
if ( config.element_height < 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 ); exit ( 1 );
} }
if ( config.menu_columns == 0 ) { if ( config.menu_columns == 0 ) {
@ -2477,7 +2477,15 @@ int main ( int argc, char *argv[] )
// flags to run immediately and exit // flags to run immediately and exit
char *sname = NULL; 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 ); int index = switcher_get ( sname );
if ( index >= 0 ) { if ( index >= 0 ) {
run_switcher ( FALSE, index ); run_switcher ( FALSE, index );
@ -2514,14 +2522,6 @@ int main ( int argc, char *argv[] )
fprintf ( stderr, "The ssh dialog has not been enabled\n" ); 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{ else{
// Daemon mode, Listen to key presses.. // Daemon mode, Listen to key presses..
if ( switcher_get ( "window" ) >= 0 ) { if ( switcher_get ( "window" ) >= 0 ) {