summaryrefslogtreecommitdiffstats
path: root/source
diff options
context:
space:
mode:
authorDave Davenport <qball@gmpclient.org>2015-12-10 20:57:43 +0100
committerDave Davenport <qball@gmpclient.org>2015-12-10 20:57:43 +0100
commitbae542791336929366d711fb3bea0fcc6f0e82f3 (patch)
treef3b982745f0fb016e4d343f853102d466aee7e01 /source
parent8ed31cab7e0bd4e68b504d202e0bed951ee5c182 (diff)
Add option to output to specific file.
Diffstat (limited to 'source')
-rw-r--r--source/rofi.c33
-rw-r--r--source/xrmoptions.c14
2 files changed, 27 insertions, 20 deletions
diff --git a/source/rofi.c b/source/rofi.c
index 50becc8b..12326e9a 100644
--- a/source/rofi.c
+++ b/source/rofi.c
@@ -585,21 +585,28 @@ static void menu_capture_screenshot ( void )
return;
}
// Get current time.
- GDateTime *now = g_date_time_new_now_local ();
+ GDateTime *now = g_date_time_new_now_local ();
// Format filename.
- char *timestmp = g_date_time_format ( now, "rofi-%Y-%m-%d-%H%M" );
- char *filename = g_strdup_printf ( "%s.png", timestmp );
+ char *timestmp = g_date_time_format ( now, "rofi-%Y-%m-%d-%H%M" );
+ char *filename = g_strdup_printf ( "%s.png", timestmp );
// Build full path
- char *fpath = g_build_filename ( xdg_pict_dir, filename, NULL );
- while ( g_file_test ( fpath, G_FILE_TEST_EXISTS ) && index < 99 ) {
- g_free ( fpath );
- g_free ( filename );
- // Try the next index.
- index++;
- // Format filename.
- filename = g_strdup_printf ( "%s-%d.png", timestmp, index );
- // Build full path
+ char *fpath = NULL;
+ const char *outp = g_getenv ( "ROFI_PNG_OUTPUT" );
+ if ( outp == NULL ) {
fpath = g_build_filename ( xdg_pict_dir, filename, NULL );
+ while ( g_file_test ( fpath, G_FILE_TEST_EXISTS ) && index < 99 ) {
+ g_free ( fpath );
+ g_free ( filename );
+ // Try the next index.
+ index++;
+ // Format filename.
+ filename = g_strdup_printf ( "%s-%d.png", timestmp, index );
+ // Build full path
+ fpath = g_build_filename ( xdg_pict_dir, filename, NULL );
+ }
+ }
+ else {
+ fpath = g_strdup ( outp );
}
fprintf ( stderr, color_green "Storing screenshot %s\n"color_reset, fpath );
cairo_status_t status = cairo_surface_write_to_png ( surface, fpath );
@@ -2444,7 +2451,7 @@ int main ( int argc, char *argv[] )
exit ( EXIT_SUCCESS );
}
if ( find_arg ( "-dump-xresources-theme" ) >= 0 ) {
- print_xresources_theme();
+ print_xresources_theme ();
exit ( EXIT_SUCCESS );
}
// Parse the keybindings.
diff --git a/source/xrmoptions.c b/source/xrmoptions.c
index 2d3b5dd2..5cb3f588 100644
--- a/source/xrmoptions.c
+++ b/source/xrmoptions.c
@@ -513,18 +513,18 @@ void print_help_msg ( const char *option, const char *type, const char*text, con
void print_xresources_theme ( void )
{
- if( config.color_enabled != TRUE ) {
- printf("! Dumping theme only works for the extended color scheme.\n");
+ if ( config.color_enabled != TRUE ) {
+ printf ( "! Dumping theme only works for the extended color scheme.\n" );
return;
}
- printf("! ------------------------------------------------------------------------------\n");
- printf("! ROFI Color theme\n");
- printf("! ------------------------------------------------------------------------------\n");
+ printf ( "! ------------------------------------------------------------------------------\n" );
+ printf ( "! ROFI Color theme\n" );
+ printf ( "! ------------------------------------------------------------------------------\n" );
const char * namePrefix = "rofi";
unsigned int entries = sizeof ( xrmOptions ) / sizeof ( *xrmOptions );
for ( unsigned int i = 0; i < entries; ++i ) {
- if ( strncmp(xrmOptions[i].name, "color-",6) == 0){
- xresource_dump_entry(namePrefix, &xrmOptions[i]);
+ if ( strncmp ( xrmOptions[i].name, "color-", 6 ) == 0 ) {
+ xresource_dump_entry ( namePrefix, &xrmOptions[i] );
}
}
}