mirror of https://github.com/davatorium/rofi.git
Add option to output to specific file.
This commit is contained in:
parent
8ed31cab7e
commit
bae5427913
|
@ -15,6 +15,9 @@ COLOR_BLUE="\e[0;34m"
|
||||||
XRDB_FILE=$1
|
XRDB_FILE=$1
|
||||||
shift
|
shift
|
||||||
|
|
||||||
|
OUTPUT_PNG=$1
|
||||||
|
shift
|
||||||
|
|
||||||
XVFB=$(which Xvfb 2> /dev/null)
|
XVFB=$(which Xvfb 2> /dev/null)
|
||||||
XDOTOOL=$(which xdotool 2> /dev/null)
|
XDOTOOL=$(which xdotool 2> /dev/null)
|
||||||
XRDB=$(which xrdb 2> /dev/null)
|
XRDB=$(which xrdb 2> /dev/null)
|
||||||
|
@ -79,6 +82,11 @@ ROFI_OPTIONS="-selected-row 6 -u 2,3 -a 4,5 -location 0 -width 100 -lines 7 -col
|
||||||
|
|
||||||
export DISPLAY=${VDISPLAY}
|
export DISPLAY=${VDISPLAY}
|
||||||
|
|
||||||
|
if [ -n "${OUTPUT_PNG}" ]
|
||||||
|
then
|
||||||
|
export ROFI_PNG_OUTPUT="${OUTPUT_PNG}"
|
||||||
|
fi
|
||||||
|
|
||||||
# Create fake X11
|
# Create fake X11
|
||||||
create_fake_x ${VDISPLAY}
|
create_fake_x ${VDISPLAY}
|
||||||
|
|
||||||
|
|
|
@ -590,7 +590,10 @@ static void menu_capture_screenshot ( void )
|
||||||
char *timestmp = g_date_time_format ( now, "rofi-%Y-%m-%d-%H%M" );
|
char *timestmp = g_date_time_format ( now, "rofi-%Y-%m-%d-%H%M" );
|
||||||
char *filename = g_strdup_printf ( "%s.png", timestmp );
|
char *filename = g_strdup_printf ( "%s.png", timestmp );
|
||||||
// Build full path
|
// Build full path
|
||||||
char *fpath = g_build_filename ( xdg_pict_dir, filename, NULL );
|
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 ) {
|
while ( g_file_test ( fpath, G_FILE_TEST_EXISTS ) && index < 99 ) {
|
||||||
g_free ( fpath );
|
g_free ( fpath );
|
||||||
g_free ( filename );
|
g_free ( filename );
|
||||||
|
@ -601,6 +604,10 @@ static void menu_capture_screenshot ( void )
|
||||||
// Build full path
|
// Build full path
|
||||||
fpath = g_build_filename ( xdg_pict_dir, filename, NULL );
|
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 );
|
fprintf ( stderr, color_green "Storing screenshot %s\n"color_reset, fpath );
|
||||||
cairo_status_t status = cairo_surface_write_to_png ( surface, fpath );
|
cairo_status_t status = cairo_surface_write_to_png ( surface, fpath );
|
||||||
if ( status != CAIRO_STATUS_SUCCESS ) {
|
if ( status != CAIRO_STATUS_SUCCESS ) {
|
||||||
|
@ -2444,7 +2451,7 @@ int main ( int argc, char *argv[] )
|
||||||
exit ( EXIT_SUCCESS );
|
exit ( EXIT_SUCCESS );
|
||||||
}
|
}
|
||||||
if ( find_arg ( "-dump-xresources-theme" ) >= 0 ) {
|
if ( find_arg ( "-dump-xresources-theme" ) >= 0 ) {
|
||||||
print_xresources_theme();
|
print_xresources_theme ();
|
||||||
exit ( EXIT_SUCCESS );
|
exit ( EXIT_SUCCESS );
|
||||||
}
|
}
|
||||||
// Parse the keybindings.
|
// Parse the keybindings.
|
||||||
|
|
|
@ -513,18 +513,18 @@ void print_help_msg ( const char *option, const char *type, const char*text, con
|
||||||
|
|
||||||
void print_xresources_theme ( void )
|
void print_xresources_theme ( void )
|
||||||
{
|
{
|
||||||
if( config.color_enabled != TRUE ) {
|
if ( config.color_enabled != TRUE ) {
|
||||||
printf("! Dumping theme only works for the extended color scheme.\n");
|
printf ( "! Dumping theme only works for the extended color scheme.\n" );
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
printf("! ------------------------------------------------------------------------------\n");
|
printf ( "! ------------------------------------------------------------------------------\n" );
|
||||||
printf("! ROFI Color theme\n");
|
printf ( "! ROFI Color theme\n" );
|
||||||
printf("! ------------------------------------------------------------------------------\n");
|
printf ( "! ------------------------------------------------------------------------------\n" );
|
||||||
const char * namePrefix = "rofi";
|
const char * namePrefix = "rofi";
|
||||||
unsigned int entries = sizeof ( xrmOptions ) / sizeof ( *xrmOptions );
|
unsigned int entries = sizeof ( xrmOptions ) / sizeof ( *xrmOptions );
|
||||||
for ( unsigned int i = 0; i < entries; ++i ) {
|
for ( unsigned int i = 0; i < entries; ++i ) {
|
||||||
if ( strncmp(xrmOptions[i].name, "color-",6) == 0){
|
if ( strncmp ( xrmOptions[i].name, "color-", 6 ) == 0 ) {
|
||||||
xresource_dump_entry(namePrefix, &xrmOptions[i]);
|
xresource_dump_entry ( namePrefix, &xrmOptions[i] );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue