Ok, first off KDE Connect is a killer app. It’s so slick and convenient. Love it.

My desktop is running Fedora 42 Workstation with Gnome. Since I’ve got GNOME instead of KDE, I’m using an extension called GSConnect to communicate with KDE connect on my phone. It’s working perfectly.

I’ve also got this extension called “Display Configuration Switcher” that lets me use a keyboard shortcut ( ctrl + ; ) to switch between two display configs:

  1. Standard desktop layout
  2. TV only.

(Fedora 42 is using Wayland, when I was on X11 I could use ARandR to create custom commands but Wayland is… more complicated.)

I want to add a command to KDE Connect/GSConnect to switch my display configuration from “desktop” output to “TV” output. The problem is I don’t know what command to invoke to trigger “Display Configuration Switcher” to swap configurations.

There are multiple ways to approach this. The best solution is just to figure out what command is invoked when I press the keyboard shortcut “ctrl + ;”, which is the shortcut to switch display configs. I’m not sure how to see what command is run when I press a button or shortcut.

Alternatively, I could find a way to send the ctrl + ; shortcut from the KDE connect app. Sending keyboard shortcuts would be handy regardless, but this is a workaround.

Any help would be appreciated. Thank you in advance!

EDIT: Ok, a lot of options below worked!

  • wtype and ydotool can be used to send keystrokes via commands. While wtype didn’t work for me, ydotool did! It requires setting up a daemon to run in the background on system boot.

  • Simply installing a keyboard on android that supports modifier keys (specifically the ctrl key) works too. I used Unexpected Keyboard. Once installed and enabled you can go into KDE Connect > remote input > keyboard and hit the language icon/globe thing and your keyboard swaps between the preferred keyboard and Unexpected keyboard. On UK press Ctrl and swipe down&right on the “n” key to access semicolon and my display config switches.

  • My preferred solution, however, is using gdctl and pactl to manually set the dispay and audio output. Once I figured out the commands I put them in a bash script and point GSConnect to that. My displayConfig_tv.sh script looks like this:

#!/bin/bash
gdctl set --logical-monitor \
--primary \
--monitor HDMI-2 \
--mode [email protected]
pactl set-default-sink alsa_output.pci-0000_2f_00.1.hdmi-stereo-extra3

My TV by default wanted to be 4K at 60Hz, which makes everything too small and at 60Hz everything was stuttery. I had to add the “–mode [email protected]” to force it to 1080p at 120Hz.

(Also of note is that I was having an issue with one of my desktop monitors having a weird refresh rate. I kept trying to set the monitor to “–mode 2560x1440@144” but got an error that no such mode existed. I ended up setting the refresh rate through GNOME settings and running “gdctl show” to see what the current profile was, which was 2560x1440@144.006. Including the “.006” fixed my issue.)

The final issue I’m having is the pactl command fails because the TV audio-out doesn’t exist until the display is enabled. My fix is just to press the command a second time once the TV is active. I may see if adding a “time sleep” or something to the bash script fixes this issue.

Thank you to everyone who helped!

  • dontmindmehere@programming.dev
    link
    fedilink
    English
    arrow-up
    2
    ·
    5 days ago

    in this case, you’ll probably have to create a desktop entry in ~/.local/share/applications/ydotoold.desktop

    something like

    [Desktop Entry]
    Name=ydotool daemon
    Exec=the command you used to launch
    Type=Application
    

    you can look at other .desktop in the same directory for reference