(OLD) (ARCHIVED) Puppy Linux Discussion Forum Forum Index (OLD) (ARCHIVED) Puppy Linux Discussion Forum
Puppy HOME page : puppylinux.com
"THE" alternative forum : puppylinux.info

This forum can also be accessed as http://oldforum.puppylinux.com
It is now read-only and serves only as archives.

Please register over the NEW forum
https://forum.puppylinux.com
and continue your work there. Thank you.

 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups    
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

The time now is Wed 23 Sep 2020, 03:40
All times are UTC - 4
 Forum index » Advanced Topics » Additional Software (PETs, n' stuff) » Filesystem
Find'N'Run
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies. View previous topic :: View next topic
Page 5 of 7 [104 Posts]   Goto page: Previous 1, 2, 3, 4, 5, 6, 7 Next
Author Message
L18L


Joined: 19 Jun 2010
Posts: 3493
Location: www.eussenheim.de/

PostPosted: Wed 08 Apr 2015, 13:47    Post subject: sort order of translated Names in desktop files  

SFR wrote:
... I have never encountered a .desktop file where 'Name[lang]=' is before 'Name=' (that's where my "assumption" came from Wink), have you?

Yes I have them en masse: created by momanager.
I have changed it in latest momanager now, but there might still exist many of them.

SFR wrote:
Takes slightly more time, too, but still way below 0.100s (i3@2.13GHz).

Btw, side effect: it now picks up correct 'Name=' field from transmission-qt.desktop (an issue mentioned on previous page).
That is, of course much better (and we have hundreds of millisecods available) !

So I leave my script, integrated into findnrun for the records only.
Code:
.
.
.
LOC1="/usr/share/applications/"
LOC2="/usr/local/share/applications/"
LOC3="${XDG_DATA_HOME}/applications/"
#LOC4="${HOME}/.local/share/applications/"

CONFIG="${HOME}/.findnrunrc"

check_and_fix() {
 DIR=${1%/*}
 if [ -d ${DIR} ]; then
  mv -f ${DIR} ${DIR}_ || exit 0
  mkdir -p ${DIR}
  cd ${DIR}_
  for f in `ls *.desktop`; do
   sed q $f > ${DIR}/${f} # first line: [Desktop Entry]
   sort $f | grep -v '^\[' >> ${DIR}/${f}
  done
  cd - >/dev/null
  rm -rf ${DIR}_
 fi
}

case $1 in -c)
 Xdialog --msgbox "Check and fix sort order of translations ..." 0 0 &
 cPID=$!
 for LOC in $LOC1 $LOC2 $LOC3 ; do check_and_fix $LOC; done
 kill $cPID
 exit
esac
launched by right click via AppInfo.xml
Code:
  <AppMenu>
    <Item option="-c" icon="gtk-find">
      <Label>Check and fix order of translation</Label>
      <Label xml:lang="de">Reihenfolge der Übersetzungen prüfen und reparieren</Label>
    </Item>

Greetings

Last edited by L18L on Thu 09 Apr 2015, 09:48; edited 1 time in total
Back to top
View user's profile Send private message 
SFR


Joined: 26 Oct 2011
Posts: 1802

PostPosted: Wed 08 Apr 2015, 14:14    Post subject:  

Oh yes, I have found lots of them, too, in Polish langpack for Slacko.
Ok, so updated to v1.5.

Thanks &
Greetings!

_________________
[O]bdurate [R]ules [D]estroy [E]nthusiastic [R]ebels => [C]reative [H]umans [A]lways [O]pen [S]ource
Omnia mea mecum porto.
Back to top
View user's profile Send private message 
L18L


Joined: 19 Jun 2010
Posts: 3493
Location: www.eussenheim.de/

PostPosted: Thu 09 Apr 2015, 03:43    Post subject: v1.5
Subject description: sorry
 

Sorry, Name[lang] has to overwrite (or override) Name. Wink
findnrun-1.5_bug.png
 Description   
 Filesize   16.06 KB
 Viewed   460 Time(s)

findnrun-1.5_bug.png

Back to top
View user's profile Send private message 
SFR


Joined: 26 Oct 2011
Posts: 1802

PostPosted: Thu 09 Apr 2015, 04:40    Post subject:  

Hmm, it's fine down here. Don't you have, by accident, a second abiword.desktop file without 'Name[de]=' field (only 'Name=')?

Greetings!
Screenshot.jpg
 Description   
 Filesize   77.63 KB
 Viewed   439 Time(s)

Screenshot.jpg


_________________
[O]bdurate [R]ules [D]estroy [E]nthusiastic [R]ebels => [C]reative [H]umans [A]lways [O]pen [S]ource
Omnia mea mecum porto.
Back to top
View user's profile Send private message 
L18L


Joined: 19 Jun 2010
Posts: 3493
Location: www.eussenheim.de/

PostPosted: Thu 09 Apr 2015, 11:56    Post subject: Find'N'Run v1.5
Subject description: my false alert
 

SFR wrote:
Don't you have, by accident, a second abiword.desktop file without 'Name[de]=' field (only 'Name=')?

Not by accident, but I have forgot why I did it:
/root/.local/share/applications wrote:
Name=AbiWord
Name[de]=AbiWord
Name[es]=Procesador de textos Abiword
Name[fi]=AbiWord
Name[fr]=Traitement de texte AbiWord

Or did I do it to test LOC3? (greetings from Alzheimer)

BTW, all lines Name[lang] which have the same value as Name should be deleted. Always!
There must be a script for this....

Back to the actual problem
I do have 2 different Name[de] for abiword.desktop
1 in /usr/share/applications
1 in $HOME/.local/share/applications

or one in LOC1 and another in LOC3.

A solution could be
Give LOC3 precedence over LOC2 over LOC1
Just to not confuse nobody. Question
No, it makes sense in a multi user system! Idea

Maybe my false alert can be good for something else.
Greetings
Back to top
View user's profile Send private message 
L18L


Joined: 19 Jun 2010
Posts: 3493
Location: www.eussenheim.de/

PostPosted: Thu 09 Apr 2015, 13:59    Post subject: Re: Find'N'Run v1.5
Subject description: my false alert
 

L18L wrote:
BTW, all lines Name[lang] which have the same value as Name should be deleted. Always!
There must be a script for this....

Found it.
Let us call it desktop_files_lang_fix.sh
and launch it from something like:
Code:
for LOC in $LOC1 $LOC2 $LOC3 ; do desktop_files_lang_fix.sh $LOC; done

Code:
#!/bin/sh
#
# .desktp files (and .directory files) sometimes have a really very
#         strange use of language code.
# de_DE prevents (de_AT, de_BE, de_LU and de_CH)
#       Austrian Belgian Luxemburg and Switzerland from being used.
# similiar for other languages...it_CH...fr_BE
#

#
# fix *.desktop for each ITEM in Name GenericName Comment
#  rename Name[de_DE] to    Name[de] if not existant
#  delete Name[es_VE] if Name[es] has identical value
#  delete Name[de] if value equals Name (if not [..@latin], Chinese,...)
#     

die() { [ "$DISPLAY" ] && xmessage "$1" || echo $1 ; exit 1; } 
WD=/tmp/$0 ; mkdir -p $WD # temp dir

#IN=/usr/share/razor/razor-panel/clock.desktop # was 1st test file
IN=$1
EXT="${IN##*.}"
[ "${EXT}" = "desktop" -o "${EXT}" = "directory" ] || die "${IN} neither .desktop nor .directory file"
[ -f "${IN}" ] || die "file $1 not found."
[ -r "${IN}" ] || die "file $1 not readable."
[ -w "${IN}" ] || die "file $1 not writeable."
echo $IN  #log
for identifier in Name GenericName Comment ; do
  # store English Name GenericName Comment ex: 'Date & time' in file 'Name'
  aVALUE="`grep -m 1 "^${identifier}=" $IN | cut -d'=' -f2-`"
  [ "$aVALUE" ] && echo "$aVALUE" > ${WD}/"`grep -m 1 "^${identifier}=" $IN | cut -d'=' -f1`"
done
cd ${WD};for f in *;do echo -n ${f}=;cat $f;done;cd - >/dev/null #log

DOIT()
{
  identifier=$1 # ex: Name
  lang_loc=${NAME%%]*};lang_loc=${lang_loc##*[} #ex:de_DE
  case $lang_loc in
    *@*) continue ;;
    zh*) continue ;;
  esac
  #sed needs this:
  LINE="${LINE//[/\[}"
  LINE="${LINE//]/\]}"
  #del LINE if value identic with unlocalized VALUE
  [ "$VALUE" = "`cat ${WD}/${identifier}`" ] && sed -i "/${LINE}/d" $IN 
  # 
  lang=${lang_loc%%_*} #ex:de
  loc=${lang_loc##*_}  #ex:DE
  [ "$loc" = "$lang" ] && loc=
  if [ "$loc" ] ; then
    COMP="`grep "^${identifier}\[${lang}\]" $IN | cut -d'=' -f1-`"
    if [ "$COMP" ]; then
      sed -i "/${LINE}/d" $IN
      echo deleted ${identifier}[${lang}_${loc}] because value identic with ${identifier}[$lang]
    else
      changedLINE=${LINE//_$loc/}
      # append all changes for better manul checking
      sed -i "/${LINE}/d" $IN
      grep "${changedLINE}" $IN || echo "${changedLINE//\\/}" >> $IN
      echo ${identifier}[${lang}_${loc}] renamed to ${identifier}[${lang}] as ${identifier}[${lang}] not existant
    fi   
  fi
}

for repeat in 0 1; do
  #for identifier in Comment Name Comment Name ; do # repeat needed for delete
  for identifier in `cd ${WD};ls;cd - >/dev/null`; do # repeat needed for delete
    while read LINE; do
      NAME=${LINE%%=*}
      VALUE=${LINE##*=}
      case $NAME in
        ${identifier}\[*)
          DOIT ${identifier}
          ;;
      esac
    done < $IN
  done
  [ $repeat -eq 0 ] && echo check again # log
done
echo checked # log
rm -r $WD
exit 0
Back to top
View user's profile Send private message 
L18L


Joined: 19 Jun 2010
Posts: 3493
Location: www.eussenheim.de/

PostPosted: Sat 11 Apr 2015, 06:51    Post subject: Re: Find'N'Run v1.5
Subject description: my fix for multiple LOCs
 

L18L wrote:
I do have 2 different Name[de] for abiword.desktop
1 in /usr/share/applications
1 in $HOME/.local/share/applications

or one in LOC1 and another in LOC3.

A solution could be
Give LOC3 precedence over LOC2 over LOC1
Just to not confuse nobody. Question
No, it makes sense in a multi user system! Idea

Thus I have edited my /root/.local/share/applications/abiword.desktop for this test only.
Code:
Name[de]=AbiWord in local

and changed version 1.6 of the code (just 1 line) to:
Code:
      <input>grep -H -R -E "^Name(\['${LR}'\]|\['${L}'\])?=" '${LOC3}' '${LOC2}' '${LOC1}' --include="*.desktop" 2>/dev/null | sort -t: -k2.1,2.9  -u | sort -t= -k1,1 -d -r | sort -t: -u -k1,1 | cut -f2- -d "=" | sort -f -u | grep -F -i -- "$varENTRY"</input>

Note1, The changed sequence of LOC3 LOC2 LOC1 gave precedence to LOC3
Note2, sort -t: -k2.1,2.9 -u picked just one Name[de]= or Name[de_D (a dirty hack Laughing )

See result in screenshot.


---
EDIT
Why are there Touchpad and Flashplayer now Question
findnrun_local_applications_abiword.desktop.png
 Description   
 Filesize   27.42 KB
 Viewed   364 Time(s)

findnrun_local_applications_abiword.desktop.png

Back to top
View user's profile Send private message 
SFR


Joined: 26 Oct 2011
Posts: 1802

PostPosted: Sat 11 Apr 2015, 13:30    Post subject:  

Hey L18L

Well, I think changing the order of LOCations would be enough, i.e. if there are two .desktop files with the same 'Name' fields, only the one from $HOME/.local... will be picked up.
But if those files would have different 'Name' fileds, why should we pick only one of them?

Quote:
Why are there Touchpad and Flashplayer now Question

Because sort -t: -k2.1,2.9 -u somehow excludes almost all lines with [lang], so the defaults in English popped up instead.

Ok, LOCs re-ordered in v1.6.

Thanks &
Greetings!

_________________
[O]bdurate [R]ules [D]estroy [E]nthusiastic [R]ebels => [C]reative [H]umans [A]lways [O]pen [S]ource
Omnia mea mecum porto.
Back to top
View user's profile Send private message 
L18L


Joined: 19 Jun 2010
Posts: 3493
Location: www.eussenheim.de/

PostPosted: Sun 12 Apr 2015, 04:00    Post subject: Find'N'Run v1.6
Subject description: LOC3
 

SFR wrote:
Hey L18L

Well, I think changing the order of LOCations would be enough, i.e. if there are two .desktop files with the same 'Name' fields, only the one from $HOME/.local... will be picked up.
But if those files would have different 'Name' fileds, why should we pick only one of them?

Makes only sense if they are different.
Each USER can use another content of Name[lang] stored in their $HOME/.local/.....
Quote:
Quote:
Why are there Touchpad and Flashplayer now Question
Because sort -t: -k2.1,2.9 -u somehow excludes almost all lines with [lang], so the defaults in English popped up instead.
Ah yes, yes are right; and the translations did not start with "A".

Quote:
Ok, LOCs re-ordered in v1.6.
Hope that helps. Very Happy

Thanks &
Greetings!
Back to top
View user's profile Send private message 
SFR


Joined: 26 Oct 2011
Posts: 1802

PostPosted: Mon 13 Apr 2015, 11:49    Post subject:  

Update - version 1.7:

I tried a bit different approach for searching/filtering.
Now the actual path to appropriate .desktop file goes to column 0 (which is invisible; names are in column 1), so it's no longer possible to pick up wrong exec.
Duplicates are also allowed, so if you have two different apps installed (e.g. ROX-Term and LXTerm) that share the same 'Name' field (e.g. Name=Terminal), both will be displayed.

Greetings!

_________________
[O]bdurate [R]ules [D]estroy [E]nthusiastic [R]ebels => [C]reative [H]umans [A]lways [O]pen [S]ource
Omnia mea mecum porto.
Back to top
View user's profile Send private message 
step

Joined: 04 May 2012
Posts: 1352

PostPosted: Thu 30 Apr 2015, 04:25    Post subject: unexport variables  

Enhancement request: unexport all (4) exported variables before launching the target program.
Test in Fatdog64: Find urxvt terminal and run. Type "set" in the command line and see the variables that find'n'run leaves exported.
Thanks, great script!

_________________
Fatdog64-810|+Packages|Kodi|gtkmenuplus
Back to top
View user's profile Send private message 
SFR


Joined: 26 Oct 2011
Posts: 1802

PostPosted: Thu 30 Apr 2015, 05:16    Post subject:  

Thanks Step, fixed in v1.8.

Greetings!

_________________
[O]bdurate [R]ules [D]estroy [E]nthusiastic [R]ebels => [C]reative [H]umans [A]lways [O]pen [S]ource
Omnia mea mecum porto.
Back to top
View user's profile Send private message 
SFR


Joined: 26 Oct 2011
Posts: 1802

PostPosted: Mon 25 May 2015, 07:54    Post subject:  

Version 1.9 - fixed a typo: "opened" -> "open" (thanks to step).

First post updated!

Greetings!

_________________
[O]bdurate [R]ules [D]estroy [E]nthusiastic [R]ebels => [C]reative [H]umans [A]lways [O]pen [S]ource
Omnia mea mecum porto.
Back to top
View user's profile Send private message 
SFR


Joined: 26 Oct 2011
Posts: 1802

PostPosted: Thu 18 Jun 2015, 09:44    Post subject:  

Version 1.10.5 - huge rewrite by step

See first post for details.

Greetings!

_________________
[O]bdurate [R]ules [D]estroy [E]nthusiastic [R]ebels => [C]reative [H]umans [A]lways [O]pen [S]ource
Omnia mea mecum porto.
Back to top
View user's profile Send private message 
step

Joined: 04 May 2012
Posts: 1352

PostPosted: Thu 25 Jun 2015, 04:34    Post subject: call for translators  

I would like to enthusiastically draw translators' attention to the .pot file on github http://github.com/step-/find-n-run

usr/share/doc/nls/findnrun/findnrun.pot

awaiting for your translator's pen. Thanks in advance for sending in your .po file, preferably as a github pull request, or otherwise as an attachment to this thread. I will file your contributed .po's in the project repository on github.

edit: 2015-07-15 update file path

_________________
Fatdog64-810|+Packages|Kodi|gtkmenuplus

Last edited by step on Wed 15 Jul 2015, 04:50; edited 1 time in total
Back to top
View user's profile Send private message 
Display posts from previous:   Sort by:   
Page 5 of 7 [104 Posts]   Goto page: Previous 1, 2, 3, 4, 5, 6, 7 Next
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies. View previous topic :: View next topic
 Forum index » Advanced Topics » Additional Software (PETs, n' stuff) » Filesystem
Jump to:  

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group
[ Time: 0.2180s ][ Queries: 12 (0.0569s) ][ GZIP on ]