diff --git a/include/rofi.h b/include/rofi.h index f6854636..356e0f00 100644 --- a/include/rofi.h +++ b/include/rofi.h @@ -52,7 +52,8 @@ typedef enum /** Custom (non-matched) input was entered. */ MENU_CUSTOM_INPUT = -3, /** User wanted to delete entry from history. */ - MENU_ENTRY_DELETE = -4 + MENU_ENTRY_DELETE = -4, + MENU_QUICK_SWITCH = -5, } MenuReturn; diff --git a/source/rofi.c b/source/rofi.c index b1b705d3..a4b94f27 100644 --- a/source/rofi.c +++ b/source/rofi.c @@ -1373,6 +1373,12 @@ MenuReturn menu ( char **lines, unsigned int num_lines, char **input, char *prom break; } } + else if ( ( ( ev.xkey.state & Mod1Mask ) == Mod1Mask ) && + key >= XK_1 && key <= XK_9 ) { + *selected_line = ( key - XK_1 ); + retv = MENU_QUICK_SWITCH; + break; + } int rc = textbox_keypress ( text, &ev ); @@ -1653,6 +1659,9 @@ SwitcherMode run_switcher_window ( char **input, void *data ) if ( mretv == MENU_NEXT ) { retv = NEXT_DIALOG; } + else if ( mretv == MENU_QUICK_SWITCH ) { + retv = selected_line; + } else if ( mretv == MENU_OK && list[selected_line] ) { #ifdef HAVE_I3_IPC_H @@ -1726,6 +1735,9 @@ static void run_switcher ( int do_fork, SwitcherMode mode ) else if ( retv == RELOAD_DIALOG ) { // do nothing. } + else if ( retv < DMENU_DIALOG ) { + mode = ( retv ) % num_switchers; + } else { mode = retv; } diff --git a/source/run-dialog.c b/source/run-dialog.c index 3237201b..8dc630fe 100644 --- a/source/run-dialog.c +++ b/source/run-dialog.c @@ -218,6 +218,9 @@ SwitcherMode run_switcher_dialog ( char **input, void *data ) if ( mretv == MENU_NEXT ) { retv = NEXT_DIALOG; } + else if ( mretv == MENU_QUICK_SWITCH ) { + retv = selected_line; + } else if ( mretv == MENU_OK && cmd_list[selected_line] != NULL ) { exec_cmd ( cmd_list[selected_line], shift ); } diff --git a/source/script-dialog.c b/source/script-dialog.c index 321b7534..b4c16e08 100644 --- a/source/script-dialog.c +++ b/source/script-dialog.c @@ -134,6 +134,9 @@ SwitcherMode script_switcher_dialog ( char **input, void *data ) if ( mretv == MENU_NEXT ) { retv = NEXT_DIALOG; } + else if ( mretv == MENU_QUICK_SWITCH ) { + retv = selected_line; + } else if ( mretv == MENU_OK && list[selected_line] != NULL ) { new_list = execute_executor ( options, list[selected_line], &new_length ); } diff --git a/source/ssh-dialog.c b/source/ssh-dialog.c index 954d871f..2ac30089 100644 --- a/source/ssh-dialog.c +++ b/source/ssh-dialog.c @@ -235,6 +235,9 @@ SwitcherMode ssh_switcher_dialog ( char **input, void *data ) if ( mretv == MENU_NEXT ) { retv = NEXT_DIALOG; } + else if ( mretv == MENU_QUICK_SWITCH ) { + retv = selected_line; + } else if ( mretv == MENU_OK && cmd_list[selected_line] != NULL ) { exec_ssh ( cmd_list[selected_line] ); }