From 27cef3c9ae83a488c70c8483ee6bef5e104a3a16 Mon Sep 17 00:00:00 2001 From: Dave Davenport Date: Sat, 12 Nov 2016 11:28:40 +0100 Subject: [PATCH] Fix #497: Create cache dir if not exists. --- include/view.h | 2 +- source/dialogs/dmenu.c | 2 +- source/dialogs/window.c | 2 +- source/helper.c | 4 ++-- source/rofi.c | 5 +++++ source/view.c | 14 +++++++------- 6 files changed, 17 insertions(+), 12 deletions(-) diff --git a/include/view.h b/include/view.h index 8c9c7dfc..09945ada 100644 --- a/include/view.h +++ b/include/view.h @@ -27,7 +27,7 @@ typedef enum /** INDICATOR */ MENU_INDICATOR = 8, /** Show column */ - MENU_PROMPT_COLON = 16, + MENU_PROMPT_COLON = 16, } MenuFlags; /** diff --git a/source/dialogs/dmenu.c b/source/dialogs/dmenu.c index 06628fc5..a308dca1 100644 --- a/source/dialogs/dmenu.c +++ b/source/dialogs/dmenu.c @@ -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 ) { diff --git a/source/dialogs/window.c b/source/dialogs/window.c index 12de5ced..1b353f4f 100644 --- a/source/dialogs/window.c +++ b/source/dialogs/window.c @@ -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 ); } } diff --git a/source/helper.c b/source/helper.c index bf21e0a6..e099457d 100644 --- a/source/helper.c +++ b/source/helper.c @@ -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; } diff --git a/source/rofi.c b/source/rofi.c index a4eafc20..b5d89615 100644 --- a/source/rofi.c +++ b/source/rofi.c @@ -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 ) { diff --git a/source/view.c b/source/view.c index 938c4941..6ddbe099 100644 --- a/source/view.c +++ b/source/view.c @@ -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 );