Using Konsole, how to open a folder in Dolphin, then, automatically, Konsole returns to its command line?

ok, wow - I don’t understand why you’d use KDE and have Dolphin as a flatpak - sorry; missed that part.

The following script will open my Konsole, run the command, and if I don’t ‘hold’ it open, the konsole closes when done with a slight 10 sec delay whilst also launching Marktext.

#!/bin/bash

commands() {

    date +"It's now %R" | cowthink
    echo "How's it going?"
    read HOW && sleep 3
    echo 'Youre' $HOW ' - and Im' $HOW | cowsay
    sleep 2
    clear
    cowsay 'Goodbye then!'
flatpak run com.github.marktext.marktext
}

export -f commands

konsole -e "bash -c 'commands'"
sleep 10

Why make life so complicated?

konsole -e /bin/bash -c 'flatpak run org.kde.dolphin & exec /usr/bin/zsh'

How’s that one?

1 Like

@ben2talk I enjoyed your humour in this shebang script. LOL :slight_smile: Unfortunately, this flies 37,000 feet above my present skills. For information, I’m a Dolphin and Konsole end-user. Not a software engineer.


konsole -e /bin/bash -c 'flatpak run org.kde.dolphin & exec /usr/bin/zsh'

How’s that one?

I tried just now. This happened:

  1. Konsole succesfully opens
  2. Konsole displays this:

    kf.config.core: Watching absolute paths is not supported “/usr/share/color-schemes/BreezeDark.colors”

  3. Dolphin does not open
  4. End

I’m assuming that you meant this in my case:

#!/bin/bash
flatpak run org.kde.konsole -e /bin/bash -c 'flatpak run org.kde.dolphin & exec <ABSOLUTE PATH TO FOLDER>'

Reminder that the device I need this for is GNOME with Wayland, with both Dolphin and Konsole installed and used as Flatpak.

In other words, using:

Details about this in my original post above at https://discuss.kde.org/t/using-konsole-how-to-open-a-folder-in-dolphin-then-automatically-konsole-returns-to-its-command-line/28830#p-82055-steps-to-reproduce-2

If I execute konsole -e /bin/bash -c 'flatpak run org.kde.dolphin & exec /usr/bin/zsh' as is. It displays this error message:

bash: konsole : commande introuvable

Which translates to it can’t find the command konsole

Obviously not - but you’ll find everyone here uses KDE Plasma, so doing this stuff on a Gnome desktop is gonna be completely different.

I’m not sure that Konsole is the best fit for a Gnome environment, any more than Dolphin is.

On KDE

kstart dolphin <your directory>

Opens dolphin as a child of the desktop (and not of your console process, so closing the terminal window won’t close it).
Isn’t there a similar command for Gnome?

1 Like

I’ve checked your updated post but it does not include any new info on why the Konsole is needed.

However, it still has

Konsole either returns to its command prompt or Konsole automatically closes itself. Either way would be success for me

If “automatically closes” is a success, why open it in the first place and just run the script as a program?

1 Like

Maybe it doesn’t meet your security requirements, but I like Krusader.
Aside from the dual folder panes, which I often find helpful, it can provide you with a console window at the bottom of each pane that automatically changes directory in sync with the director selected for display in the pane above.
This would effective turn your use case on its head, i.e. accessing the command line from the GUI file manager instead of the other way around.

Aside from the dual folder panes, which I often find helpful, it can provide you with a console window at the bottom of each pane that automatically changes directory in sync with the director selected for display in the pane above.

Dolphin has been doing this for ages, too (ok, it’s a single terminal window, that tracks the folder in the active pane+tab… )

bit late to the party …

from what i have seen here (not dolphin running as flatpak), the cause of your trouble might be the way, dolphin runs konsole, which is:

/usr/bin/konsole --hold -e /some/path/to/my-bash-script.sh

doing the same on a command line, konsole will stay open with literally all scripts, even
with just an exit command init.

if you remove the ‘–hold’ part, konsole closes after running the script.

one approach … add something to the script, that figures the current konsole window (eventualy from process is) and send dbus command to it to close.

next approach: create a service menu on your own that that basicly does the same but without the --hold part (also known as --noclose)

i would go with the second, as it might add some flexibility to your needs.

2 Likes

Yup, you’re late - you didn’t notice that OP isn’t running Plasma, so all these apps are installed as Flatpaks on a Gnome desktop.

Yup, it’s weird.

i did. that’s why i mentioned this in my comment. in fact i was able to reproduce OPs observings with a regular kde neon install and a flatpak installation of dolphin and konsole in a current ubuntu (gnome) desktop.

anyhow . i’ve played around with my second and recommended approach and this is, what i came along and worked for me:

also here (but failes to install in flatpak variant)

2 Likes

Thanks @chartmann for solving this Scooby-Doo-Hold-Mystery :slight_smile:


one approach … add something to the script, that figures the current konsole window (eventualy from process is) and send dbus command to it to close.

