[SOLVED] Triggering pamac-manager from website

I will create a website where I will recommend Manjaro applications and I thought would be cool to have an "install" button for each application that once clicked to trigger/search the package/application on pamac-manager :stuck_out_tongue: - I simply wanted to ask if this is even possible?

I know Ubuntu store (the old one) had such a feature for their online store.

opensuse has it

I guess it is possible but not (?) easy. You have to create/register/use some custom protocol (url scheme) handler. Something like mailto:// which opens email client. Make up alpmpackage:// or so and attach it to run pamac-installer. Sorry, I don’t know how to implement that.

EDIT. Maybe you can get some inspiration from others who made their custom handlers like this

1 Like

Oh nvm. Just links to download and their own package installed for doing funny things.
(but bodhis entire app management was browser-based)

Thanks. Would be great if pacman-manager had an API or some documentation that can be used for this. Actually maybe they have but I would not know where to start…maybe I will submit a feature request for it on gitlab

Submitted here https://gitlab.manjaro.org/applications/pamac/issues/564 - but if anyone in the forum can help would be great :slight_smile:

1 Like

Note that because this is a rolling distro, you should not be installing or updating packages piecemeal if the rest of your system has not been fully upgraded or isn’t being updated at the same time.

This browser facility might lead to issues if users don’t make sure everything else is updated when they make use of it, because they are still treating Manjaro like a fixed release distro.

If this causes problems with their system as a result, it’ll cause more work on this forum.

2 Likes

But I am talking about triggering pamac-manager with the package open, and so people can click apply to install, which triggers the entire system update as well. It is like replacing the search and find application with a simple click.

1 Like

No special API is required. All can be done with a small script and a desktop file. I messed up with this idea, looked at some URL handlers form AUR and got these two files:
pamac-url-handler.desktop

[Desktop Entry]
Version=1.0
Type=Application
Name=ALPM package URL Handler
Comment=Install ALPM packages with pamac-installer from URL scheme x-alpm-package://packagename
Icon=system-software-install
NoDisplay=true
Categories=System;
Exec=pamac-url-handler %u
Terminal=false
MimeType=x-scheme-handler/x-alpm-package;
X-Desktop-File-Install-Version=0.1

And pamac-url-handler

#!/usr/bin/env bash

# ALPM package URL handler
# x-alpm-package://packagename

packagename="${1#x-alpm-package://}"
pamac-installer "$packagename"

Make the script executable and place somewhere in the PATH. Install .desktop file with desktop-file-install or place it where other .desktop files are. If you want automated installation, write some PKGBUILD and build the package (I haven’t write it).

With these two files I can click a link like this:

<a href="x-alpm-package://mc">Install mc</a>

and it opens dialog window and after confirmation and password prompt installs mc package. (This forum seems to block unusual hyperlinks, so it won’t work right here.)

P.S. Although this idea of installing packages by one click on a web page is quite easy to implement, its use can cause problems, especially if a user does not keep the system up to date, as have been pointed out. In rolling release distribution model fully automated package installation or system update is not a good practice. Sometimes manual user intervention is critical to keep the system in working condition.

2 Likes

If memory serves, pamac nowadays does automatically a system update if you install something to prevent partial updates. If this is correct (memory does not serve often), then pamac is a great option for this kind of website, because it avoids this precise problem you mentioned.

3 Likes

I am so interested in this!

Ok, so hold on a bit because I am not that knowledgeable when it comes to this.

I have created the desktop file " pamac-url-handler.desktop" and put it into .local/share/applications. I have also created a bash script file " pamac-url-handler" and made it executable and I am unsure where to put it. I am more than willing to learn how to do this :smiley:

You probably want to put it in /usr/bin
[tip to find out your current PATH you can echo $PATH]

1 Like

Thank you! Actually I thought that would be the “path” and I put it there now.

[tio@tio-pc ~]$ echo $PATH
/usr/local/bin:/usr/local/sbin:/usr/bin:/usr/lib/jvm/default/bin:/usr/bin/site_perl:/usr/bin/vendor_perl:/usr/bin/core_perl:/var/lib/snapd/snap/bin

So, put the bash in usr/bin, and testing with a url

nothing happens it sends me to x-alpm-package://mc like it would do for any url. Testing in Firefox.

no … put it in /usr/bin
[ your path explicitly seems to omit /bin ]

Oh yes that’s what I meant :stuck_out_tongue: - usr/bin

This is the Firefox error I get:

The address wasn’t understood


Firefox doesn’t know how to open this address, because one of the following protocols (x-alpm-package) isn’t associated with any program or is not allowed in this context.

    You might need to install other software to open this address.

I have tried it from Libreoffice and from Chromium (ungoogled one). Maybe some update/rescan of .desktop files or mime is needed.

EDIT. Maybe update-desktop-database or sudo update-desktop-database.

EDIT 2. Doesn’t work with Firefox on my end too. Maybe some default settings are different in Firefox. This approach assumes that it should open these links with xdg-open.

So it is working for you if you click such a link in Chromium? I tried and does not at all. I " sudo update-desktop-database" and nothing.

I am already working on the website design :stuck_out_tongue: - but it will take a while to release this website. So I am really interested if I can implement this into the website. Let me know please what I should do because I cannot make it work via the link.

1 Like

That’s something I didn’t know, so thanks for the update in my knowledge!

Check from terminal if this works:
xdg-open x-alpm-package://mc

Forum kindly sponsored by Bytemark