aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--CHECKLIST3
-rw-r--r--Makefile2
-rw-r--r--examples/configs/sampleconfig2
-rw-r--r--examples/configs/sampleconfig-dev2
-rw-r--r--uzbl.c22
5 files changed, 27 insertions, 4 deletions
diff --git a/CHECKLIST b/CHECKLIST
index 66f7bf6..292f9ab 100644
--- a/CHECKLIST
+++ b/CHECKLIST
@@ -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
diff --git a/Makefile b/Makefile
index 906436f..622a79a 100644
--- a/Makefile
+++ b/Makefile
@@ -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 =
diff --git a/uzbl.c b/uzbl.c
index ae7c755..39417cf 100644
--- a/uzbl.c
+++ b/uzbl.c
@@ -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);