WelcomeWelcome | FAQFAQ | DownloadsDownloads | WikiWiki

Author Topic: desktop files with multi Name= and Exec= lines  (Read 3243 times)

Offline Arslan S.

  • Hero Member
  • *****
  • Posts: 825
desktop files with multi Name= and Exec= lines
« on: August 16, 2012, 10:31:45 PM »
writeFLWMitem and writeWBARitem should take only first Name and Exec
this can easily be done with checking if variable is set in functions writeFLWMitem and writeWBARitem

Code: [Select]
--- wbar_update.sh.orig
+++ wbar_update.sh
@@ -6,13 +6,15 @@
 busybox awk -v output="$TMP" -v target="$TARGET" -v wbaricons="$TCEWBAR" '
 BEGIN {
   FS = "="
+  name = ""
+  exec = ""
 }
 function rtrim(s) { sub(/[ \t]+$/, "", s); return s }
 {
-  if ( $1 == "Name") {
+  if ( $1 == "Name" && name == "") {
     name = rtrim($2)
     gsub(/ /, "", name)
-  } else if ( $1 == "Exec" ) {
+  } else if ( $1 == "Exec" && exec == "") {
     exec = $2
     test = match(exec,"%")
     if ( test ) exec = substr(exec,0,test-1)

Code: [Select]
--- flwm_topside_menu_common.orig
+++ flwm_topside_menu_common
@@ -6,12 +6,14 @@
 busybox awk -v output="$TARGET" '
 BEGIN {
   FS = "="
+  name = ""
+  exec = ""
 }
 {
-  if ( $1 == "Name") {
+  if ( $1 == "Name" && name == "") {
     name = $2
     gsub(/ /, "", name)
-  } else if ( $1 == "Exec" ) {
+  } else if ( $1 == "Exec" && exec == "") {
     exec = $2
     test = match(exec,"%")
     if ( test ) exec = substr(exec,0,test-1)

see also
http://forum.tinycorelinux.net/index.php/topic,13855.msg77500.html#new
« Last Edit: August 16, 2012, 10:34:14 PM by Arslan S. »

Offline roberts

  • Retired Admins
  • Hero Member
  • *****
  • Posts: 7361
  • Founder Emeritus
Re: desktop files with multi Name= and Exec= lines
« Reply #1 on: August 17, 2012, 01:03:26 AM »
Arslan, Thanks for the patches. Will apply for 4.6 final.
10+ Years Contributing to Linux Open Source Projects.

Offline Arslan S.

  • Hero Member
  • *****
  • Posts: 825
Re: desktop files with multi Name= and Exec= lines
« Reply #2 on: August 17, 2012, 09:54:58 PM »
hi roberts,
there is one more line in wbar_update.sh that needs to be changed
patch below makes awk exit immediately after first match with return code 0

Code: [Select]
@@ -70,7 +72,7 @@
 FREEDESK=/usr/local/share/applications/"$APPNAME".desktop
 if [ -e "$FREEDESK" ]; then
    ICONCHECK="$(awk 'BEGIN{FS = "="}$1=="X-FullPathIcon"{print $2}' "$FREEDESK")"
-   NAMECHECK="$(awk 'BEGIN{FS = "="}$1=="Name"{print $2}' "$FREEDESK")"
+   NAMECHECK="$(awk 'BEGIN{FS = "="}$1=="Name"{print $2; exit 0}' "$FREEDESK")"
    if grep -qw "^t: *${NAMECHECK// /}$" "${TCEDIR}"/xwbar.lst 2>/dev/null; then exit 0; fi
    TARGET="$APPNAME".img
    [ -f "$ICONCHECK" ] && writeWBARitem "$FREEDESK" && [ -G /tmp/.X11-unix/X0 ] && wbar.sh

Offline roberts

  • Retired Admins
  • Hero Member
  • *****
  • Posts: 7361
  • Founder Emeritus
Re: desktop files with multi Name= and Exec= lines
« Reply #3 on: August 18, 2012, 12:38:20 AM »
OK. Thanks again!
10+ Years Contributing to Linux Open Source Projects.

Offline roberts

  • Retired Admins
  • Hero Member
  • *****
  • Posts: 7361
  • Founder Emeritus
Re: desktop files with multi Name= and Exec= lines
« Reply #4 on: August 18, 2012, 01:11:39 AM »
Now posted updated wbar and flwm* in repository.
10+ Years Contributing to Linux Open Source Projects.

Offline coreplayer2

  • Hero Member
  • *****
  • Posts: 3020
Re: desktop files with multi Name= and Exec= lines
« Reply #5 on: August 18, 2012, 01:15:56 AM »
Cool thanks,  be nice to see if this fixes the issue where icons are labeled incorrectly..