From d3dc638149202de26529abd97b39c1a287f72a54 Mon Sep 17 00:00:00 2001 From: Barrucadu Date: Mon, 4 May 2009 10:39:06 +0100 Subject: Now supports all values uname() can grab in the user agent. See sampleconfig for all variables. --- uzbl.c | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) (limited to 'uzbl.c') diff --git a/uzbl.c b/uzbl.c index ae7c755..39417cf 100644 --- a/uzbl.c +++ b/uzbl.c @@ -40,6 +40,7 @@ #include #include #include +#include #include #include #include @@ -92,6 +93,9 @@ static gchar* modkey = NULL; static guint modmask = 0; static guint http_debug = 0; +/* System info */ +static struct utsname unameinfo; + /* settings from config: group bindings, key -> action */ static GHashTable* bindings; @@ -971,8 +975,22 @@ settings_init () { strcpy(newagent, str_replace("%webkit-major%", itos(WEBKIT_MAJOR_VERSION), useragent)); strcpy(newagent, str_replace("%webkit-minor%", itos(WEBKIT_MINOR_VERSION), newagent)); strcpy(newagent, str_replace("%webkit-micro%", itos(WEBKIT_MICRO_VERSION), newagent)); - strcpy(newagent, str_replace("%kernver%", KERNVER, newagent)); - strcpy(newagent, str_replace("%arch%", ARCH, newagent)); + + if (uname (&unameinfo) == -1) { + printf("Error getting uname info. Not replacing system-related user agent variables.\n"); + } else { + strcpy(newagent, str_replace("%sysname%", unameinfo.sysname, newagent)); + strcpy(newagent, str_replace("%nodename%", unameinfo.nodename, newagent)); + strcpy(newagent, str_replace("%kernrel%", unameinfo.release, newagent)); + strcpy(newagent, str_replace("%kernver%", unameinfo.version, newagent)); + strcpy(newagent, str_replace("%arch-system%", unameinfo.machine, newagent)); + + #ifdef _GNU_SOURCE + strcpy(newagent, str_replace("%domainname%", unameinfo.domainname, newagent)); + #endif + } + + strcpy(newagent, str_replace("%arch-uzbl%", ARCH, newagent)); strcpy(newagent, str_replace("%commit%", COMMIT, newagent)); useragent = malloc(1024); -- cgit v1.2.3