Meta+1, Meta+2, etc. on non-Primary monitors

Hi, I love using Meta+1 to open Firefox (my first icon in Task Manager) and other numbers for other applications.

I used to have a script bound to keyboard shortcuts to handle this for other applications. Meta+` toggled Konsole on my second screen, for example (I guess it was irrelevant that is was on the Task Manager/Panel on that screen).

I have recently switched to Wayland and my script used wmctrl and xdotool. I assume xdotool at least won’t work well in Wayland so I removed the keyboard shortcut to this script. (Edit: wmctrl works fine but as expected, xdotool does not)

Which brings me to:
Is there any way to have Meta+1, Meta+2-like keyboard shortcuts, but for Panels/Task Managers on non-primary monitors?
This would be an ideal setup for me, over using/updating shell scripts.

1 Like

You can do this in System Settings > Shortcuts. Click the “Add Application” or “Add Command” button to define an app or custom command that will be launched/run in response to a global keyboard shortcut of your choosing.

I think you’d have to use Window Rules to also make these apps open in custom locations.

That gets me close.
I’m able to open (multiple) new windows now, but the behavior I want is

  • If the program is not open, open it
  • Else, if the program is not focused, focus it
  • Else, if the program is focused, minimize it.

That works with Meta+1 on my main Panel but not with Konsole > Konsole or Konsole > Open a new Window shortcuts.

Hmm, I don’t think that’s going to be easily possible. It sounds like you basically want to replicate the Task Manager’s behavior for what happens when clicking on an app icon in various states, but for apps not pinned to the Task Manager.

The behaviors are all specific to the Task Manager, so replicating them in a script will be quite some work.

Thanks for the reply.

but for apps not pinned to the Task Manager.

Yeah that’s pretty much it, but I mean for apps that are in a Task Manager, just not on the primary monitor.

FWIW, this was the script I was using on X11:


if [ "$#" -eq 2 ]; then

if ! pgrep -x $BINARY_NAME > /dev/null ; then
        ($BINARY_NAME &)

ACTIVE_WINDOW=$(xdotool getactivewindow)
CUR_WINDOW_PID=$(xdotool getwindowpid $ACTIVE_WINDOW)
APP_WINDOW_PID=$(wmctrl -lp | grep -iE "$APP_WINDOW_PIDS" | awk '{print $3}')

if [[ "$CUR_WINDOW_PID" == "$APP_WINDOW_PID" ]] ; then
        xdotool windowminimize $ACTIVE_WINDOW
        wmctrl -a $(wmctrl -lp | grep -i $APP_WINDOW_PID | awk '{s = ""; for (i = 5; i <= NF; i++) s = s $i " "; print s}')

So binding Meta+` to ‘ konsole’ would do basically what Meta+1 did.

Looking at how the Keyboard Shortcuts for System Settings > Plasma, it seems to be only aware of one Task Manager, so yeah I get if this is not easily possible.

If I can find a Wayland equivalent to the xdotool commands I may be able to make this work again.

Oh nice, you already have it most of the way there. I’m pretty sure you can do everything you need via KWin’s DBus API. This would work on both X11 and Wayland. I’m not sure where the documentation for it is, or if it even exists, though.

Oh thanks, that gives me something else to look up and try out.

I’ll update this thread if I do find a solution.

However, if one day this were to get expanded and “Activate Task Manager Entry X” were to work beyond the primary monitor/Task Manager, that would be super cool.

Thanks for being a part of making KDE so awesome.

You’re very welcome!