On Fri, Aug 25, 2006 at 10:58:15PM +0200, Toby Cubitt wrote: > On Fri, Aug 25, 2006 at 12:22:47PM +0100, Asfand Yar Qazi wrote: > > I don't know if it's already been done, but here's a little script > > that reads in all key bindings from enlightenment_remote, and > > substitutes all uses of ALT with WIN. > > > > Just thought it might be useful to someone. If there's a better > > solution out there, please tell me! > > Looks to me like a job for a sed + xargs one-liner(*) to me... > > (*) left as an exercise for the reader ;-)
OK, I got curious as to how easy this would be, so here's my attempt: (split over multiple lines for clarity(!), but it could all be on one...) enlightenment_remote -binding-key-list | grep -v '<-' | \ tr = " " | cut -d" " -f4,6,8,10,12,14 | \ while read context key mod anymod action params; do \ if [[ -n "`echo $mod | grep ALT`" ]]; then \ enlightenment_remote -binding-key-del \ $context $key $mod $anymod $action $params; \ enlightenment_remote -binding-key-add \ $context $key `echo $mod | sed 's/ALT/WIN/g'` \ $anymod $action $params; \ fi; \ done Admittedly, this doesn't use xargs after all. The (trimmed) enlightenment_remote output contains VAR=VALUE pairs, which is already in the right format for setting bash variables. So I wanted to pipe it to xargs and get it to set temporary shell variables, then execute the enlightenment remote commands using those variables. But I couldn't figure out how to get xargs to set shell variables based on the text it receives from the pipe. Instead, I munged the output with the tr and cut commands, then piped it to the while loop and the read command, etc. Anyone know if there's a way to do what I want using xargs? Or indeed any way to shorten it? Of course, this isn't the diehard-bash-scripting-junkies mailing list, so perhaps this is getting off-topic ;-) But I do like the fact that an entire object-oriented, relational-database-driven, automatic, systematic, hydromatic, all-singing, all-dancing, fully web 3.0 hype-infused ruby program can be replaced by one line of (incomprehensible) bash ;-) Toby PS: I've never even tried programming in ruby, so please don't take my inane comments seriously ;-) -- PhD Student Quantum Information Theory group Max Planck Institute for Quantum Optics Garching, Germany email: [EMAIL PROTECTED] web: www.dr-qubit.org ------------------------------------------------------------------------- Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 _______________________________________________ enlightenment-users mailing list enlightenment-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/enlightenment-users