Skip to content

Commit

Permalink
When modi is not enabled, only print warning when started from console
Browse files Browse the repository at this point in the history
  • Loading branch information
DaveDavenport committed Mar 31, 2017
1 parent 9ae1344 commit 18618dd
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions source/rofi.c
Original file line number Diff line number Diff line change
Expand Up @@ -339,6 +339,18 @@ static void help ( G_GNUC_UNUSED int argc, char **argv )
}
}

static void help_print_disabled_mode ( const char *mode )
{
int is_term = isatty ( fileno ( stdout ) );
// Only output to terminal
if ( is_term ) {
fprintf ( stderr, "Mode %s%s%s is not enabled. I have enabled it for now.\n",
color_red, mode, color_reset);
fprintf ( stderr, "Please consider adding %s%s%s to the %smodi%s option.\n",
color_red, mode, color_reset,
color_green, color_reset);
}
}
static void help_print_no_arguments ( void )
{
int is_term = isatty ( fileno ( stdout ) );
Expand Down Expand Up @@ -371,7 +383,8 @@ static void help_print_no_arguments ( void )
is_term ? color_reset : "" );
}
}
fprintf ( stderr, "\nTo activate a mode, add it to the list of modi in the 'modi' setting." );
fprintf ( stderr, "\nTo activate a mode, add it to the list of modi in the %smodi%s setting.",
is_term?color_green:"",is_term?color_reset:"" );
}

/**
Expand Down Expand Up @@ -823,9 +836,7 @@ static gboolean startup ( G_GNUC_UNUSED gpointer data )
index = add_mode ( sname );
// Complain
if ( index >= 0 ) {
fprintf ( stdout, "Mode %s not enabled. Please add it to the list of enabled modi: %s\n",
sname, config.modi );
fprintf ( stdout, "Adding mode: %s\n", sname );
help_print_disabled_mode ( sname );
}
// Run it anyway if found.
}
Expand Down

0 comments on commit 18618dd

Please sign in to comment.