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.
apt install ... && echo OK
? – muru Dec 11 '18 at 13:33qapt-deb-installer
. – Dec 11 '18 at 13:39Exec=konsole --hold -e sudo apt install %f && echo OK
I get no ok message in terminal (tested by successfully installing Opera: in that case the last line isProcessing triggers for libc-bin (2.27-3ubuntu1) ...
.) But maybe in a script. – Dec 11 '18 at 13:43~/.bashrc
as in this answer I get the desired notification popup with a command in terminal likesudo apt install /path/to/deb; alert
, but not with the lineExec=konsole --hold -e sudo apt install %f; alert
in the files above (installation works, but no popup). I will add that to question. – Dec 12 '18 at 12:23echo $?
can be used at the end of a command, which gives0
for ok. But it's the same as withalert
: works when typed in terminal, but not with the terminal launched from the desktop file. – Jan 13 '19 at 17:02alert
feature in~/.bashrc
but the other aspect, involving the service menu route, is still very much open according to the last comment by user47206. And I don't have an answer for that second aspect. – DK Bose May 27 '20 at 09:27Exec
lines aren't really parsed like shell lines, so the; alert
probably should have beenkonsole --hold -e bash -c 'apt install "$@"; alert' _ %f
. – muru May 27 '20 at 09:46Exec=konsole --hold -e bash -c 'sudo apt install %f; alert' _ %f
withsudo
added and with%f
because KDE service menus use %f (obtained when a file is clicked in Dolphin). The installation is fine, but no alert, instead, the terminal shows_: alert: command not found
. – DK Bose May 27 '20 at 10:54alert
is an alias in bashrc, so changingbash -c
tobash -ic
should fix that – muru May 27 '20 at 10:58Exec=konsole --hold -e bash -ic 'sudo apt install %f; alert' _ %f
, installation is fine, no alert, but now the last line isNo summary specified.
– DK Bose May 27 '20 at 11:02