mirror of
https://github.com/lbonn/rofi
synced 2024-11-15 08:37:17 +00:00
Improve error message when called with -show
This commit is contained in:
parent
d31fc5c8bc
commit
9ae1344d56
10 changed files with 223 additions and 209 deletions
|
@ -2,86 +2,86 @@
|
|||
#define ROFI_DEFAULT_THEME
|
||||
|
||||
const char *default_theme =
|
||||
"* {"
|
||||
" spacing: 2;"
|
||||
" background: #FFFDF6E3;"
|
||||
"}"
|
||||
"#window {"
|
||||
" border: 1;"
|
||||
" foreground: #FF002B36;"
|
||||
" padding: 5;"
|
||||
" background: @background;"
|
||||
"}"
|
||||
"#window.mainbox {"
|
||||
" border: 0;"
|
||||
" padding: 0;"
|
||||
"}"
|
||||
"#window.mainbox.message.box {"
|
||||
" border: 1px dash 0px 0px ;"
|
||||
" padding: 2px 0px 0px ;"
|
||||
"}"
|
||||
"#window.mainbox.message.normal {"
|
||||
" foreground: #FF002B36;"
|
||||
"}"
|
||||
"#window.mainbox.listview {"
|
||||
" fixed-height: 0;"
|
||||
" border: 1px dash 0px 0px ;"
|
||||
" columns: 1;"
|
||||
" padding: 2px 0px 0px ;"
|
||||
"}"
|
||||
"#window.mainbox.listview.element {"
|
||||
" border: 0;"
|
||||
"}"
|
||||
"#window.mainbox.listview.element.normal.normal {"
|
||||
" foreground: #FF002B36;"
|
||||
" background: #FFFDF6E3;"
|
||||
"}"
|
||||
"#window.mainbox.listview.element.normal.urgent {"
|
||||
" foreground: #FFDC322F;"
|
||||
" background: #FFFDF6E3;"
|
||||
"}"
|
||||
"#window.mainbox.listview.element.normal.active {"
|
||||
" foreground: #FF268BD2;"
|
||||
" background: #FFFDF6E3;"
|
||||
"}"
|
||||
"#window.mainbox.listview.element.selected.normal {"
|
||||
" foreground: #FFEEE8D5;"
|
||||
" background: #FF586E75;"
|
||||
"}"
|
||||
"#window.mainbox.listview.element.selected.urgent {"
|
||||
" foreground: #FFFDF6E3;"
|
||||
" background: #FFDC322F;"
|
||||
"}"
|
||||
"#window.mainbox.listview.element.selected.active {"
|
||||
" foreground: #FFFDF6E3;"
|
||||
" background: #FF268BD2;"
|
||||
"}"
|
||||
"#window.mainbox.listview.element.alternate.normal {"
|
||||
" foreground: #FF002B36;"
|
||||
" background: #FFEEE8D5;"
|
||||
"}"
|
||||
"#window.mainbox.listview.element.alternate.urgent {"
|
||||
" foreground: #FFDC322F;"
|
||||
" background: #FFEEE8D5;"
|
||||
"}"
|
||||
"#window.mainbox.listview.element.alternate.active {"
|
||||
" foreground: #FF268BD2;"
|
||||
" background: #FFEEE8D5;"
|
||||
"}"
|
||||
"#window.mainbox.listview.scrollbar {"
|
||||
" border: 0;"
|
||||
" padding: 0;"
|
||||
"}"
|
||||
"#window.mainbox.sidebar.box {"
|
||||
" border: 1px dash 0px 0px ;"
|
||||
"}"
|
||||
"#window.mainbox.inputbar {"
|
||||
" spacing: 0;"
|
||||
"}"
|
||||
"#window.mainbox.inputbar.box {"
|
||||
"}"
|
||||
"#window.mainbox.inputbar.normal {"
|
||||
" foreground: #FF002B36;"
|
||||
" background: @background;"
|
||||
"}";
|
||||
"* {"
|
||||
" spacing: 2;"
|
||||
" background: #FFFDF6E3;"
|
||||
"}"
|
||||
"#window {"
|
||||
" border: 1;"
|
||||
" foreground: #FF002B36;"
|
||||
" padding: 5;"
|
||||
" background: @background;"
|
||||
"}"
|
||||
"#window.mainbox {"
|
||||
" border: 0;"
|
||||
" padding: 0;"
|
||||
"}"
|
||||
"#window.mainbox.message.box {"
|
||||
" border: 1px dash 0px 0px ;"
|
||||
" padding: 2px 0px 0px ;"
|
||||
"}"
|
||||
"#window.mainbox.message.normal {"
|
||||
" foreground: #FF002B36;"
|
||||
"}"
|
||||
"#window.mainbox.listview {"
|
||||
" fixed-height: 0;"
|
||||
" border: 1px dash 0px 0px ;"
|
||||
" columns: 1;"
|
||||
" padding: 2px 0px 0px ;"
|
||||
"}"
|
||||
"#window.mainbox.listview.element {"
|
||||
" border: 0;"
|
||||
"}"
|
||||
"#window.mainbox.listview.element.normal.normal {"
|
||||
" foreground: #FF002B36;"
|
||||
" background: #FFFDF6E3;"
|
||||
"}"
|
||||
"#window.mainbox.listview.element.normal.urgent {"
|
||||
" foreground: #FFDC322F;"
|
||||
" background: #FFFDF6E3;"
|
||||
"}"
|
||||
"#window.mainbox.listview.element.normal.active {"
|
||||
" foreground: #FF268BD2;"
|
||||
" background: #FFFDF6E3;"
|
||||
"}"
|
||||
"#window.mainbox.listview.element.selected.normal {"
|
||||
" foreground: #FFEEE8D5;"
|
||||
" background: #FF586E75;"
|
||||
"}"
|
||||
"#window.mainbox.listview.element.selected.urgent {"
|
||||
" foreground: #FFFDF6E3;"
|
||||
" background: #FFDC322F;"
|
||||
"}"
|
||||
"#window.mainbox.listview.element.selected.active {"
|
||||
" foreground: #FFFDF6E3;"
|
||||
" background: #FF268BD2;"
|
||||
"}"
|
||||
"#window.mainbox.listview.element.alternate.normal {"
|
||||
" foreground: #FF002B36;"
|
||||
" background: #FFEEE8D5;"
|
||||
"}"
|
||||
"#window.mainbox.listview.element.alternate.urgent {"
|
||||
" foreground: #FFDC322F;"
|
||||
" background: #FFEEE8D5;"
|
||||
"}"
|
||||
"#window.mainbox.listview.element.alternate.active {"
|
||||
" foreground: #FF268BD2;"
|
||||
" background: #FFEEE8D5;"
|
||||
"}"
|
||||
"#window.mainbox.listview.scrollbar {"
|
||||
" border: 0;"
|
||||
" padding: 0;"
|
||||
"}"
|
||||
"#window.mainbox.sidebar.box {"
|
||||
" border: 1px dash 0px 0px ;"
|
||||
"}"
|
||||
"#window.mainbox.inputbar {"
|
||||
" spacing: 0;"
|
||||
"}"
|
||||
"#window.mainbox.inputbar.box {"
|
||||
"}"
|
||||
"#window.mainbox.inputbar.normal {"
|
||||
" foreground: #FF002B36;"
|
||||
" background: @background;"
|
||||
"}";
|
||||
#endif
|
||||
|
|
|
@ -104,7 +104,7 @@ typedef char* ( *_mode_preprocess_input )( Mode *sw, const char *input );
|
|||
*
|
||||
* @returns the (valid pango markup) message to display.
|
||||
*/
|
||||
typedef char * (*_mode_get_message )( const Mode *sw );
|
||||
typedef char * ( *_mode_get_message )( const Mode *sw );
|
||||
|
||||
/**
|
||||
* Structure defining a switcher.
|
||||
|
|
|
@ -196,7 +196,6 @@ extern xcb_colormap_t map;
|
|||
*/
|
||||
void x11_create_visual_and_colormap ( void );
|
||||
|
||||
|
||||
/**
|
||||
* Gets a surface containing the background image of the desktop.
|
||||
*
|
||||
|
|
|
@ -105,6 +105,11 @@ struct xkb_stuff xkb = {
|
|||
char *config_path = NULL;
|
||||
/** Array holding all activated modi. */
|
||||
Mode **modi = NULL;
|
||||
|
||||
/** List of (possibly uninitialized) modi's */
|
||||
Mode ** available_modi = NULL;
|
||||
/** Length of #num_available_modi */
|
||||
unsigned int num_available_modi = 0;
|
||||
/** Number of activated modi in #modi array */
|
||||
unsigned int num_modi = 0;
|
||||
/** Current selected mode */
|
||||
|
@ -334,6 +339,41 @@ static void help ( G_GNUC_UNUSED int argc, char **argv )
|
|||
}
|
||||
}
|
||||
|
||||
static void help_print_no_arguments ( void )
|
||||
{
|
||||
int is_term = isatty ( fileno ( stdout ) );
|
||||
// Daemon mode
|
||||
fprintf ( stderr, "Rofi is unsure what to show.\n" );
|
||||
fprintf ( stderr, "Please specify the mode you want to show.\n\n" );
|
||||
fprintf ( stderr, " %srofi%s -show %s{mode}%s\n\n",
|
||||
is_term ? color_bold : "", is_term ? color_reset : "",
|
||||
is_term ? color_green : "", is_term ? color_reset : "" );
|
||||
fprintf ( stderr, "The following modi are enabled:\n" );
|
||||
for ( unsigned int j = 0; j < num_modi; j++ ) {
|
||||
fprintf ( stderr, " * %s%s%s\n",
|
||||
is_term ? color_green : "",
|
||||
modi[j]->name,
|
||||
is_term ? color_reset : "" );
|
||||
}
|
||||
fprintf ( stderr, "\nThe following can be enabled:\n" );
|
||||
for ( unsigned int i = 0; i < num_available_modi; i++ ) {
|
||||
gboolean active = FALSE;
|
||||
for ( unsigned int j = 0; j < num_modi; j++ ) {
|
||||
if ( modi[j] == available_modi[i] ) {
|
||||
active = TRUE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if ( !active ) {
|
||||
fprintf ( stderr, " * %s%s%s\n",
|
||||
is_term ? color_red : "",
|
||||
available_modi[i]->name,
|
||||
is_term ? color_reset : "" );
|
||||
}
|
||||
}
|
||||
fprintf ( stderr, "\nTo activate a mode, add it to the list of modi in the 'modi' setting." );
|
||||
}
|
||||
|
||||
/**
|
||||
* Cleanup globally allocated memory.
|
||||
*/
|
||||
|
@ -407,10 +447,6 @@ static void cleanup ()
|
|||
/**
|
||||
* Collected modi
|
||||
*/
|
||||
/** List of (possibly uninitialized) modi's */
|
||||
Mode ** available_modi = NULL;
|
||||
/** Length of #num_available_modi */
|
||||
unsigned int num_available_modi = 0;
|
||||
|
||||
/**
|
||||
* @param name Search for mode with this name.
|
||||
|
@ -548,7 +584,7 @@ static int add_mode ( const char * token )
|
|||
}
|
||||
else {
|
||||
// Report error, don't continue.
|
||||
fprintf ( stderr, "Invalid script switcher: %s\n", token );
|
||||
fprintf ( stderr, "Invalid script mode: %s\n", token );
|
||||
}
|
||||
}
|
||||
return ( index == num_modi ) ? -1 : (int) index;
|
||||
|
@ -806,27 +842,7 @@ static gboolean startup ( G_GNUC_UNUSED gpointer data )
|
|||
run_switcher ( 0 );
|
||||
}
|
||||
else{
|
||||
// Daemon mode
|
||||
fprintf ( stderr, "Please specify the mode you want to show.\n\n" );
|
||||
fprintf ( stderr, " rofi -show {mode}\n\n");
|
||||
fprintf ( stderr, "The following modi are available:\n" );
|
||||
for ( unsigned int j = 0; j < num_modi; j++ ) {
|
||||
fprintf ( stderr, " * %s\n", modi[j]->name);
|
||||
}
|
||||
fprintf ( stderr, "\nThe following can be enabled:\n" );
|
||||
for ( unsigned int i = 0; i < num_available_modi; i++ ) {
|
||||
gboolean active = FALSE;
|
||||
for ( unsigned int j = 0; j < num_modi; j++ ) {
|
||||
if ( modi[j] == available_modi[i] ){
|
||||
active = TRUE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if ( ! active ) {
|
||||
fprintf ( stderr, " * %s\n", available_modi[i]->name);
|
||||
}
|
||||
}
|
||||
fprintf ( stderr, "\nTo activate a mode, add it to the list of modi in the 'modi' setting.");
|
||||
help_print_no_arguments ( );
|
||||
|
||||
g_main_loop_quit ( main_loop );
|
||||
}
|
||||
|
@ -1104,8 +1120,8 @@ int main ( int argc, char *argv[] )
|
|||
g_free ( theme_str );
|
||||
}
|
||||
if ( rofi_theme_is_empty ( ) ) {
|
||||
if ( rofi_theme_parse_string ( default_theme ) ){
|
||||
fprintf(stderr, "Failed to parse default theme. Giving up..\n");
|
||||
if ( rofi_theme_parse_string ( default_theme ) ) {
|
||||
fprintf ( stderr, "Failed to parse default theme. Giving up..\n" );
|
||||
rofi_theme = NULL;
|
||||
cleanup ();
|
||||
return EXIT_FAILURE;
|
||||
|
|
|
@ -807,7 +807,6 @@ void x11_create_visual_and_colormap ( void )
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
xcb_window_t xcb_stuff_get_root_window ( xcb_stuff *xcb )
|
||||
{
|
||||
return xcb->screen->root;
|
||||
|
|
Loading…
Reference in a new issue