toggle graphic tablet mapping on wayland (wacom)

since I have started to use wayland, I am not able to use xsetwacom anymore. I used to use that script on x11 to toggle between the screens

#!/bin/sh
for ID in $(xsetwacom list | cut -f2 | cut -d’ ’ -f2); do xsetwacom set “$ID” maptooutput next; done

but now I don’t seem to find a way to toggle my screens outside the settings, tried to edit .config/kcminputrc my self and reload, but I am not sure what to reload

is there a way to do it that I am not aware of?

thanks for your help in advance!

UPDATE: I found a working solution

I am not great with coding but I was trying to figure out how the settings working in the first place

started with plasma/wacomtablet, which turned to be the old module

so if I am not mistaken plasma/plasma-desktop/-/tree/master/kcms/tablet is what we use currently

I have made this

#!/bin/bash
# Wacom Tablet Screen Toggle

TABLET_DEVICE="event7"
DEVICE_PATH="/org/kde/KWin/InputDevice/$TABLET_DEVICE"

# screens
SCREEN1="HDMI-A-1"
SCREEN2="eDP-1"

# Get current output
CURRENT_OUTPUT=$(qdbus org.kde.KWin $DEVICE_PATH \
    org.freedesktop.DBus.Properties.Get \
    org.kde.KWin.InputDevice outputName 2>/dev/null)

if [ $? -ne 0 ] || [ -z "$CURRENT_OUTPUT" ]; then
    notify-send -i dialog-error "Wacom Toggle" "Failed to read current output"
    exit 1
fi

echo "Current output: $CURRENT_OUTPUT"

# Toggle logic
if [ "$CURRENT_OUTPUT" = "$SCREEN1" ]; then
    NEXT_OUTPUT="$SCREEN2"
    SCREEN_NAME="Laptop (eDP-1)"
else
    NEXT_OUTPUT="$SCREEN1"
    SCREEN_NAME="External (HDMI-A-1)"
fi

echo "Switching to: $NEXT_OUTPUT"

# Apply the mapping
qdbus org.kde.KWin $DEVICE_PATH \
    org.freedesktop.DBus.Properties.Set \
    org.kde.KWin.InputDevice outputName "$NEXT_OUTPUT"

if [ $? -ne 0 ]; then
    notify-send -i dialog-error "Wacom Toggle" "Failed to set output to $NEXT_OUTPUT"
    exit 1
fi

qdbus org.kde.KWin $DEVICE_PATH \
    org.freedesktop.DBus.Properties.Set \
    org.kde.KWin.InputDevice mapToWorkspace false

notify-send -i video-display "Wacom Tablet" "Switched to $SCREEN_NAME"

echo "Successfully switched to $NEXT_OUTPUT"

I have also made a helper if someone needs to use this script

#!/bin/bash

echo "=========================================="
echo "  WACOM SETUP HELPER"
echo "=========================================="
echo ""

# Colors
GREEN='\033[0;32m'
BLUE='\033[0;34m'
YELLOW='\033[1;33m'
NC='\033[0m'

# Find tablet device
echo -e "${BLUE}STEP 1: Finding your tablet device...${NC}"
echo ""

DEVICES=$(qdbus org.kde.KWin /org/kde/KWin/InputDevice \
    org.freedesktop.DBus.Properties.Get \
    org.kde.KWin.InputDeviceManager devicesSysNames 2>/dev/null | \
    grep -E '^event[0-9]+$')

TABLET_FOUND=""
for device in $DEVICES; do
    is_tablet=$(qdbus org.kde.KWin /org/kde/KWin/InputDevice/$device \
        org.freedesktop.DBus.Properties.Get \
        org.kde.KWin.InputDevice tabletTool 2>/dev/null)
    
    if [ "$is_tablet" = "true" ]; then
        name=$(qdbus org.kde.KWin /org/kde/KWin/InputDevice/$device \
            org.freedesktop.DBus.Properties.Get \
            org.kde.KWin.InputDevice name 2>/dev/null)
        echo -e "${GREEN}Found tablet:${NC} $device"
        echo "  Name: $name"
        TABLET_FOUND="$device"
        break
    fi
done

if [ -z "$TABLET_FOUND" ]; then
    echo "No tablet found!"
    echo "Make sure your tablet is connected and recognized by KDE."
    exit 1
fi

echo ""

# Find screens
echo -e "${BLUE}STEP 2: Finding your screens...${NC}"
echo ""

# Use KWin support information
SUPPORT_INFO=$(qdbus org.kde.KWin /KWin org.kde.KWin.supportInformation 2>/dev/null)

if [ -z "$SUPPORT_INFO" ]; then
    echo "Could not get KWin information"
    exit 1
fi

# Extract screen names (the method that actually works)
SCREENS=$(echo "$SUPPORT_INFO" | grep "Name:" | awk '{print $2}' | tr -d '",')

if [ -z "$SCREENS" ]; then
    echo "No screens found!"
    exit 1
fi

SCREEN_ARRAY=($SCREENS)

# Filter out non-screen entries (like "DRM", "Bibata-6e099")
FILTERED_SCREENS=()
for screen in "${SCREEN_ARRAY[@]}"; do
    # Keep only entries that look like display connectors
    if [[ "$screen" =~ ^(HDMI|DP|eDP|DVI|VGA|LVDS) ]]; then
        FILTERED_SCREENS+=("$screen")
        
        # Try to get geometry info
        GEOMETRY=$(echo "$SUPPORT_INFO" | grep -A 5 "Name: $screen" | grep "Geometry:" | head -1 | awk '{print $2}')
        
        echo -e "${GREEN}Found screen:${NC} $screen"
        if [ -n "$GEOMETRY" ]; then
            echo "  Geometry: $GEOMETRY"
        fi
    fi
done

if [ ${#FILTERED_SCREENS[@]} -eq 0 ]; then
    echo "No valid display outputs found!"
    echo ""
    echo "Raw screen data found:"
    for screen in "${SCREEN_ARRAY[@]}"; do
        echo "  - $screen"
    done
    exit 1
fi

SCREEN_ARRAY=("${FILTERED_SCREENS[@]}")

echo ""

# Show configuration
echo "=========================================="
echo -e "${BLUE}CONFIGURATION FOR YOUR SCRIPT:${NC}"
echo "=========================================="
echo ""

echo "Edit the other (Wacom Tablet Screen Toggle) script and set these values:"
echo ""
echo -e "${YELLOW}TABLET_DEVICE=\"$TABLET_FOUND\"${NC}"

if [ ${#SCREEN_ARRAY[@]} -eq 2 ]; then
    echo -e "${YELLOW}SCREEN1=\"${SCREEN_ARRAY[0]}\"${NC}"
    echo -e "${YELLOW}SCREEN2=\"${SCREEN_ARRAY[1]}\"${NC}"
elif [ ${#SCREEN_ARRAY[@]} -eq 1 ]; then
    echo -e "${YELLOW}SCREEN1=\"${SCREEN_ARRAY[0]}\"${NC}"
    echo -e "${YELLOW}SCREEN2=\"${SCREEN_ARRAY[0]}\"  # Only one screen detected!${NC}"
else
    echo "Available screens (pick two for toggle):"
    for i in "${!SCREEN_ARRAY[@]}"; do
        echo -e "${YELLOW}  ${SCREEN_ARRAY[$i]}${NC}"
    done
fi

echo ""
echo "=========================================="
echo -e "${GREEN}DONE!${NC}"
echo "=========================================="

The script uses KWin’s DBus interface (org.kde.KWin.InputDevice) to change the tablet’s outputName property, which is the same interface the Drawing Tablet settings use. This is the proper Wayland way to handle tablet mapping in KDE Plasma 6.

I’m looking into adding shortcuts back into the Drawing Tablet KCM (like the old wacomtablet module had). The relevant code is in plasma/plasma-desktop/-/tree/master/kcms/tablet

not sure why I can not have links in my reply but these are the kde repos

UPDATE: made small kded for it

plasma/plasma-desktop/-/merge_requests/3300