This forum has been archived. All content is frozen. Please use KDE Discuss instead.

Limit a program to single instance

Tags: None
(comma "," separated)
rsupremo
Registered Member
Posts
51
Karma
0
OS

Limit a program to single instance

Sat Dec 06, 2014 6:09 pm
Is there a way in KDE to limit the number of instances of a particular program to just one and if the user launches a new instance with already one instance existing the window of the previous window would come into top instead?


openSUSE 13.2, KDE 4.14.2
Arch Linux, KDE 4.14.7
User avatar
google01103
Manager
Posts
6668
Karma
25
probably depends on the particular program - don't know if there's a KDE global option to enforce this but I don't think there is

examples:
- "kate --u" 'u' is an option to reuse the existing Kate instance
- "konsole --new-tab" creates a tab in an existing Konsole window instead of creating a new one
- VLC has preferences settings to allow only one instance

for programs like kate and konsole you can edit Kmenu to always use those options or create aliases in your .bashrc if opening them on a command line


OpenSuse Leap 42.1 x64, Plasma 5.x

rsupremo
Registered Member
Posts
51
Karma
0
OS
probably depends on the particular program - don't know if there's a KDE global option to enforce this


I am interested in the global option, but thanks for the tips and info about other applications. I knew about single instance setting of Krusader only.

Last edited by rsupremo on Sun Dec 07, 2014 10:38 am, edited 2 times in total.


openSUSE 13.2, KDE 4.14.2
Arch Linux, KDE 4.14.7
luebking
Karma
0
No.
If you run an executable, the process is just started by init.
=> You must have an executable with support to check for running instances/present windows and the ability to raise latter.
You'll have a hard time to get that into a binary that doesn't already support it, but you can script yourself sth. like that:

Code: Select all
#!/bin/sh
wmctrl -a "trojitá" || /usr/local/bin/trojita &


Notice that this is a veeery basic example, because
wmctrl -a "trojitá"
will usually also match a browser that has the trojita webpage open. You'll have to sharpen the wmctrl matching to fit your needs.
rsupremo
Registered Member
Posts
51
Karma
0
OS
Yep. I used similar wmctrl script for this. I was wondering if KDE desktop does not provide this functionality but it seesm that answer is no.


openSUSE 13.2, KDE 4.14.2
Arch Linux, KDE 4.14.7
luebking
Karma
0
It's completely impossible to post-apply such feature from userspace (and the kernel/init process does of course not link X11 ;-)

Either the client manages its singleton status by itself, or you use a script to do this.
Of course there're docker/taskbars which allow to "stick" a button for an application and will either start the assigned application or raise a matching window - but that's tied to the particular launcher.


Bookmarks



Who is online

Registered users: bartoloni, Bing [Bot], Evergrowing, Google [Bot], q.ignora, watchstar