You are not logged in.

#1 2025-06-22 15:53:40

tvidal
Member
Registered: 2020-06-18
Posts: 23

[SOLVED] focus window or start application on plasma with wayland

Now that we are kind of forced to use Wayland since Plasma 6.4, I have a ton of global shortcuts mapped to scripts like this:

* Meta-F:

wmctrl -xa firefox || exec firefox

* Meta-K:

wmctrl -xa konsole || exec konsole

Since the forced Wayland upgrade, this always starts a new process and does not focus the existing window.

Is there an equivalent way of focusing an application in wayland like we could in Xorg with wmctrl?

Thank you.

Last edited by tvidal (2025-07-09 11:23:50)

Offline

#2 2025-06-22 16:00:20

arojas
Developer
From: Spain
Registered: 2011-10-09
Posts: 2,261

Re: [SOLVED] focus window or start application on plasma with wayland

You are not forced to anything. Nobody is stopping you from keeping using X11.

Offline

#3 2025-06-22 16:06:54

tvidal
Member
Registered: 2020-06-18
Posts: 23

Re: [SOLVED] focus window or start application on plasma with wayland

Well, I said "kind of", because for the moment I fixed by installing plasma-x11-session as suggested in another topic, but I know that is temporary a temporary solution with Xorg reaching end of support.

Ultimately, I will need to find a better solution to keep these Global Shortcuts working.

Last edited by tvidal (2025-06-22 16:10:12)

Offline

#4 2025-06-23 04:40:02

dan123
Member
Registered: 2025-05-30
Posts: 23

Re: [SOLVED] focus window or start application on plasma with wayland

arojas wrote:

You are not forced to anything. Nobody is stopping you from keeping using X11.

But it is forced. No new features are coming to X11 and some features are Wayland-only. Some DEs are dropping X11 support (and dropping it way too early imo) instead of allowing either graphical session. Making your own DE just to run X11 would be a lot of work.

Global shortcuts for X11 apps are kind of supported depending on DE, but should be a feature of XWayland imo. Not sure if it's even possible to make a script run under an X11 session so that you do get potential global shortcut support. Might be something hacky you could do like executing a script in Xterm. Not tested it myself.

Probably better to add X11 as default choice in SDDM

Offline

#5 2025-07-09 11:22:56

tvidal
Member
Registered: 2020-06-18
Posts: 23

Re: [SOLVED] focus window or start application on plasma with wayland

found kdotool

here's the full script for future reference:

#!/usr/bin/env zsh
set -eo pipefail
#
## open-app
#
# Usage:
# open-app [action] <class> [args]
# action:
#     -R:         move window to current desktop and focus
#
# name:           window class / executable name
# args:           executable program arguments

zparseopts -D -K -a ARGS -- R || exit 1

# focus app if already running
WINDOW=$(kdotool search --class $1)
if [ -n "$WINDOW" ]
then
	if [ -n "${ARGS[(r)-R]}" ]
	then
		kdotool set_desktop_for_window $WINDOW $(kdotool get_desktop)
	fi
	kdotool windowactivate $WINDOW
	exit 0
fi
cd ${HOME}

if exe=$(whence -p $1) && [ -x $exe ]
then
	exec $*
else
	gtk-launch $*
fi

Offline

#6 2025-10-30 07:31:06

nonZero
Member
Registered: 2015-05-17
Posts: 64

Re: [SOLVED] focus window or start application on plasma with wayland

I am looking for a gnome solution for this.

https://superuser.com/questions/1929485 … ning-gedit

Offline

Board footer

Powered by FluxBB