next approach: create a service menu on your own that that basicly does the same but without the --hold part (also known as --noclose)

i would go with the second, as it might add some flexibility to your needs.

I noted both your suggested approach

Another benefit of the service menu approach is that an add-on could be published at https://store.kde.org/browse?cat=102&ord=latest
Then Dolphin users facing the same challenge could both use that add-on, and contribute to it if interested.

I’m an end-user though. Not a developer. If any developer is interested to contribute a new services menu to resolve this challenge, I would be happy to contribute both testing and documentation if needed.

Just now I searched the KDE store. Found this add-on at https://store.kde.org/p/2255893

I noticed that you recently created it. Thanks a bunch :slight_smile: :green_heart: I’ll happily try it and share my result here.

Your Run It Service Menus add-on successfully solved this challenge. Thanks @chartmann :slight_smile:

I added a 10/10 rating and a +1 fan at https://store.kde.org/p/2255893 My +1 fan is showing. But somehow the 10/10 rating is not recorded and not displayed. Maybe the KDE store needs time to display it, or maybe my new KDE store account is too recent, or maybe the Gremlins are chewing on the internet cables (joke :wink: ) I tried 3 times. With three different browsers.

For your review for interest and for your decision as maintainer of Run It, I’m contributing the screenshot above. I suggest adding it to https://store.kde.org/p/2255893 This screenshot might be useful for newcomers to KDE Dolphin Service Menus and Run It. I made this screenshot using KDE Dolphin 24.12.1. Feel free to adapt this screenshot to your liking.

Tested with this script

#!/bin/sh
flatpak run org.kde.dolphin --new-window "/<PATH>"

Both Konsole and Dolphin have the “Acquire arbitrary permissions” permission granted to their Flatpaks

using [Konsole and Dolphin] as Flatpaks in this situation - as far as I can tell - does not offer a security or privacy benefit).

Thanks for your reply @johnandmegh :slight_smile:

I’m assuming that you’re referring to using a Flatpak app without adapting its permissions.

After installing any Flatpak app, end-users can easily and quickly adapt its permissions. Using this awesome and very popular Flatseal app at https://flathub.org/apps/com.github.tchx84.Flatseal

Then, all Flatpak permissions set with Flatseal automatically override and cancel any app permissions. This is what I meant by app with Flatpak have stronger security.


Below is the same reply as above. But with details if you’re interested in those.

For those not familiar with the Flatpak Flatseal app, this screenshot below shows an example. Using simple on-off switches, end-users are able to quickly adapt any Flatpak app permissions.

There are many ways to adapt a Flatpak app permissions. For end-users using only a GUI, the easiest that I know of are those steps below.

Steps

  1. If not already done, install Flathub for Debian per https://flathub.org/setup

  2. Install Flatseal Flatpak app from https://flathub.org/apps/com.github.tchx84.Flatseal

  3. Using Flatseal, adapt the permissions of the app installed above. See the screenshot up above. In this example, the user could turn off the “All user files” switch. The number 3 in the screenshot above shows this. Then, optionally, using the “Other files” field, allow access to only some folder(s) to her/his likings. By adding the path(s). The number 4 shows this. There are lots of other types of permissions Flatseal is able to adapt. For example, but not limited to, allow the app access to only a few folders to your liking. Not all folders.

  4. Launch the app with stronger security

  5. Done. In the future, in this example, each time you launch the Flatpak app, it has only access to the folder(s) of your choosing. In the future, after updates, if somehow, in good faith, the maintainer of the app allows access to all folders, Flatseal with automatically override and cancel this permission. All of the above, shows that an app with Flatpak has stronger security. In turn, stronger privacy. Simply because the Flatpak app now has only access to the folder(s) and file(s) you allowed.

The above assumes the end-users are Flatpak newcomers using only a GUI. Mid-level or advanced end-users are able to do the same using other options. Such as, but not limited to, Flatseal advanced permission configurations, or Flatpak commands using Console/Konsole/Terminal.

Video about Flatseal at https://youtu.be/IfDUXZfDhEI

For developers, this Flatpak documentation might be of interest.

___• Folder and File permissions at https://docs.flatpak.org/en/latest/sandbox-permissions.html#filesystem-access

___• All other permissions at https://docs.flatpak.org/en/latest/sandbox-permissions.html

In this documentation above, under the title “Additionally the following permissions are available”, using Flatseal, end-users are able to quickly and easy deactivate or activate any of those folder permissions. With a flip of a switch. All of the above using a graphical user interface (GUI).

Hi @chartmann :slight_smile: I just found how to publish a rating and review for Run It. In the middle of the page, I needed to use the “Product” horizontal tab and at the bottom, use its “Add a comment” field. I published one now and it worked at https://store.kde.org/s/KDE%20Store/p/2255893

Before this above, I was trying to use the “Ratings & Reviews” horizontal tab to publish my review. But somehow, the “Add a comment” field is not available on this horizontal tab. In other words, a user error. Anyhow, I learned something new.