this post was submitted on 29 Apr 2024
32 points (100.0% liked)

Linux

7847 readers
1 users here now

Welcome to c/linux!

Welcome to our thriving Linux community! Whether you're a seasoned Linux enthusiast or just starting your journey, we're excited to have you here. Explore, learn, and collaborate with like-minded individuals who share a passion for open-source software and the endless possibilities it offers. Together, let's dive into the world of Linux and embrace the power of freedom, customization, and innovation. Enjoy your stay and feel free to join the vibrant discussions that await you!

Rules:

  1. Stay on topic: Posts and discussions should be related to Linux, open source software, and related technologies.

  2. Be respectful: Treat fellow community members with respect and courtesy.

  3. Quality over quantity: Share informative and thought-provoking content.

  4. No spam or self-promotion: Avoid excessive self-promotion or spamming.

  5. No NSFW adult content

  6. Follow general lemmy guidelines.

founded 1 year ago
MODERATORS
 

I use KDE on arch and would like to achieve the following behavior:

Whatever way I launch Konsole, I want it to check whether there already is a Konsole instance. If one exists, it should be brought into focus, and if no instance exists, one should be launched.

I am unable to find such an option in the Konsole settings, even though I found a roughly 1 year old forum entry mentioning such a setting. Was it removed or am I just blind? Or do I need some optional dependency?

Alternatively, it would be fine if this could simply kick in when I use my Super+K shortcut, which I've set up. Maybe there's a way to call Konsole from the terminal like that? I tried using konsole --force-reuse but it didn't seem to do the trick, and konsole --new-tab does not bring Konsole into the foreground.

Edit: Here's a script that does this, by @[email protected]

#!/bin/bash
WIN="$(kdotool search --class org.kde.konsole | head -1)"
if [[ "$WIN" != "" ]]; then 
    kdotool windowactivate "$WIN"
else 
    konsole
fi

kdotool is available in AUR as kdotool-git

you are viewing a single comment's thread
view the rest of the comments
[–] [email protected] 8 points 6 months ago* (last edited 6 months ago) (2 children)

Here's a KDE-specific script with kdotool (Wayland always needs custom solutions for simple things):

#!/bin/bash
WIN="$(kdotool search --class org.kde.konsole | head -1)"
if [[ "$WIN" != "" ]]; then 
    kdotool windowactivate "$WIN"
else 
    konsole
fi
[–] [email protected] 3 points 6 months ago

sweet! thank you so much!