Forum › Forums › antiX-development › Development › GUI to add quick launcher icons to JWM toolbar
- This topic has 8 replies, 5 voices, and was last updated May 3-9:59 am by PPC.
-
AuthorPosts
-
May 1, 2023 at 1:53 pm #105743Member
PPC
I seem to recall, a while ago that me and anticapitalista tried to come up to a GUI to manage JWM toolbar icons, similar to the one that was created for IceWM.
This is my first try, a simple GUI that uses app-select to do the heavy lifting.
Please test.
If no bug is found, it could be a nice addition to antiX 23… For noe, the only GUI is app-select, so there is nothing to localize- select the app you want to add, and it pops up in your jwm toolbar (no check is performed to see if you are using jwm, this is a proof of concept only).#!/bin/bash ####GUI script to add quicklauncher to IceWM toolbar, by PPC, GPL licence #Use app-select to select the app (go figure :-) ) selected=$(app-select --select) #If a selection was not done, exit if [ -z "$selected" ]; then exit fi executable=$(echo $selected| cut -d '|' -f 5) name=$(echo echo $selected| cut -d '|' -f 2| tail -1) icon=$(echo echo $selected| cut -d '|' -f 8) # To add icon to icewm's toolbar (new icons are added to the right side of any existing quick launchers # echo prog \"$name\" $icon $executable >> ~/.icewm/toolbar #For this to work in jwm, echo the text after the line that shows the menu (it contains the expression "root:1") #new icons are added to the right of the menu (om the left side of any existing quick launchers) sed -i "/root:1/a <TrayButton label=\"\" icon=\"$icon\" popup=\"$name\">exec: $executable</TrayButton> " ~/.jwm/tray #restart jwm to see changes jwm -restartP.
- This topic was modified 1 day, 22 hours ago by PPC.
May 1, 2023 at 3:06 pm #105754Member
Wallon
::Dear PPC,
Thank you for this great idea.
I am not the only one working on antiX today.
As you can see on my screenshot, I have added 4 programs to my taskbar.
1) I notice that you always put a new program on line 8 of the file. I hope you do a search on “TrayButton” plus 1 line to place the new program. If it is on a fixed line, it may not work if the file has been customised.
2) In app-select, it is not possible to put words on the buttons. For example “To confirm” and “To cancel”?
3) In my fifth test, I clicked on the abandon button in app-select. This added a line to my “tray” file. You should put a condition in your file. If the user gives up, exit the program without doing anything.
This little file will already help me a lot because I don’t have time to customize my taskbar anymore.
Kind regards,
WallonAttachments:
May 1, 2023 at 3:39 pm #105758MemberPPC
::DEar Wallon, thanks for testing the script:
On your notes:
1- The line corresponding to the new quick launcher icon is placed on the line right after the one that has the menu (it has the contents “root:1”, that the script searches for.
2- no, I can’t change app-select
3- the script has a safe guard, that should exit if nothing was chosen. Iĺl have to create a better one, when I have the timaP.
May 1, 2023 at 5:13 pm #105766MemberRJP
::It works but script dies after launcher is added. Just to add a function which keeps script alive.
May 1, 2023 at 5:19 pm #105767Member
Wallon
::Dear RJP,
This is the beginning of the programme.
Our PPC expert didn’t have time to do the loop to restart the program.
This is already a very good start.Best regards,
WallonMay 1, 2023 at 5:33 pm #105768Member
marcelocripe
::Hello PPC.
I managed to test your newest program on antiX 22 full 64bit.
The line <TrayButton label=”Menu “>root:1</TrayButton> was created in the “tray” file in the /home/demo/.jwm/ folder right after I closed “AppSelect” without adding any icons. Even after I removed this line, the program failed to add the shortcut icons to the JWM toolbar.
Unfortunately, I couldn’t see the icons being added to the zzz-JWM desktop.
I managed to change our “icewm-toolbar-icon-manager.desktop” file to create a new “jwm-toolbar-icon-manager.desktop”. Since I just changed the text “IceWM” to “JWM”, the non-Latin languages will need to be proofread by the native speakers of the respective languages. In addition to a review of the comment texts, as it should be compatible with the functionality of your new program.
I leave my suggestion for all the texts of the “.desktop” files that are exclusive for use in IceWM to have the information “IceWM” in the “Name” entry and the same suggestion for all the texts of the “.desktop” files that are exclusive for use in JWM. This way, it will be written and explicitly for which desktop environment the menu serves.
The attached file has your “jwm-toolbar-icon-manager” program, “jwm-toolbar-icon-manager.desktop”, two images of the menu and one of the attempts to add a shortcut icon and a text file with the commands I used in the tests.
Thank you for working on this new program for JWM.
– – – – –
Olá PPC.
Eu consegui testar o seu mais novo programa no antiX 22 full de 64 bits.
A linha <TrayButton label=” Menu “>root:1</TrayButton> foi criada no arquivo “tray” da pasta /home/demo/.jwm/ logo após eu fechar o “AppSelect” sem eu ter adicionado nenhum ícone. Mesmo após eu remover esta linha, o programa não conseguiu adicionar os ícones de atalho na barra de ferramentas do JWM.
Infelizmente, eu não consegui ver os ícones sendo adicionados na área de trabalho zzz-JWM.
Eu consegui alterar o nosso arquivo “icewm-toolbar-icon-manager.desktop” para criar um novo “jwm-toolbar-icon-manager.desktop”. Como eu apenas alterei o texto “IceWM” por “JWM”, os idiomas não latinos precisarão ser revisados pelos nativos dos respectivos idiomas. Além de uma revisão dos textos dos comentários, pois deverá ser compatível com a funcionalidade do seu novo programa.
Deixo a minha sugestão para todos os textos dos arquivos “.desktop” que forem exclusivos para o uso no IceWM possuirem a informação “IceWM” na entrada “Name” e a mesma sugestão para todos os textos dos arquivos “.desktop” que forem exclusivos para o uso no JWM. Desta forma, ficará escrito e de forma explícita para qual ambiente de área de trabalho o menu serve.
O arquivo anexo possui o seu programa “jwm-toolbar-icon-manager”, o “jwm-toolbar-icon-manager.desktop”, duas imagens do menu e de uma das tentativas de adicionar um ícone de atalho e um arquivo de texto com os comandos que eu utilizei nos testes.
Obrigado por trabalhar neste novo programa para o JWM.
Attachments:
May 1, 2023 at 7:51 pm #105780MemberPPC
::Newer version, with checks for jwm and for selection:
#!/bin/bash ####GUI script to add quicklauncher to IceWM toolbar, by PPC, GPL licence ###Check if the current desktop is JWM, if not, exit desktop=$(wmctrl -m) [[ $desktop != *"JWM"* ]]&& exit #Use app-select to select the app (go figure :-) ) selected=$(app-select --select) #If a selection was not done, exit [[ $selected != *".desktop"* ]] && exit executable=$(echo $selected| cut -d '|' -f 5) name=$(echo echo $selected| cut -d '|' -f 2| tail -1) icon=$(echo echo $selected| cut -d '|' -f 8) # To add icon to icewm's toolbar (new icons are added to the right side of any existing quick launchers # echo prog \"$name\" $icon $executable >> ~/.icewm/toolbar #For this to work in jwm, echo the text after the line that shows the menu (it contains the expression "root:1") #new icons are added to the right of the menu (om the left side of any existing quick launchers) sed -i "/root:1/a <TrayButton label=\"\" icon=\"$icon\" popup=\"$name\">exec: $executable</TrayButton> " ~/.jwm/tray #restart jwm to see changes jwm -restartMay 1, 2023 at 9:53 pm #105788Forum Admin
Dave
::@PPC
Looks good! A few suggestions to perhaps take into consideration for future additions.
1) desktop= variable. Perhaps write as
desktop=${DESKTOP_SESSION_WM:=$(wmctrl command here)}
As this will check if the window manager environment variable is set by desktop-session and use it. Otherwise it will fall back to the wmctrl command.2) for selected= variable. Perhaps check if there are command line arguments to the script
if [ ! -z "$@" ]; then selected="$@" else: selected=$(app-select --select) fiThis way this script can be made into a context menu plugin for app-select as well. So you could start app-select, select an app and open the context menu (or right click) and press a “send to toolbar” option.
3) for the sed and restart lines; consider placing them in a case statement that checks against the desktop variable. In this way you could use the same script for all window managers.
case "$desktop" in jwm) #For this to work in jwm, echo the text after the line that shows the menu (it contains the expression "root:1") #new icons are added to the right of the menu (om the left side of any existing quick launchers) sed -i "/root:1/a <TrayButton label=\"\" icon=\"$icon\" popup=\"$name\">exec: $executable</TrayButton> " ~/.jwm/tray #restart jwm to see changes jwm -restart ;; icewm) icewm sed line here icewm restart line here ;; fluxbox) fluxbox sed line here fluxbox restart line here ;; openbox) openbox sed line here openbox restart line here ;; *) echo "No window manager found" exit 1; ;; esacalternatively if you know desktop-session is in use you could use the “desktop-session-exit -R” command to restart the window manager / session. (Note the capital -R as lowercase will reboot the computer 😉 ) This would be placed after the case statement instead of individual restart commands.
There was another suggestion I had thought of but forgot while writing the above. Will update the post if it comes back into memory.
edit: Remembered.
Consider placing the written line in a variable called “line=” and reference this in the sed command as
sed -i "/root:1/a $line " ~/.jwm/tray
This way you can also have a grep check to avoid duplicates and unwillingly filling the tray file.line="<TrayButton label=\"\" icon=\"$icon\" popup=\"$name\">exec: $executable</TrayButton>" if ! grep -q "$line" ~/.jwm/tray; then sed -i "/root:1/a $line " ~/.jwm/tray fi- This reply was modified 1 day, 14 hours ago by Dave.
Computers are like air conditioners. They work fine until you start opening Windows. ~Author Unknown
May 3, 2023 at 9:59 am #105873MemberPPC
::@Dave
Many thanks for your suggestions – I don’t currently have time (or the focus) to redo the script, this week.
Please, if you can, feel free to adapt it as needed:
– I loved the idea of using it from app-select as a all-in-one “send to toolbar tool”- I’ve suggested such used to app-select over the time, and it would be a nice “extension” or “add-on” for app-select.Notes: I think this script can only work on Icewm (using the commented line of code) and JWM, because Fluxbox does not allow adding toolbar quick-launchers (it’s the reason I stopped using a pure Fluxbox and created FT10), an I also think Openbox (probably the most used stand-alone Floating Window Manager) does not come, out of the box, with a toolbar hence many people use it with tint2)
Notes on adding a script to delete toolbar entries; it’s doable, but harder than in Icewm- because the config file stores entries that are quick-launchers (next to the menu) but also next to the clock (the single feature I think JWM has that I miss in IceWM). Adapting the logic of IceWM’s Toolbar Icon Manager to process the list of entries on JWM’s config file is doable, but, like I said, I don’t have the time or the headspace for it now- I should try to help out iron some of antiX23 beta’s problems, when I have the time- this script came out of an idea I had, scribbled on a file, that ironed out on a few minutes, and published here, because I think JWM users miss that feature (although I don’t use that window manager).
P.
-
AuthorPosts
- You must be logged in to reply to this topic.
