mirror of
https://github.com/davatorium/rofi.git
synced 2025-02-03 15:34:54 -05:00
Add keybinding.
This commit is contained in:
parent
a749aa35e9
commit
ef8d444dd2
5 changed files with 76 additions and 33 deletions
|
@ -23,6 +23,7 @@ simpleswitcher \- a simple EWMH window switcher
|
||||||
.IR comdo ]
|
.IR comdo ]
|
||||||
.RB [ \-now ]
|
.RB [ \-now ]
|
||||||
.RB [ \-rnow ]
|
.RB [ \-rnow ]
|
||||||
|
.RB [ \-snow ]
|
||||||
.RB [ \-term
|
.RB [ \-term
|
||||||
.IR terminal ]
|
.IR terminal ]
|
||||||
|
|
||||||
|
@ -63,12 +64,26 @@ simpleswitcher -rkey control+shift+d
|
||||||
simpleswitcher -rkey mod1+grave (grave=backtick)
|
simpleswitcher -rkey mod1+grave (grave=backtick)
|
||||||
.RE
|
.RE
|
||||||
.TP
|
.TP
|
||||||
|
.B -skey
|
||||||
|
Change the key combination to display the ssh dialog (default: mod1-F3).
|
||||||
|
.P
|
||||||
|
.RS
|
||||||
|
simpleswitcher -skey F10
|
||||||
|
.br
|
||||||
|
simpleswitcher -skey control+shift+s
|
||||||
|
.br
|
||||||
|
simpleswitcher -skey mod1+grave (grave=backtick)
|
||||||
|
.RE
|
||||||
|
.TP
|
||||||
.B -now
|
.B -now
|
||||||
Run simpleswitcher in all-windows mode once then exit. Does not bind any keys.
|
Run simpleswitcher in all-windows mode once then exit. Does not bind any keys.
|
||||||
.TP
|
.TP
|
||||||
.B -rnow
|
.B -rnow
|
||||||
Run simpleswitcher in run-dialog mode once then exit. Does not bind any keys.
|
Run simpleswitcher in run-dialog mode once then exit. Does not bind any keys.
|
||||||
.TP
|
.TP
|
||||||
|
.B -snow
|
||||||
|
Run simpleswitcher in ssh mode once then exit. Does not bind any keys.
|
||||||
|
.TP
|
||||||
.B -bg
|
.B -bg
|
||||||
Set the background text color (X11 named color or hex #rrggbb) for the menu (default: #222222).
|
Set the background text color (X11 named color or hex #rrggbb) for the menu (default: #222222).
|
||||||
.P
|
.P
|
||||||
|
|
|
@ -230,10 +230,12 @@ static int token_match ( char **tokens, const char *input,
|
||||||
__attribute__( ( unused ) )void *data )
|
__attribute__( ( unused ) )void *data )
|
||||||
{
|
{
|
||||||
int match = 1;
|
int match = 1;
|
||||||
|
|
||||||
// Do a tokenized match.
|
// Do a tokenized match.
|
||||||
if ( tokens ) for ( int j = 1; match && tokens[j]; j++ ) {
|
if ( tokens ) for ( int j = 1; match && tokens[j]; j++ ) {
|
||||||
match = ( strcasestr( input, tokens[j] ) != NULL );
|
match = ( strcasestr( input, tokens[j] ) != NULL );
|
||||||
}
|
}
|
||||||
|
|
||||||
return match;
|
return match;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -718,6 +718,8 @@ unsigned int windows_modmask;
|
||||||
KeySym windows_keysym;
|
KeySym windows_keysym;
|
||||||
unsigned int rundialog_modmask;
|
unsigned int rundialog_modmask;
|
||||||
KeySym rundialog_keysym;
|
KeySym rundialog_keysym;
|
||||||
|
unsigned int sshdialog_modmask;
|
||||||
|
KeySym sshdialog_keysym;
|
||||||
// flags to set if we switch modes on the fly
|
// flags to set if we switch modes on the fly
|
||||||
Window main_window = None;
|
Window main_window = None;
|
||||||
|
|
||||||
|
@ -784,6 +786,7 @@ int window_match ( char **tokens, __attribute__((unused))const char *input, int
|
||||||
int match =1;
|
int match =1;
|
||||||
winlist *ids = ( winlist * )data;
|
winlist *ids = ( winlist * )data;
|
||||||
client *c = window_client( ids->array[index] );
|
client *c = window_client( ids->array[index] );
|
||||||
|
|
||||||
if ( tokens ) for ( int j = 1; match && tokens[j]; j++ ) {
|
if ( tokens ) for ( int j = 1; match && tokens[j]; j++ ) {
|
||||||
int test = 0;
|
int test = 0;
|
||||||
|
|
||||||
|
@ -977,6 +980,7 @@ int menu( char **lines, char **input, char *prompt, int selected, Time *time, in
|
||||||
// pressing one of the global key bindings closes the switcher. this allows fast closing of the menu if an item is not selected
|
// pressing one of the global key bindings closes the switcher. this allows fast closing of the menu if an item is not selected
|
||||||
|| ( ( windows_modmask == AnyModifier || ev.xkey.state & windows_modmask ) && key == windows_keysym )
|
|| ( ( windows_modmask == AnyModifier || ev.xkey.state & windows_modmask ) && key == windows_keysym )
|
||||||
|| ( ( rundialog_modmask == AnyModifier || ev.xkey.state & rundialog_modmask ) && key == rundialog_keysym )
|
|| ( ( rundialog_modmask == AnyModifier || ev.xkey.state & rundialog_modmask ) && key == rundialog_keysym )
|
||||||
|
|| ( ( sshdialog_modmask == AnyModifier || ev.xkey.state & sshdialog_modmask ) && key == sshdialog_keysym )
|
||||||
) {
|
) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -1190,6 +1194,11 @@ void handle_keypress( XEvent *ev )
|
||||||
key == rundialog_keysym ) {
|
key == rundialog_keysym ) {
|
||||||
run_switcher( FORK , RUN_DIALOG );
|
run_switcher( FORK , RUN_DIALOG );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ( ( sshdialog_modmask == AnyModifier || ev->xkey.state & sshdialog_modmask ) &&
|
||||||
|
key == sshdialog_keysym ) {
|
||||||
|
run_switcher( FORK , SSH_DIALOG );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// convert a Mod+key arg to mod mask and keysym
|
// convert a Mod+key arg to mod mask and keysym
|
||||||
|
@ -1362,6 +1371,16 @@ int main( int argc, char *argv[] )
|
||||||
|
|
||||||
if ( i3_socket_path != NULL ) free( i3_socket_path );
|
if ( i3_socket_path != NULL ) free( i3_socket_path );
|
||||||
|
|
||||||
|
#endif
|
||||||
|
exit( EXIT_SUCCESS );
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( find_arg( ac, av, "-snow" ) >= 0 ) {
|
||||||
|
run_switcher( NOFORK, SSH_DIALOG );
|
||||||
|
#ifdef I3
|
||||||
|
|
||||||
|
if ( i3_socket_path != NULL ) free( i3_socket_path );
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
exit( EXIT_SUCCESS );
|
exit( EXIT_SUCCESS );
|
||||||
}
|
}
|
||||||
|
@ -1371,11 +1390,13 @@ int main( int argc, char *argv[] )
|
||||||
// key combination to display all windows from all desktops
|
// key combination to display all windows from all desktops
|
||||||
parse_key( find_arg_str( ac, av, "-key", "F12" ), &windows_modmask, &windows_keysym );
|
parse_key( find_arg_str( ac, av, "-key", "F12" ), &windows_modmask, &windows_keysym );
|
||||||
parse_key( find_arg_str( ac, av, "-rkey", "mod1+F2" ), &rundialog_modmask, &rundialog_keysym );
|
parse_key( find_arg_str( ac, av, "-rkey", "mod1+F2" ), &rundialog_modmask, &rundialog_keysym );
|
||||||
|
parse_key( find_arg_str( ac, av, "-skey", "mod1+F3" ), &sshdialog_modmask, &sshdialog_keysym );
|
||||||
|
|
||||||
|
|
||||||
// bind key combos
|
// bind key combos
|
||||||
grab_key( windows_modmask, windows_keysym );
|
grab_key( windows_modmask, windows_keysym );
|
||||||
grab_key( rundialog_modmask, rundialog_keysym );
|
grab_key( rundialog_modmask, rundialog_keysym );
|
||||||
|
grab_key( sshdialog_modmask, sshdialog_keysym );
|
||||||
|
|
||||||
XEvent ev;
|
XEvent ev;
|
||||||
|
|
||||||
|
|
|
@ -179,8 +179,11 @@ static char ** get_ssh ( )
|
||||||
if ( strncasecmp( buffer, "Host", 4 ) == 0 ) {
|
if ( strncasecmp( buffer, "Host", 4 ) == 0 ) {
|
||||||
int start = 0, stop=0;
|
int start = 0, stop=0;
|
||||||
buffer[strlen( buffer )-1] = '\0';
|
buffer[strlen( buffer )-1] = '\0';
|
||||||
|
|
||||||
for ( start=4; isspace( buffer[start] ); start++ );
|
for ( start=4; isspace( buffer[start] ); start++ );
|
||||||
|
|
||||||
for ( stop=start; isalnum( buffer[stop] ); stop++ );
|
for ( stop=start; isalnum( buffer[stop] ); stop++ );
|
||||||
|
|
||||||
retv = realloc( retv, ( index+2 )*sizeof( char* ) );
|
retv = realloc( retv, ( index+2 )*sizeof( char* ) );
|
||||||
retv[index] = strndup( &buffer[start], stop-start );
|
retv[index] = strndup( &buffer[start], stop-start );
|
||||||
retv[index+1] = NULL;
|
retv[index+1] = NULL;
|
||||||
|
@ -213,10 +216,12 @@ static int token_match ( char **tokens, const char *input,
|
||||||
__attribute__( ( unused ) )void *data )
|
__attribute__( ( unused ) )void *data )
|
||||||
{
|
{
|
||||||
int match = 1;
|
int match = 1;
|
||||||
|
|
||||||
// Do a tokenized match.
|
// Do a tokenized match.
|
||||||
if ( tokens ) for ( int j = 1; match && tokens[j]; j++ ) {
|
if ( tokens ) for ( int j = 1; match && tokens[j]; j++ ) {
|
||||||
match = ( strcasestr( input, tokens[j] ) != NULL );
|
match = ( strcasestr( input, tokens[j] ) != NULL );
|
||||||
}
|
}
|
||||||
|
|
||||||
return match;
|
return match;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue