Active Application on Pop!_OS Linux (Wayland)

Hi there, I’m running POP_OS (Therefore Wayland) and I’m trying to use the Rotatrix with FreeCAD. I’m having an issue where the “Check Setup” window is showing the following:

Backend: Custom shell command Test your command in a terminal. Print PIDapp name for process routing, or an app name alone for app matching. A blank record means no active window. Print the initial window within one second. For a command that stays running, print each change on a new line and flush stdout. Save and restart Rotatrix after changing the command.

Process ID: Unavailable

Custom shell command

I’ve tried to set up a custom shell command as instructed but I think I’m missing something, I am pretty sure I am following the instructions wrong. What do I put in the Active Window Command?

Hi and welcome! You’re probably not doing anything wrong - Rotatrix doesn’t currently have built-in active-window detection for COSMIC.

Another Pop!_OS user shared a workaround using cos-cli. With cos-cli and jq installed, save this as ~/.local/bin/cosmic-active-app-id:

#!/usr/bin/env bash
set -o pipefail

app="$(
  cos-cli info --json 2>/dev/null |
    jq -r '[.apps[] | select(.state[]? == "activated")][0].app_id // ""'
)" || exit 1

case "$app" in
  FreeCAD|freecad|org.freecad.FreeCAD)
    echo "FreeCAD"
    ;;
  *)
    echo "$app"
    ;;
esac

Make it executable:

chmod +x ~/.local/bin/cosmic-active-app-id

Then put the full path in Active Window Command, replacing YOUR_USERNAME:

/home/YOUR_USERNAME/.local/bin/cosmic-active-app-id

Save and fully quit & restart Rotatrix. Process ID: Unavailable is expected with this workaround, it provides only the app name. 1.6 should support that when there’s a single matching FreeCAD connection, though I haven’t verified this workaround on the current release yet.

Please let me know whether this gets FreeCAD working, and which Pop!_OS version and FreeCAD package you’re using. If it still doesn’t route movement correctly, I’ll investigate further. I’d also like to make COSMIC setup easier in a future release.

That worked partially. It looks like it is detecting the active app as rotatrix after a moment of pressing the rotation hotkey, and then switches back to FreeCAD after a moment, resulting in alternating between mouse mode and rotation mode.. I’m using Pop!_OS 24.04 LTS with COSMIC 1.10.0 and FreeCAD 1.1.4.

I see - that indicates the OSD is stealing focus, which happens with some window managers. Try turning off the OSD in Config > Global > Rotatrix Mode.

I’ll have to look into why COSMIC ignores the OSD’s no-focus flags. Linux: custom window manager issues with on-screen display (OSD)

Perfect, that worked a treat. COSMIC is a bit of an oddity in many regards, I’ve noticed.

This works for OnShape too.

With OSD turned on, the overlay flickers and rotation/translation is unusable.

With OSD enabled I tried launching rotatrix with XWayland option but it did not work and overlay still flickers:

cosmic-edit ~/.config/autostart/rotatrix.desktop

env QT_QPA_PLATFORM=xcb /home/my_user_name/Applications/rotatrix.appimage

Thanks for sharing. I’m planning to add more OSD elements soon and will look into the Linux focus issues with that round of changes so you all get to enjoy it too.