diff options
author | Barrucadu <mike@barrucadu.co.uk> | 2009-05-04 10:39:06 +0100 |
---|---|---|
committer | Barrucadu <mike@barrucadu.co.uk> | 2009-05-04 10:39:06 +0100 |
commit | d3dc638149202de26529abd97b39c1a287f72a54 (patch) | |
tree | c026eccaddebd7e32b462bd75b15094d9e6901a3 /uzbl.c | |
parent | 62d317e0d10e849c4ec358ce501ad4909b579cbb (diff) |
Now supports all values uname() can grab in the user agent. See sampleconfig for all variables.
Diffstat (limited to 'uzbl.c')
-rw-r--r-- | uzbl.c | 22 |
1 files changed, 20 insertions, 2 deletions
@@ -40,6 +40,7 @@ #include <sys/stat.h> #include <sys/types.h> #include <sys/un.h> +#include <sys/utsname.h> #include <webkit/webkit.h> #include <stdio.h> #include <string.h> @@ -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); |