From 4d03acc454a34df4e67905ca7b6855eb16c1bfee Mon Sep 17 00:00:00 2001 From: George Angelopoulos Date: Sat, 29 Jul 2017 15:16:08 +0200 Subject: [PATCH 1/2] replace 'folder' with 'path' in icon functionality "folder" is more of a windows term. In unix we have paths and directories. --- config.def.h | 2 +- docs/dunst.pod | 2 +- dunstrc | 2 +- src/settings.c | 4 ++-- src/settings.h | 2 +- src/x11/x.c | 6 +++--- 6 files changed, 9 insertions(+), 9 deletions(-) diff --git a/config.def.h b/config.def.h index 0783430..9e868e5 100644 --- a/config.def.h +++ b/config.def.h @@ -56,7 +56,7 @@ char *browser = "/usr/bin/firefox"; int max_icon_size = 0; /* paths to default icons */ -char *icon_folders = "/usr/share/icons/gnome/16x16/status/:/usr/share/icons/gnome/16x16/devices/"; +char *icon_path = "/usr/share/icons/gnome/16x16/status/:/usr/share/icons/gnome/16x16/devices/"; /* follow focus to different monitor and display notifications there? * possible values: diff --git a/docs/dunst.pod b/docs/dunst.pod index 7a99ea0..122a600 100644 --- a/docs/dunst.pod +++ b/docs/dunst.pod @@ -383,7 +383,7 @@ Set to 0 to disable icon scaling. (default) If B is set to off, this setting is ignored. -=item B (default: "/usr/share/icons/gnome/16x16/status/:/usr/share/icons/gnome/16x16/devices/") +=item B (default: "/usr/share/icons/gnome/16x16/status/:/usr/share/icons/gnome/16x16/devices/") Can be set to a colon-separated list of paths to search for icons to use with notifications. diff --git a/dunstrc b/dunstrc index f38d4ed..6faedc4 100644 --- a/dunstrc +++ b/dunstrc @@ -159,7 +159,7 @@ max_icon_size = 32 # Paths to default icons. - icon_folders = /usr/share/icons/gnome/16x16/status/:/usr/share/icons/gnome/16x16/devices/ + icon_path = /usr/share/icons/gnome/16x16/status/:/usr/share/icons/gnome/16x16/devices/ ### History ### diff --git a/src/settings.c b/src/settings.c index 5aefd2c..8dee163 100644 --- a/src/settings.c +++ b/src/settings.c @@ -390,9 +390,9 @@ void load_settings(char *cmdline_config_path) "Scale larger icons down to this size, set to 0 to disable" ); - settings.icon_folders = option_get_string( + settings.icon_path = option_get_string( "global", - "icon_folders", "-icon_folders", icon_folders, + "icon_path", "-icon_path", icon_path, "paths to default icons" ); diff --git a/src/settings.h b/src/settings.h index cd44fdc..c121af3 100644 --- a/src/settings.h +++ b/src/settings.h @@ -63,7 +63,7 @@ typedef struct _settings { char *browser; enum icon_position_t icon_position; int max_icon_size; - char *icon_folders; + char *icon_path; enum follow_mode f_mode; bool always_run_script; keyboard_shortcut close_ks; diff --git a/src/x11/x.c b/src/x11/x.c index 57ca7b3..7b14c1c 100644 --- a/src/x11/x.c +++ b/src/x11/x.c @@ -329,13 +329,13 @@ static GdkPixbuf *get_pixbuf_from_path(char *icon_path) if (icon_path[0] == '/' || icon_path[0] == '~') { pixbuf = get_pixbuf_from_file(icon_path); } - /* search in icon_folders */ + /* search in icon_path */ if (pixbuf == NULL) { - char *start = settings.icon_folders, + char *start = settings.icon_path, *end, *current_folder, *maybe_icon_path; do { end = strchr(start, ':'); - if (end == NULL) end = strchr(settings.icon_folders, '\0'); /* end = end of string */ + if (end == NULL) end = strchr(settings.icon_path, '\0'); /* end = end of string */ current_folder = g_strndup(start, end - start); /* try svg */ From 9acb9fd2550d349d55a0f192a2a87cfcc9d43f45 Mon Sep 17 00:00:00 2001 From: George Angelopoulos Date: Sun, 30 Jul 2017 18:34:33 +0200 Subject: [PATCH 2/2] add backwards compatibility for icon_folders option Existing configurations will continue to work but now print a warning. New, icon_path option takes precedence if both options are used. If icon_folders option is used, its usage string also appears in --help output. --- src/settings.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/settings.c b/src/settings.c index 8dee163..c7d43e1 100644 --- a/src/settings.c +++ b/src/settings.c @@ -390,9 +390,23 @@ void load_settings(char *cmdline_config_path) "Scale larger icons down to this size, set to 0 to disable" ); + // If the deprecated icon_folders option is used, + // read it and generate its usage string. + if (ini_is_set("global", "icon_folders") || cmdline_is_set("-icon_folders")) { + settings.icon_path = option_get_string( + "global", + "icon_folders", "-icon_folders", icon_path, + "folders to default icons (deprecated, please use 'icon_path' instead)" + ); + fprintf(stderr, "Warning: 'icon_folders' is deprecated, please use 'icon_path' instead.\n"); + } + // Read value and generate usage string for icon_path. + // If icon_path is set, override icon_folder. + // if not, but icon_folder is set, use that instead of the compile time default. settings.icon_path = option_get_string( "global", - "icon_path", "-icon_path", icon_path, + "icon_path", "-icon_path", + settings.icon_path ? settings.icon_path : icon_path, "paths to default icons" );