@muts
Unfortunately, I haven't managed to contact you via IRC (yet)
@All
Although this is WIP, I'd like to share my current state of .desktop conversation. I've written an awk-script and a shell-script that modifies the .desktop files in /usr/local/share/applications/ to get them working with gnome-terminal. I need to consider some excludes (e.g. SAINT) tough - this isn't done yet.
test3.awk looks like this
Code:
#!/usr/bin/awk -f
BEGIN{FS="="}
$1=="Exec" {exec = $2;en=NR}
$1=="Path" {path = $2}
{array[NR]=$0}
END{
if (exec~/cd / || path == ""){
exec="gnome-terminal -x bash -c ""\""exec"\"";
} else {
exec="gnome-terminal -x bash -c ""\"""cd "path";"exec"\"";
}
array[en]="Exec=" exec
for(i=1;i<=NR;i++){
print array[i]
}
}
test3.sh like this
Code:
#!/bin/sh
for i in /usr/local/share/applications/*.desktop; do
cp "$i" "$i.orig"; ./test3.awk "$i" > "$i.tmp"; mv "$i.tmp" "$i";
done
Any input from "coding gurus" is certainly appreciated and besides general documentation purposes the reason I post this.
EDIT 06-09-2009
Just for the record: here's today's outcome, i.e. another step forward to a KDE/Gnome cross-desktop compatible solution. I'll explain this in detail another time - it's pretty late already. I thought about posting it though as it's from my perspective way better than yesterday's solution and thus should be documented - in case anyone wants to try it.
test4.sh
Code:
#!/bin/sh
for i in /usr/local/share/applications/*.desktop; do
cp "$i" "$i.orig"; ./test4.awk "$i" > "$i.tmp"; mv "$i.tmp" "$i";
done
test4.awk
Code:
#!/usr/bin/awk -f
BEGIN{FS="="}
$1=="Exec" {exec = $2;en=NR}
{array[NR]=$0}
END{
split(exec, esplit, ";")
if(esplit[2] > ""){
exec="sh -c ""\""exec"\""
}
array[en]="Exec=" exec
for(i=1;i<=NR;i++){
print array[i]
}
}
EDIT 06-10-2009
One more revision to the awk script - this one also considers " as a restricted character in the Exec key and takes care of escaping it - just a minor change to yesterday's version though
Code:
#!/usr/bin/awk -f
BEGIN{FS="="}
$1=="Exec" {exec = $2;en=NR}
{array[NR]=$0}
END{
gsub(/\"/,"\\\"",exec)
split(exec, esplit, ";")
if(esplit[2] > ""){
exec="sh -c ""\""exec"\""
}
array[en]="Exec=" exec
for(i=1;i<=NR;i++){
print array[i]
}
}
EDIT 06-11-2009
No need for head banging anymore - the issue is finally solved and the solution is documented here
best,
orange