about summary refs log tree commit diff
diff options
context:
space:
mode:
authorQuentin Rameau <quinq@fifth.space>2021-07-01 23:40:39 +0200
committerQuentin Rameau <quinq@fifth.space>2021-07-19 22:27:32 +0200
commit238d2273b50c33a1e98ad55750126f05201f911d (patch)
tree16326b24b8a19fd8a6c924eb0cfae22b19854b69
parentFix togglestats array (diff)
downloadsurf-238d2273b50c33a1e98ad55750126f05201f911d.tar.gz
surf-238d2273b50c33a1e98ad55750126f05201f911d.tar.bz2
surf-238d2273b50c33a1e98ad55750126f05201f911d.zip
Improve SETPROP xprop parsing
This handles correctly quotes, backslashes, etc.
-rw-r--r--config.def.h10
1 files changed, 6 insertions, 4 deletions
diff --git a/config.def.h b/config.def.h
index ef44721..3a417f0 100644
--- a/config.def.h
+++ b/config.def.h
@@ -67,10 +67,12 @@ static WebKitFindOptions findopts = WEBKIT_FIND_OPTIONS_CASE_INSENSITIVE |
 /* SETPROP(readprop, setprop, prompt)*/
 #define SETPROP(r, s, p) { \
         .v = (const char *[]){ "/bin/sh", "-c", \
-             "prop=\"$(printf '%b' \"$(xprop -id $1 $2 " \
-             "| sed \"s/^$2(STRING) = //;s/^\\\"\\(.*\\)\\\"$/\\1/\")\" " \
-             "| dmenu -p \"$4\" -w $1)\" && xprop -id $1 -f $3 8s -set $3 \"$prop\"", \
-             "surf-setprop", winid, r, s, p, NULL \
+             "prop=\"$(printf '%b' \"$(xprop -id $1 "r" " \
+             "| sed -e 's/^"r"(STRING) = \"\\(.*\\)\"/\\1/' " \
+             "      -e 's/\\\\\\(.\\)/\\1/g')\" " \
+             "| dmenu -p '"p"' -w $1)\" " \
+             "&& xprop -id $1 -f "s" 8s -set "s" \"$prop\"", \
+             "surf-setprop", winid, NULL \
         } \
 }