My keyboard has a button to launch calculator and I often use it to launch KCalc. However, if I forget that I already have KCalc running and hit that key again, I end up with two instances of KCalc. Is there a way to switch to the running instance of KCalc instead of launching a new one? I don't need to use KCalc, I am open to any other calculator app.
Announcement
Collapse
No announcement yet.
Launch only one instance of KCalc
Collapse
This topic is closed.
X
X
-
xdotool can do that sort of thing. I don't have a calculator key on my keyboard, so I don't know if it can be remapped.
But I have mapped a key to do what you want:- Install xdotool using your favourite method; f.ex. muon package manager.
- Right-click the K-menu, select Edit applications, to start the KDE Menu Editor.
- In some place you find sensible, maybe Utilities, make a new item, give it a name, and for the command use
Code:if ! xdotool search --classname --onlyvisible KCalc windowactivate; then kcalc;fi
- On the advanced tab, set up a shortcut key by clicking the button that says "None".
- Save the menu changes; maybe by clicking Save on the toolbar, or File->Save.
A big caveat is that I find xdotool can be capricious, illogical or inexplicable. Another caveat is that this is using the X window system, and with Wayland I imagine there'll be problems.Regards, John Little
- Top
- Bottom
-
I use wmctrl for this purpose.
Example: wmctrl -xa Konsole || konsole
I too don't have a Calculator key and so don't know whether this will work ...Kubuntu 20.04
- Top
- Bottom
Comment
-
Originally posted by jlittle View PostA big caveat is that I find xdotool can be capricious, illogical or inexplicable. Another caveat is that this is using the X window system, and with Wayland I imagine there'll be problems.Kubuntu 20.04
- Top
- Bottom
Comment
Comment