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,287

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-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

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

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

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