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 ) {
|
||||||
|
|
Loading…
Reference in New Issue