Format the settings file better

This commit is contained in:
Nikos Tsipinakis 2017-02-04 15:18:14 +02:00
parent 0c7406f1ba
commit 4aa4e93123

View File

@ -83,77 +83,128 @@ void load_settings(char *cmdline_config_path)
load_ini_file(config_file); load_ini_file(config_file);
#endif #endif
settings.font = settings.font = option_get_string(
option_get_string("global", "font", "-fn", font, "global",
"The font dunst should use."); "font", "-fn", font,
settings.allow_markup = "The font dunst should use."
option_get_bool("global", "allow_markup", "-markup", allow_markup, );
"Allow markups in notifications/formats.");
settings.plain_text = settings.allow_markup = option_get_bool(
option_get_bool("global", "plain_text", "-plain", plain_text, "global",
"Treat incoming notifications as plain text."); "allow_markup", "-markup", allow_markup,
settings.format = "Allow markups in notifications/formats."
option_get_string("global", "format", "-format", format, );
"The format template for the notifications");
settings.sort = settings.plain_text = option_get_bool(
option_get_bool("global", "sort", "-sort", sort, "global",
"Sort notifications by urgency and date?"); "plain_text", "-plain", plain_text,
settings.indicate_hidden = "Treat incoming notifications as plain text."
option_get_bool("global", "indicate_hidden", "-indicate_hidden", );
indicate_hidden,
"Show how many notificaitons are hidden?"); settings.format = option_get_string(
settings.word_wrap = "global",
option_get_bool("global", "word_wrap", "-word_wrap", word_wrap, "format", "-format", format,
"Truncating long lines or do word wrap"); "The format template for the notifications"
);
settings.sort = option_get_bool(
"global",
"sort", "-sort", sort,
"Sort notifications by urgency and date?"
);
settings.indicate_hidden = option_get_bool(
"global",
"indicate_hidden", "-indicate_hidden", indicate_hidden,
"Show how many notificaitons are hidden?"
);
settings.word_wrap = option_get_bool(
"global",
"word_wrap", "-word_wrap", word_wrap,
"Truncating long lines or do word wrap"
);
settings.ignore_newline = option_get_bool(
"global",
"ignore_newline", "-ignore_newline", ignore_newline,
"Ignore newline characters in notifications"
);
settings.idle_threshold = option_get_int(
"global",
"idle_threshold", "-idle_threshold", idle_threshold,
"Don't timeout notifications if user is longer idle than threshold"
);
settings.monitor = option_get_int(
"global",
"monitor", "-mon", monitor,
"On which monitor should the notifications be displayed"
);
settings.ignore_newline =
option_get_bool("global", "ignore_newline", "-ignore_newline",
ignore_newline,
"Ignore newline characters in notifications");
settings.idle_threshold =
option_get_int("global", "idle_threshold", "-idle_threshold",
idle_threshold,
"Don't timeout notifications if user is longer idle than threshold");
settings.monitor =
option_get_int("global", "monitor", "-mon", monitor,
"On which monitor should the notifications be displayed");
{ {
char *c = option_get_string("global", "follow", "-follow", "", char *c = option_get_string(
"Follow mouse, keyboard or none?"); "global",
"follow", "-follow", "",
"Follow mouse, keyboard or none?"
);
if (strlen(c) > 0) { if (strlen(c) > 0) {
parse_follow_mode(c); parse_follow_mode(c);
free(c); free(c);
} }
} }
settings.title =
option_get_string("global", "title", "-t/-title", title, settings.title = option_get_string(
"Define the title of windows spawned by dunst."); "global",
settings.class = "title", "-t/-title", title,
option_get_string("global", "class", "-c/-class", class, "Define the title of windows spawned by dunst."
"Define the class of windows spawned by dunst."); );
settings.geom =
option_get_string("global", "geometry", "-geom/-geometry", geom, settings.class = option_get_string(
"Geometry for the window"); "global",
settings.shrink = "class", "-c/-class", class,
option_get_bool("global", "shrink", "-shrink", "Define the class of windows spawned by dunst."
shrink, );
"Shrink window if it's smaller than the width");
settings.line_height = settings.geom = option_get_string(
option_get_int("global", "line_height", "-lh/-line_height", "global",
line_height, "geometry", "-geom/-geometry", geom,
"Add spacing between lines of text"); "Geometry for the window"
settings.notification_height = );
option_get_int("global", "notification_height", "-nh/-notification_height",
notification_height, settings.shrink = option_get_bool(
"Define height of the window"); "global",
settings.bounce_freq = "shrink", "-shrink", shrink,
option_get_double("global", "bounce_freq", "-bounce_freq", "Shrink window if it's smaller than the width"
bounce_freq, );
"Make long text bounce from side to side");
settings.line_height = option_get_int(
"global",
"line_height", "-lh/-line_height", line_height,
"Add spacing between lines of text"
);
settings.notification_height = option_get_int(
"global",
"notification_height", "-nh/-notification_height", notification_height,
"Define height of the window"
);
settings.bounce_freq = option_get_double(
"global",
"bounce_freq", "-bounce_freq", bounce_freq,
"Make long text bounce from side to side"
);
{ {
char *c = option_get_string("global", "alignment", char *c = option_get_string(
"-align/-alignment", "", "global",
"Align notifications left/center/right"); "alignment", "-align/-alignment", "",
"Align notifications left/center/right"
);
if (strlen(c) > 0) { if (strlen(c) > 0) {
if (strcmp(c, "left") == 0) if (strcmp(c, "left") == 0)
settings.align = left; settings.align = left;
@ -167,44 +218,68 @@ void load_settings(char *cmdline_config_path)
free(c); free(c);
} }
} }
settings.show_age_threshold =
option_get_int("global", "show_age_threshold", settings.show_age_threshold = option_get_int(
"-show_age_threshold", show_age_threshold, "global",
"When should the age of the notification be displayed?"); "show_age_threshold", "-show_age_threshold", show_age_threshold,
settings.hide_duplicates_count = "When should the age of the notification be displayed?"
option_get_bool("global", "hide_duplicates_count", );
"-hide_duplicates_count", false,
"Hide count of the merged notifications with the same content"); settings.hide_duplicates_count = option_get_bool(
settings.sticky_history = "global",
option_get_bool("global", "sticky_history", "-sticky_history", "hide_duplicates_count", "-hide_duplicates_count", false,
sticky_history, "Hide count of the merged notifications with the same content"
"Don't timeout notifications popped up from history"); );
settings.history_length =
option_get_int("global", "history_length", "-history_length", settings.sticky_history = option_get_bool(
history_length, "global",
"Max amount of notifications kept in history"); "sticky_history", "-sticky_history", sticky_history,
settings.show_indicators = "Don't timeout notifications popped up from history"
option_get_bool("global", "show_indicators", "-show_indicators", );
show_indicators,
"Show indicators for actions \"(A)\" and URLs \"(U)\""); settings.history_length = option_get_int(
settings.separator_height = "global",
option_get_int("global", "separator_height", "history_length", "-history_length", history_length,
"-sep_height/-separator_height", separator_height, "Max amount of notifications kept in history"
"height of the separator line"); );
settings.padding =
option_get_int("global", "padding", "-padding", padding, settings.show_indicators = option_get_bool(
"Padding between text and separator"); "global",
settings.h_padding = "show_indicators", "-show_indicators", show_indicators,
option_get_int("global", "horizontal_padding", "Show indicators for actions \"(A)\" and URLs \"(U)\""
"-horizontal_padding", h_padding, );
"horizontal padding");
settings.transparency = settings.separator_height = option_get_int(
option_get_int("global", "transparency", "-transparency", "global",
transparency, "Transparency. range 0-100"); "separator_height", "-sep_height/-separator_height", separator_height,
"height of the separator line"
);
settings.padding = option_get_int(
"global",
"padding", "-padding", padding,
"Padding between text and separator"
);
settings.h_padding = option_get_int(
"global",
"horizontal_padding", "-horizontal_padding", h_padding,
"horizontal padding"
);
settings.transparency = option_get_int(
"global",
"transparency", "-transparency", transparency,
"Transparency. range 0-100"
);
{ {
char *c = option_get_string("global", "separator_color", char *c = option_get_string(
"-sep_color/-separator_color", "", "global",
"Color of the separator line (or 'auto')"); "separator_color", "-sep_color/-separator_color", "",
"Color of the separator line (or 'auto')"
);
if (strlen(c) > 0) { if (strlen(c) > 0) {
if (strcmp(c, "auto") == 0) if (strcmp(c, "auto") == 0)
settings.sep_color = AUTO; settings.sep_color = AUTO;
@ -220,27 +295,39 @@ void load_settings(char *cmdline_config_path)
} }
} }
settings.stack_duplicates = option_get_bool("global", "stack_duplicates", settings.stack_duplicates = option_get_bool(
"-stack_duplicates", true, "Merge multiple notifications with the same content"); "global",
"stack_duplicates", "-stack_duplicates", true,
"Merge multiple notifications with the same content"
);
settings.startup_notification = settings.startup_notification = option_get_bool(
option_get_bool("global", "startup_notification", "global",
"-startup_notification", false, "startup_notification", "-startup_notification", false,
"print notification on startup"); "print notification on startup"
);
settings.dmenu = option_get_string(
"global",
"dmenu", "-dmenu", dmenu,
"path to dmenu"
);
settings.dmenu =
option_get_string("global", "dmenu", "-dmenu", dmenu,
"path to dmenu");
settings.dmenu_cmd = string_to_argv(settings.dmenu); settings.dmenu_cmd = string_to_argv(settings.dmenu);
settings.browser = settings.browser = option_get_string(
option_get_string("global", "browser", "-browser", browser, "global",
"path to browser"); "browser", "-browser", browser,
"path to browser"
);
{ {
char *c = option_get_string("global", "icon_position", char *c = option_get_string(
"-icon_position", "off", "global",
"Align icons left/right/off"); "icon_position", "-icon_position", "off",
"Align icons left/right/off"
);
if (strlen(c) > 0) { if (strlen(c) > 0) {
if (strcmp(c, "left") == 0) if (strcmp(c, "left") == 0)
settings.icon_position = icons_left; settings.icon_position = icons_left;
@ -255,95 +342,154 @@ void load_settings(char *cmdline_config_path)
} }
} }
settings.max_icon_size = settings.max_icon_size = option_get_int(
option_get_int("global", "max_icon_size", "-max_icon_size", max_icon_size, "global",
"Scale larger icons down to this size, set to 0 to disable"); "max_icon_size", "-max_icon_size", max_icon_size,
"Scale larger icons down to this size, set to 0 to disable"
);
settings.icon_folders = settings.icon_folders = option_get_string(
option_get_string("global", "icon_folders", "-icon_folders", icon_folders, "global",
"paths to default icons"); "icon_folders", "-icon_folders", icon_folders,
"paths to default icons"
);
settings.frame_width = settings.frame_width = option_get_int(
option_get_int("frame", "width", "-frame_width", frame_width, "frame",
"Width of frame around window"); "width", "-frame_width", frame_width,
"Width of frame around window"
);
settings.frame_color = settings.frame_color = option_get_string(
option_get_string("frame", "color", "-frame_color", frame_color, "frame",
"Color of the frame around window"); "color", "-frame_color", frame_color,
"Color of the frame around window"
);
settings.lowbgcolor = settings.lowbgcolor = option_get_string(
option_get_string("urgency_low", "background", "-lb", lowbgcolor, "urgency_low",
"Background color for notifications with low urgency"); "background", "-lb", lowbgcolor,
settings.lowfgcolor = "Background color for notifications with low urgency"
option_get_string("urgency_low", "foreground", "-lf", lowfgcolor, );
"Foreground color for notifications with low urgency");
settings.lowframecolor =
option_get_string("urgency_low", "frame_color", "-lfr", NULL,
"Frame color for notifications with low urgency");
settings.timeouts[LOW] =
option_get_int("urgency_low", "timeout", "-lto", timeouts[LOW],
"Timeout for notifications with low urgency");
settings.icons[LOW] =
option_get_string("urgency_low", "icon", "-li", icons[LOW],
"Icon for notifications with low urgency");
settings.normbgcolor =
option_get_string("urgency_normal", "background", "-nb",
normbgcolor,
"Background color for notifications with normal urgency");
settings.normfgcolor =
option_get_string("urgency_normal", "foreground", "-nf",
normfgcolor,
"Foreground color for notifications with normal urgency");
settings.normframecolor =
option_get_string("urgency_normal", "frame_color", "-nfr", NULL,
"Frame color for notifications with normal urgency");
settings.timeouts[NORM] =
option_get_int("urgency_normal", "timeout", "-nto", timeouts[NORM],
"Timeout for notifications with normal urgency");
settings.icons[NORM] =
option_get_string("urgency_normal", "icon", "-ni", icons[NORM],
"Icon for notifications with normal urgency");
settings.critbgcolor =
option_get_string("urgency_critical", "background", "-cb",
critbgcolor,
"Background color for notifications with critical urgency");
settings.critfgcolor =
option_get_string("urgency_critical", "foreground", "-cf",
critfgcolor,
"Foreground color for notifications with ciritical urgency");
settings.critframecolor =
option_get_string("urgency_critical", "frame_color", "-cfr", NULL,
"Frame color for notifications with critical urgency");
settings.timeouts[CRIT] =
option_get_int("urgency_critical", "timeout", "-cto", timeouts[CRIT],
"Timeout for notifications with critical urgency");
settings.icons[CRIT] =
option_get_string("urgency_critical", "icon", "-ci", icons[CRIT],
"Icon for notifications with critical urgency");
settings.close_ks.str = settings.lowfgcolor = option_get_string(
option_get_string("shortcuts", "close", "-key", close_ks.str, "urgency_low",
"Shortcut for closing one notification"); "foreground", "-lf", lowfgcolor,
settings.close_all_ks.str = "Foreground color for notifications with low urgency"
option_get_string("shortcuts", "close_all", "-all_key", );
close_all_ks.str,
"Shortcut for closing all notifications");
settings.history_ks.str =
option_get_string("shortcuts", "history", "-history_key",
history_ks.str,
"Shortcut to pop the last notification from history");
settings.context_ks.str = settings.lowframecolor = option_get_string(
option_get_string("shortcuts", "context", "-context_key", "urgency_low",
context_ks.str, "Shortcut for context menu"); "frame_color", "-lfr", NULL,
"Frame color for notifications with low urgency"
);
settings.print_notifications = settings.timeouts[LOW] = option_get_int(
cmdline_get_bool("-print", false, "urgency_low",
"Print notifications to cmdline (DEBUG)"); "timeout", "-lto", timeouts[LOW],
"Timeout for notifications with low urgency"
);
settings.always_run_script = settings.icons[LOW] = option_get_string(
option_get_bool("global", "always_run_script", "-always_run_script", true, "urgency_low",
"Always run rule-defined scripts, even if the notification is suppressed with format = \"\"."); "icon", "-li", icons[LOW],
"Icon for notifications with low urgency"
);
settings.normbgcolor = option_get_string(
"urgency_normal",
"background", "-nb", normbgcolor,
"Background color for notifications with normal urgency"
);
settings.normfgcolor = option_get_string(
"urgency_normal",
"foreground", "-nf", normfgcolor,
"Foreground color for notifications with normal urgency"
);
settings.normframecolor = option_get_string(
"urgency_normal",
"frame_color", "-nfr", NULL,
"Frame color for notifications with normal urgency"
);
settings.timeouts[NORM] = option_get_int(
"urgency_normal",
"timeout", "-nto", timeouts[NORM],
"Timeout for notifications with normal urgency"
);
settings.icons[NORM] = option_get_string(
"urgency_normal",
"icon", "-ni", icons[NORM],
"Icon for notifications with normal urgency"
);
settings.critbgcolor = option_get_string(
"urgency_critical",
"background", "-cb", critbgcolor,
"Background color for notifications with critical urgency"
);
settings.critfgcolor = option_get_string(
"urgency_critical",
"foreground", "-cf", critfgcolor,
"Foreground color for notifications with ciritical urgency"
);
settings.critframecolor = option_get_string(
"urgency_critical",
"frame_color", "-cfr", NULL,
"Frame color for notifications with critical urgency"
);
settings.timeouts[CRIT] = option_get_int(
"urgency_critical",
"timeout", "-cto", timeouts[CRIT],
"Timeout for notifications with critical urgency"
);
settings.icons[CRIT] = option_get_string(
"urgency_critical",
"icon", "-ci", icons[CRIT],
"Icon for notifications with critical urgency"
);
settings.close_ks.str = option_get_string(
"shortcuts",
"close", "-key", close_ks.str,
"Shortcut for closing one notification"
);
settings.close_all_ks.str = option_get_string(
"shortcuts",
"close_all", "-all_key", close_all_ks.str,
"Shortcut for closing all notifications"
);
settings.history_ks.str = option_get_string(
"shortcuts",
"history", "-history_key", history_ks.str,
"Shortcut to pop the last notification from history"
);
settings.context_ks.str = option_get_string(
"shortcuts",
"context", "-context_key", context_ks.str,
"Shortcut for context menu"
);
settings.print_notifications = cmdline_get_bool(
"-print", false,
"Print notifications to cmdline (DEBUG)"
);
settings.always_run_script = option_get_bool(
"global",
"always_run_script", "-always_run_script", true,
"Always run rule-defined scripts, even if the notification is suppressed with format = \"\"."
);
/* push hardcoded default rules into rules list */ /* push hardcoded default rules into rules list */
for (int i = 0; i < LENGTH(default_rules); i++) { for (int i = 0; i < LENGTH(default_rules); i++) {