I find apt
in terminal as the best way to install a program from a deb package. As I prefer it to other gui tools, I want that in the context menu for deb files or as a launcher among applications in order to install the deb by executing it with (double) click.
In Kubuntu with Dolphin I have created a service menu to create that context menu, also a desktop file in ~/.local/share/applications
to achieve the same action by executing the deb file.
The file ~/.local/share/kservices5/ServiceMenus/install-deb.desktop
:
[Desktop Entry]
Actions=install
Icon=dialog-information
MimeType=application/vnd.debian.binary-package
ServiceTypes=KonqPopupMenu/Plugin
Type=Service
X-KDE-Priority=TopLevel
[Desktop Action install]
Exec=konsole --hold -e sudo apt install %f
Icon=dialog-information
Name=Install
The file ~/.local/share/applications/install_deb_term.desktop
:
[Desktop Entry]
Name=Install in terminal with apt
Comment=Install deb files in terminal with apt
Exec=konsole --hold -e sudo apt install %f
Icon=gdebi
Terminal=false
Type=Application
StartupNotify=true
Categories=GNOME;GTK;Settings;HardwareSettings;X-GNOME-Settings-Panel;System;
All is well, excepting the fact that without the --hold
argument in konsole
the terminal closes to quickly (which is not good in case of error), while with that argument the terminal stays open with a rather inconclusive message like so:
Setting up <whatever_program> ...
which is not what I expect if the installation went fine.
Can I get some "OK" message at the end of the installation process with apt
? Maybe through a script containing the apt
command?
Update:
Following comments by @DKBose: modifying ~/.bashrc
as in this answer I get the desired notification popup with a command in terminal like
sudo apt install /path/to/deb; alert
but not with the line
Exec=konsole --hold -e sudo apt install %f; alert
in the files above (installation works, but no popup).
For the alert
argument to work at all, installation of libnotify-bin
was needed.
Best Answer
This answer addresses the issue of installing a .deb file using
apt install
via a service menu in Kubuntu 18.04.First, we download a small .deb,
gcolor2
which is not in the bionic repos, using the link provided by N0rbert here.Next, based on the service menu .desktop file in the question and comments by muru, the following service menu .desktop file,
~/.local/share/kservices5/ServiceMenus/install-deb.desktop
was constructed:From now on, if one right-clicks on a .deb file in Dolphin, the context menu offers "install-deb" as one of the options. Selecting "install-deb" will open up
konsole
and runsudo apt install %f
, where%f
in this case, refers to thegcolor
.deb downloaded viawget
.This is what konsole's output looks like:
Once the install is complete,
konsole
will have "Finished" in its titlebar but will remain open until it is closed via the window manager. Additionally, because of thenotify-send
bit, a notification will be visible for the number of milliseconds specified. (I don't know why but--urgency=critical
doesn't make the notification persist.)kdialog --passivepopup "whatever text string"
seems better suited for this purpose thannotify-send
.