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 | |
parent | 62d317e0d10e849c4ec358ce501ad4909b579cbb (diff) |
Now supports all values uname() can grab in the user agent. See sampleconfig for all variables.
-rw-r--r-- | CHECKLIST | 3 | ||||
-rw-r--r-- | Makefile | 2 | ||||
-rw-r--r-- | examples/configs/sampleconfig | 2 | ||||
-rw-r--r-- | examples/configs/sampleconfig-dev | 2 | ||||
-rw-r--r-- | uzbl.c | 22 |
5 files changed, 27 insertions, 4 deletions
@@ -34,4 +34,5 @@ Also testers and interested people can use this list to see what uzbl is about, * searching: /_ = search %s <-- hilight all ; = search <-- jump over all hits -* run javascript on curent page through "script" command.
\ No newline at end of file +* run javascript on curent page through "script" command. +* variable replacement in user agent.
\ No newline at end of file @@ -1,4 +1,4 @@ -CPPFLAGS=$(shell pkg-config --cflags gtk+-2.0 webkit-1.0) -Wall -W -DKERNVER="\"$(shell uname -r)\"" -DARCH="\"$(shell uname -m)\"" -DCOMMIT="\"$(shell git log | head -n1 | sed "s/.* //")\"" +CPPFLAGS=$(shell pkg-config --cflags gtk+-2.0 webkit-1.0) -Wall -W -DARCH="\"$(shell uname -m)\"" -DCOMMIT="\"$(shell git log | head -n1 | sed "s/.* //")\"" LDFLAGS=$(shell pkg-config --libs gtk+-2.0 webkit-1.0) all: uzbl uzblctrl diff --git a/examples/configs/sampleconfig b/examples/configs/sampleconfig index 4fcdead..ef3f0a8 100644 --- a/examples/configs/sampleconfig +++ b/examples/configs/sampleconfig @@ -57,5 +57,7 @@ proxy_server = #values 0-3 http_debug = 0 user-agent = uzbl (Webkit %webkit-major%.%webkit-minor%.%webkit-micro%) +# Example user agent containing everything: +#user-agent = Uzbl (Webkit %webkit-major%.%webkit-minor%.%webkit-micro%) (%sysname% %nodename% %kernrel% %kernver% %arch-system% [%arch-uzbl%]) max_conns = max_conns_per_host = diff --git a/examples/configs/sampleconfig-dev b/examples/configs/sampleconfig-dev index 9c4664e..443dbb0 100644 --- a/examples/configs/sampleconfig-dev +++ b/examples/configs/sampleconfig-dev @@ -58,6 +58,8 @@ S = script alert("hi"); #values 0-3 http_debug = 0 user-agent = uzbl (Webkit %webkit-major%.%webkit-minor%.%webkit-micro%) +# Example user agent containing everything: +#user-agent = Uzbl (Webkit %webkit-major%.%webkit-minor%.%webkit-micro%) (%sysname% %nodename% %kernrel% %kernver% %arch-system% [%arch-uzbl%]) max_conns = max_conns_per_host = @@ -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); |