Kubuntu 21.04 - How to close terminal automatically after bash is done?
UbuntuThis forum is for the discussion of Ubuntu Linux.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
When a script is called in a terminal window, and the script exits, the terminal should(tm) close.
If it doesn't it might be something in the emulator software's settings preventing that.
If indeed your script does not exit, then we need to look at the script.
I'm talking about some youtube-dl scripts, where for example, I tried to toggle two target folders, previously selected in youtube-dl.conf, located in ~/.config .
I created two files called youtube-dl.conf and youtube-dl2.conf .
The 1st one looks like this:
As I said before, none of the exit commands I found was working. The kill command was in fact the last chance for me to get the terminal closed.
But it is not only related to my youtube-dl scripts, after none of the bashes the terminal is closed when they are done.
As I said before:
Quote:
Originally Posted by ondoho
When a script is called in a terminal window, and the script exits, the terminal should(tm) close.
If it doesn't it might be something in the emulator software's settings preventing that.
The 'kill -9 $PPID' in your script is a horrible kludge. Your real problem is elsewhere, and I suspect your terminal is somehow set to stay open after the calling script is done.
Try installing a different terminal emulator and see if the problem persists when you use it to run your scripts.
The 'kill -9 $PPID' in your script is a horrible kludge.
I absolutely agree, but I didn't find any other solution so far.
Quote:
Originally Posted by ondoho
Your real problem is elsewhere, and I suspect your terminal is somehow set to stay open after the calling script is done.
Try installing a different terminal emulator and see if the problem persists when you use it to run your scripts.
Anything you can recomend there, by any chance?
I didn't do anything with the ordinary Kubuntu terminal, but to add a bit transparency and to add neofetch, but neofetch should be done way before the bash even begins, shouldn't it?
The biggest problem is that I'm no programmer. That's why I google for pieces of code and put them together until I get something that's somehow doing what I want.
and the exit in your script will [most probably] close your terminal. If not you need to explain your situation better.
That's exactly what's happening, and OP already specified it happens with all scripts.
My suspicion: konsole (?) is somehow set up to stay open after execution, similar to xterm's '-hold' option.
But I do not use konsole so cannot advise more than to look through its preferences.
Apparently that's too complicated for OP because they're "not a programmer" - well, neither am I.
OP; one more idea:
How exactly are you launching all these scripts? Not from a command line I presume?
How exactly are you launching all these scripts? Not from a command line I presume?
They answered that in the other thread...
(Snugbug: next time subjects collide, answer relevant questions in the correct thread, and post a link in the other thread.)
Quote:
Originally Posted by Snugbug
Usually, when I double click a bash for example in Mint, I'm asked if I want to execute this bash or to show its content. Then I can choose between "Run in terminal", "Show", "Cancel" and "Run". This is almost the same with all the distros I know so far.
But in Kubuntu, I have to start a bash with a right click and select "Run in terminal". Then, the terminal doesn't close automatically in the end, anymore.
Otherwise, I mean by double clicking, I get only the content of the bash, being shown in Kate.
Anyway, the issue is not that exit/Bash doesn't work, it is (as suspected) the way Konsole is being called.
On my Debian+KDE, Dolphin doesn't have a "Run in terminal" option but it does have a "Run in Konsole", under "Actions". (I've no idea if Kubuntu is different or if Snugbug typed the wrong thing.)
It is provided by "/usr/share/kservices5/ServiceMenus/konsolerun.desktop", which starts:
I have Kubuntu 20.04 which provides Dolphin 19.12.3.
Settings > Configure Dolphin > Confirmations > When opening an executable file shows three options:
Always ask
Open in application
Run script
I have "Run script" set. (You can, as a cautionary measure, go with "Always ask" and then choose "Execute".)
Here's a test script, touch.sh, which I made executable. Its contents:
Code:
#!/bin/bash
touch $(date "+%Y%m%d%H%M%S").txt
When I'm in Dolphin and in the folder containing touch.sh, if I double-click (or single click depending on how you have your system set) touch.sh, the script runs and a time-stamped file is created in the folder. Konsole is not involved. No terminal opens or needs to be closed.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.