mirror of
https://github.com/davatorium/rofi.git
synced 2024-11-25 13:55:34 -05:00
Fix #497: Create cache dir if not exists.
This commit is contained in:
parent
335a01689d
commit
27cef3c9ae
6 changed files with 17 additions and 12 deletions
|
@ -27,7 +27,7 @@ typedef enum
|
|||
/** INDICATOR */
|
||||
MENU_INDICATOR = 8,
|
||||
/** Show column */
|
||||
MENU_PROMPT_COLON = 16,
|
||||
MENU_PROMPT_COLON = 16,
|
||||
} MenuFlags;
|
||||
|
||||
/**
|
||||
|
|
|
@ -601,7 +601,7 @@ int dmenu_switcher_dialog ( void )
|
|||
// For now these only work in sync mode.
|
||||
if ( find_arg ( "-sync" ) >= 0 || find_arg ( "-dump" ) >= 0 || find_arg ( "-select" ) >= 0
|
||||
|| find_arg ( "-no-custom" ) >= 0 || find_arg ( "-only-match" ) >= 0 || config.auto_select ||
|
||||
find_arg ( "-selected-row") >= 0 ) {
|
||||
find_arg ( "-selected-row" ) >= 0 ) {
|
||||
async = FALSE;
|
||||
}
|
||||
if ( async ) {
|
||||
|
|
|
@ -600,7 +600,7 @@ static ModeMode window_mode_result ( Mode *sw, int mretv, G_GNUC_UNUSED char **i
|
|||
// Activate the window
|
||||
xcb_ewmh_request_change_active_window ( &xcb->ewmh, xcb->screen_nbr, rmpd->ids->array[selected_line],
|
||||
XCB_EWMH_CLIENT_SOURCE_TYPE_OTHER,
|
||||
XCB_CURRENT_TIME, rofi_view_get_window() );
|
||||
XCB_CURRENT_TIME, rofi_view_get_window () );
|
||||
xcb_flush ( xcb->connection );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -425,14 +425,14 @@ int create_pid_file ( const char *pidfile )
|
|||
|
||||
int fd = g_open ( pidfile, O_RDWR | O_CREAT, S_IRUSR | S_IWUSR );
|
||||
if ( fd < 0 ) {
|
||||
fprintf ( stderr, "Failed to create pid file." );
|
||||
fprintf ( stderr, "Failed to create pid file.\n" );
|
||||
return -1;
|
||||
}
|
||||
// Set it to close the File Descriptor on exit.
|
||||
int flags = fcntl ( fd, F_GETFD, NULL );
|
||||
flags = flags | FD_CLOEXEC;
|
||||
if ( fcntl ( fd, F_SETFD, flags, NULL ) < 0 ) {
|
||||
fprintf ( stderr, "Failed to set CLOEXEC on pidfile." );
|
||||
fprintf ( stderr, "Failed to set CLOEXEC on pidfile.\n" );
|
||||
remove_pid_file ( fd );
|
||||
return -1;
|
||||
}
|
||||
|
|
|
@ -668,6 +668,11 @@ int main ( int argc, char *argv[] )
|
|||
// Get the path to the cache dir.
|
||||
cache_dir = g_get_user_cache_dir ();
|
||||
|
||||
if ( g_mkdir_with_parents ( cache_dir, 0700 ) < 0 ) {
|
||||
fprintf ( stderr, "Failed to create cache directory: %s\n", strerror ( errno ) );
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
// Create pid file path.
|
||||
const char *path = g_get_user_runtime_dir ();
|
||||
if ( path ) {
|
||||
|
|
|
@ -476,7 +476,7 @@ static void rofi_view_setup_fake_transparency ( void )
|
|||
* Select Background to use for fake transparency.
|
||||
* Current options: 'screenshot','background'
|
||||
*/
|
||||
TICK_N("Fake start");
|
||||
TICK_N ( "Fake start" );
|
||||
if ( g_strcmp0 ( config.fake_background, "screenshot" ) == 0 ) {
|
||||
s = cairo_xcb_surface_create ( xcb->connection,
|
||||
xcb_stuff_get_root_window ( xcb ),
|
||||
|
@ -489,16 +489,16 @@ static void rofi_view_setup_fake_transparency ( void )
|
|||
}
|
||||
else {
|
||||
char *fpath = rofi_expand_path ( config.fake_background );
|
||||
g_log(LOG_DOMAIN, G_LOG_LEVEL_DEBUG, "Opening %s to use as background.", fpath);
|
||||
g_log ( LOG_DOMAIN, G_LOG_LEVEL_DEBUG, "Opening %s to use as background.", fpath );
|
||||
s = cairo_image_surface_create_from_png ( fpath );
|
||||
CacheState.fake_bgrel = TRUE;
|
||||
g_free ( fpath );
|
||||
}
|
||||
TICK_N("Get surface.");
|
||||
TICK_N ( "Get surface." );
|
||||
if ( s != NULL ) {
|
||||
if ( cairo_surface_status ( s ) != CAIRO_STATUS_SUCCESS ) {
|
||||
g_log( LOG_DOMAIN, G_LOG_LEVEL_DEBUG, "Failed to open surface fake background: %s",
|
||||
cairo_status_to_string ( cairo_surface_status ( s ) ));
|
||||
g_log ( LOG_DOMAIN, G_LOG_LEVEL_DEBUG, "Failed to open surface fake background: %s",
|
||||
cairo_status_to_string ( cairo_surface_status ( s ) ) );
|
||||
cairo_surface_destroy ( s );
|
||||
s = NULL;
|
||||
}
|
||||
|
@ -749,8 +749,8 @@ void rofi_view_update ( RofiViewState *state )
|
|||
}
|
||||
else {
|
||||
cairo_set_source_surface ( d, CacheState.fake_bg,
|
||||
-(double) ( state->x - CacheState.mon.x ),
|
||||
-(double) ( state->y - CacheState.mon.y ) );
|
||||
-(double) ( state->x - CacheState.mon.x ),
|
||||
-(double) ( state->y - CacheState.mon.y ) );
|
||||
}
|
||||
cairo_paint ( d );
|
||||
cairo_set_operator ( d, CAIRO_OPERATOR_OVER );
|
||||
|
|
Loading…
Reference in a new issue