mirror of
https://github.com/lbonn/rofi
synced 2025-02-17 05:18:31 +00: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
|
@ -601,7 +601,7 @@ int dmenu_switcher_dialog ( void )
|
||||||
// For now these only work in sync mode.
|
// For now these only work in sync mode.
|
||||||
if ( find_arg ( "-sync" ) >= 0 || find_arg ( "-dump" ) >= 0 || find_arg ( "-select" ) >= 0
|
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 ( "-no-custom" ) >= 0 || find_arg ( "-only-match" ) >= 0 || config.auto_select ||
|
||||||
find_arg ( "-selected-row") >= 0 ) {
|
find_arg ( "-selected-row" ) >= 0 ) {
|
||||||
async = FALSE;
|
async = FALSE;
|
||||||
}
|
}
|
||||||
if ( async ) {
|
if ( async ) {
|
||||||
|
|
|
@ -600,7 +600,7 @@ static ModeMode window_mode_result ( Mode *sw, int mretv, G_GNUC_UNUSED char **i
|
||||||
// Activate the window
|
// Activate the window
|
||||||
xcb_ewmh_request_change_active_window ( &xcb->ewmh, xcb->screen_nbr, rmpd->ids->array[selected_line],
|
xcb_ewmh_request_change_active_window ( &xcb->ewmh, xcb->screen_nbr, rmpd->ids->array[selected_line],
|
||||||
XCB_EWMH_CLIENT_SOURCE_TYPE_OTHER,
|
XCB_EWMH_CLIENT_SOURCE_TYPE_OTHER,
|
||||||
XCB_CURRENT_TIME, rofi_view_get_window() );
|
XCB_CURRENT_TIME, rofi_view_get_window () );
|
||||||
xcb_flush ( xcb->connection );
|
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 );
|
int fd = g_open ( pidfile, O_RDWR | O_CREAT, S_IRUSR | S_IWUSR );
|
||||||
if ( fd < 0 ) {
|
if ( fd < 0 ) {
|
||||||
fprintf ( stderr, "Failed to create pid file." );
|
fprintf ( stderr, "Failed to create pid file.\n" );
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
// Set it to close the File Descriptor on exit.
|
// Set it to close the File Descriptor on exit.
|
||||||
int flags = fcntl ( fd, F_GETFD, NULL );
|
int flags = fcntl ( fd, F_GETFD, NULL );
|
||||||
flags = flags | FD_CLOEXEC;
|
flags = flags | FD_CLOEXEC;
|
||||||
if ( fcntl ( fd, F_SETFD, flags, NULL ) < 0 ) {
|
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 );
|
remove_pid_file ( fd );
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
|
@ -668,6 +668,11 @@ int main ( int argc, char *argv[] )
|
||||||
// Get the path to the cache dir.
|
// Get the path to the cache dir.
|
||||||
cache_dir = g_get_user_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.
|
// Create pid file path.
|
||||||
const char *path = g_get_user_runtime_dir ();
|
const char *path = g_get_user_runtime_dir ();
|
||||||
if ( path ) {
|
if ( path ) {
|
||||||
|
|
|
@ -476,7 +476,7 @@ static void rofi_view_setup_fake_transparency ( void )
|
||||||
* Select Background to use for fake transparency.
|
* Select Background to use for fake transparency.
|
||||||
* Current options: 'screenshot','background'
|
* Current options: 'screenshot','background'
|
||||||
*/
|
*/
|
||||||
TICK_N("Fake start");
|
TICK_N ( "Fake start" );
|
||||||
if ( g_strcmp0 ( config.fake_background, "screenshot" ) == 0 ) {
|
if ( g_strcmp0 ( config.fake_background, "screenshot" ) == 0 ) {
|
||||||
s = cairo_xcb_surface_create ( xcb->connection,
|
s = cairo_xcb_surface_create ( xcb->connection,
|
||||||
xcb_stuff_get_root_window ( xcb ),
|
xcb_stuff_get_root_window ( xcb ),
|
||||||
|
@ -489,16 +489,16 @@ static void rofi_view_setup_fake_transparency ( void )
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
char *fpath = rofi_expand_path ( config.fake_background );
|
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 );
|
s = cairo_image_surface_create_from_png ( fpath );
|
||||||
CacheState.fake_bgrel = TRUE;
|
CacheState.fake_bgrel = TRUE;
|
||||||
g_free ( fpath );
|
g_free ( fpath );
|
||||||
}
|
}
|
||||||
TICK_N("Get surface.");
|
TICK_N ( "Get surface." );
|
||||||
if ( s != NULL ) {
|
if ( s != NULL ) {
|
||||||
if ( cairo_surface_status ( s ) != CAIRO_STATUS_SUCCESS ) {
|
if ( cairo_surface_status ( s ) != CAIRO_STATUS_SUCCESS ) {
|
||||||
g_log( LOG_DOMAIN, G_LOG_LEVEL_DEBUG, "Failed to open surface fake background: %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_status_to_string ( cairo_surface_status ( s ) ) );
|
||||||
cairo_surface_destroy ( s );
|
cairo_surface_destroy ( s );
|
||||||
s = NULL;
|
s = NULL;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue