Forum › Forums › antiX-development › Development › Separate thread for Preferred Applications (desktop-defaults-set) enhancement
- This topic has 35 replies, 5 voices, and was last updated Sep 1-6:02 pm by marcelocripe.
-
AuthorPosts
-
August 21, 2022 at 7:56 pm #87556Moderator
BobC
::If anyone can add a column on the right with the program name efficiently translated to local language, please do so or show/tell me how?
August 22, 2022 at 3:34 am #87575ModeratorBobC
::Maybe the translated program name isn’t needed?
I don’t know the logic needed to translate it, or display it in another column. I was looking at the menu manager, but can’t tell if it shows English or translated application names.
On older machines, translating the name would probably make the program slow.
To just get the name, in each desktop file I would need to find the first
^Name=pt_BR
if none, then find first
^Name=pt
if none, then find first
^Name=
To speed it up, I would need to do that only for the ones I was going to displayTo have multiple columns of fields, presents additional problems as I think with would need to be done with arrays, and I haven’t ever used those.
- This reply was modified 8 months, 3 weeks ago by BobC.
- This reply was modified 8 months, 3 weeks ago by BobC.
August 22, 2022 at 2:49 pm #87587Member
marcelocripe
::Thanks for creating this topic “desktop-defaults-set” and for separating this topic from the other topic “antiX-22 being worked on”.
If anyone can add a column on the right with the program name efficiently translated to local language, please do so or show/tell me how?
BobC, PPC applied the display of the text contained in the input “Name[pt_BR]”, “Name[fr_BE]”, “Name[pt]”, etc in the program “icewm-toolbar-icon-manager”. Robin guided in this topic “Important information for script developers concerning the language identifiers” on how to use this programming logic.
^Name=pt_BR
if none, then find first
^Name=pt
if none, then find first
^Name=
To speed it up, I would need to do that only for the ones I was going to displayThis is perfect logic in choosing the text to be displayed. But Robin’s instructions highlight the importance of not only looking at 2-letter or 4-letter identifier languages, but to be independent of the number of characters.
I downloaded the “desktop-defaults-set-20220821.zip”, today I will be able to help test and I will try to create the .pot file.
Thanks.
– – – – –
Eu agradeço por criarem este tópico “desktop-defaults-set” e por separarem este assunto do outro tópico “antiX-22 being worked on”.
If anyone can add a column on the right with the program name efficiently translated to local language, please do so or show/tell me how?
BobC, o PPC aplicou a exibição do texto contido na entrada “Name[pt_BR]”, “Name[fr_BE]”, “Name[pt]”, etc no programa “icewm-toolbar-icon-manager”. O Robin orientou neste tópico “Important information for script developers concerning the language identifiers” sobre como utilizar esta lógica de programação.
^Name=pt_BR
if none, then find first
^Name=pt
if none, then find first
^Name=
To speed it up, I would need to do that only for the ones I was going to displayEsta é lógica perfeita na escolha do texto a ser exibido. Mas as instruções do Robin destacam a importância de não olhar apenas para os idiomas de identificadores de 2 ou 4 letras, mas para ser independente da quantidade da caracteres.
Eu baixei o “desktop-defaults-set-20220821.zip”, hoje eu poderei ajudar a testar e tentarei criar o arquivo .pot.
Obrigado.
August 22, 2022 at 8:27 pm #87602ModeratorBobC
August 25, 2022 at 7:03 am #87666ModeratorBobC
::Marcelo,
I’m sorry. I spent a lot of time trying, and I was able to translate the name, but not able to merge and display both fields, separate them again and update from that. Its just beyond my ability. I don’t really know the language very well, and try to figure things out, but don’t pretend to be an expert with it. Its disheartening when this happens.
Maybe someone more capable will pick it up and add that enhancement.
August 25, 2022 at 1:22 pm #87679Member
marcelocripe
::I’m sorry.
BobC, I’m sorry for not knowing how to program so I can help you. Unfortunately, I can only give suggestions, do tests and help with translations.
I spent a lot of time trying, and I was able to translate the name, but not able to merge and display both fields, separate them again and update from that. Its just beyond my ability.
I don’t know how PPC did to display the input texts “Name” or “Name[xx]” or “Name[xx_YY]” in “icewm-toolbar-icon-manager”. Is it possible to copy this part of the code from “icewm-toolbar-icon-manager” to “desktop-defaults-set”?
Even if it is not possible to achieve the maximum goal, the “desktop-defaults-set-20220821.zip” version that you have greatly improved the programming code, already decreases the chances of a user choosing a .desktop file in a category of the which the app doesn’t belong, which in my view is a very important improvement. Furthermore, the .pot and .po (pt_BR) file of the “desktop-defaults-set-20220821.zip” version are ready and working successfully. If there are no other improvements made by you or others, if the anti-capitalist wants he can use the .pot file on the official Transifex. I still don’t know how, but it should be possible to change the .pot file without losing the translations that are ready, because what has changed are the line numbers and the references of the texts to be translated, since the texts are the same.
Thank you for taking the time to improve the “desktop-defaults-set” program.
– – – – –
I’m sorry.
BobC, sou que sinto muito por não saber programar para poder te ajudar. Infelizmente, eu só posso dar sugestões, fazer testes e ajudar com as traduções.
I spent a lot of time trying, and I was able to translate the name, but not able to merge and display both fields, separate them again and update from that. Its just beyond my ability.
Eu não sei como o PPC fez para exibir os textos da entrada “Name” ou “Name[xx]” ou “Name[xx_YY]” no “icewm-toolbar-icon-manager”. Será que é possível copiar esta parte do código do “icewm-toolbar-icon-manager” para o “desktop-defaults-set”?
Mesmo se não for possível conseguir atingir o objetivo máximo, a versão “desktop-defaults-set-20220821.zip” que você melhorou e muito o código de programação, já diminui as chances de um usuário escolher um arquivo .desktop em uma categoria da qual o aplicativo não pertence, o que ao meu ver é uma melhoria muito importante. Além do mais, o arquivo .pot e o .po (pt_BR) da versão “desktop-defaults-set-20220821.zip” estão prontos e funcionam com sucesso. Se não houver outras melhorias feitas por você ou por outras pessoas, se o anticapitalista quiser poderá utilizar o arquivo .pot no Transifex oficial. Eu ainda não sei como, mas deve ser possível alterar o arquivo .pot sem perder as traduções que estão prontas, pois o que mudou foram os números das linhas e as referências dos textos as serem traduzidos, já os textos são os mesmos.
Eu agradeço por você dedicar o seu tempo na melhoria do programa “desktop-defaults-set”.
August 25, 2022 at 2:10 pm #87681ModeratorBobC
::There is a 2 column list for each field, I think, but all the lists come back in one field. I didn’t understand how it should work.
It is more complex than the toolbar icon script.
August 25, 2022 at 2:46 pm #87682MemberPPC
::Hi Bob
I’ve been on vacation with my daughter, so I haven’t much time. 2 ideas:1- add the (current) name of the application not as as new column but as a text, right next to the general description of the program (ex: “video player- currently mplayer”)
2- using a menu to select the (localized) name of the application, instead of showing the .desktop file is a bit complex, but you can see my highly commented TIM script. What is does is this- ut searchs for all .desktop files, then creates a list with the (localized) application name and other needed info (ex: executable file, icon, description, etc).
In your case this is a bit simpler and faster, because the script does not need to list and examine all available desktop files, but only those that fit the needed criteria. You need to list only one field (the “name[lang_code]” one, and the .desktop file it self). Please checkout /usr/local/bin/icewm-toolbar-icon-manager.shThe relevant lines are 19-62….
I’ll try to help you more during the weekend, if I can.PS: the “text editor” field does not list geany, it would probably be better to add it manually to the text editor list, created by your script…
P.
- This reply was modified 8 months, 2 weeks ago by PPC.
August 25, 2022 at 2:58 pm #87684ModeratorBobC
::PPC,
I did get as far as translating a name and including the translated name on the output, but was not able to read or process the results correctly, because one field affects all the others. I then tried to add it to all of the fields and broke the program completely trying. I maybe just didn’t understand the right way to do things for YAD. The code got very difficult because of all the different fields, links and files.
August 26, 2022 at 3:14 am #87712ModeratorBobC
::I now have it to where it will display both the name and filename. On my system, I have the code in to translate it, but it doesn’t actually translate because I don’t have it set for a different language, but I set it for fr = French using PPC’s method, and that worked, see screenshots.
I had to turn off the ability to update the settings because I don’t understand what it returns from YAD or what to do with it. I am now trying to figure out what comes back from YAD and how to get the filename from it so I can create the links correctly. Currently that corrupts the files.
Attachments:
August 26, 2022 at 5:50 am #87714Member
iznit
::had to turn off the ability to update the settings because I don’t understand what it returns from YAD or what to do with it. I am now trying to figure out what comes back from YAD and how to get the filename from it so I can create the links correctly. Currently that corrupts the files.
tee command [has a manapage]
onto the end of your yad command statement, add
| tee > somefile.txt
and you can capture to a textfile what the verbatim output isor you can
myvariable=$( entirety of yad command statement here, to be executed in a subshell ) echo $myvariableExpect to see the output from yad is a string, formatted with pipe [bar] characters as delimiters between the individual field values. If for example a yad form contains 4 fields and the returned values are f1=harvey f2=[NULLempty] f3=42 f4=red, the output string will be harvey||42|red
Yes, bash arrays gonna be helpful here. Big powerup if you spend half hour or so reading how to create arrays and access elements.
good start
https://www.golinuxcloud.com/bash-split-string-into-array-linux/#Method_3_Bash_split_string_into_array_using_delimiter
https://tecadmin.net/working-with-array-bash-script/
and leftside on this next page give examples how to do common tasks
https://riptutorial.com/bash/example/1551/accessing-array-elementsAugust 26, 2022 at 7:03 am #87717ModeratorBobC
::Yes, neither used an array. Adding the 2nd column in the same field necessitated removing the name from the value before using it to process. I added a bunch of debug output so I could figure it out:
MakeLinks() { #echo "MakeLinks $1 app_info: $app_info" NameAppLine=$(echo $app_info |cut -d "|" -f"$1") token=${NameAppLine##* -- } # Remove the left part. #echo "token: $token" AppLine=$token #echo "AppLine: $AppLine" LinkFrom=$(echo $AppLine |cut -d "|" -f"$1") #echo "LinkFrom: $LinkFrom" LinkTo=$Desktop_Prefix"$2" #echo "LinkTo: $LinkTo" if [ -L "$LinkTo" ]; then #echo "running rm LinkTo: $LinkTo" rm $LinkTo fi echo "linking: ln -s $LinkFrom $LinkTo" ln -s $LinkFrom $LinkTo 2>/dev/null #echo "running UpdateMime $LinkFrom" UpdateMime $LinkFrom }But thanks for the help and links. I can see where an array makes good sense.
My big problem was not looking closely at what YAD returned vs what I asked it to set. Then I could see I wasn’t handling it correctly to result in the selected filename. Once I had my debugs printing the right values, it worked.
Attachments:
August 26, 2022 at 10:12 pm #87755MemberPPC
::@BobC
I tried out the latest script:
1- The really good point is that the menu worked great, showing (in English) the application name + the desktop file name
2- For some reason it created the default .desktop files in the same folder as the script was and zeroed out the default selection (I had to use the default antiX script to re-select them all).August 27, 2022 at 5:44 am #87756ModeratorBobC
::PPC, I looked on my drive. I’ve been running it from the same folder for a week, both standard version and my different versions over that 2 week period. I did find a set of links, but from 5 days ago. My explanation was that I was having terrible troubles with the YAD results when I first tried to add the name column about 5 days ago.
I think the cause is from the MakeLinks subroutine, where somewhere in the process, $app_info (from YAD), $NameAppLine, $token, or $LinkFrom, which were all derived from it, gets an incorrect value and results in $LinkFrom being created in the current folder.
I see Marcelo had the same issue as well, so its not just you. I think they should have been created in the $HOME/.local/share/desktop-defaults folder.
I wish it had happened on mine recently. I guess I need to test it logging to a file on a stock system and try to catch it making a mistake.
August 27, 2022 at 6:56 pm #87764ModeratorBobC
::OOPS! Cancel was being ignored. Bug fixed. I decided a good way to provide a few details if run in a terminal was just to output the code and values that were actually executing at critical points, like when you exit after cancelling, or when a link is being removed or created. Since it is bash syntax, I think no translation should be needed, thus not adding to translation work, but still proving execution clues when wanted.
Attachments:
-
AuthorPosts
- You must be logged in to reply to this topic.
