this post was submitted on 20 Jul 2025
10 points (91.7% liked)

Linux Questions

2320 readers
1 users here now

Linux questions Rules (in addition of the Lemmy.zip rules)

Tips for giving and receiving help

Any rule violations will result in disciplinary actions

founded 2 years ago
MODERATORS
 

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 1920x1080@120.000
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 1920x1080@120.000" 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!

all 15 comments
sorted by: hot top controversial new old
[–] lounges@lemmy.world 2 points 1 week ago (1 children)

You are looking for gdctl. https://manpages.ubuntu.com/manpages/plucky/man1/gdctl.1.html

You may also want pactl for audio switching.

[–] riquisimo@lemmy.dbzer0.com 1 points 1 week ago* (last edited 1 week ago)

This looks promising, thank you!

EDIT: This is the way! I was able to use gdctl to change my monitor setup. I couldn't find any tutorials online aside from the example at the bottom of the man page. Once I configure everything to my liking (including pactl) I'll do a write up and edit my post. Thank you!

[–] dontmindmehere@programming.dev 2 points 1 week ago (3 children)

as far as i can tell, those keybindings are handled internally, they don't invoke shell commands

you can use something like wtype or ydotool to send keybindings from kdeconnect

[–] riquisimo@lemmy.dbzer0.com 1 points 1 week ago

I'll look into these, thank you!

[–] riquisimo@lemmy.dbzer0.com 1 points 1 week ago (2 children)

Ok, wtype looks really promising but I'm having issues building it. I cloned it, installed meson, and when I try "meson build" I get this error:

meson.build:1:0: ERROR: Unknown compiler(s): [['cc'], ['gcc'], ['clang'], ['nvc'], ['pgcc'], ['icc'], ['icx']]
The following exception(s) were encountered:
Running `cc --version` gave "[Errno 2] No such file or directory: 'cc'"
Running `gcc --version` gave "[Errno 2] No such file or directory: 'gcc'"
Running `clang --version` gave "[Errno 2] No such file or directory: 'clang'"
Running `nvc --version` gave "[Errno 2] No such file or directory: 'nvc'"
Running `pgcc --version` gave "[Errno 2] No such file or directory: 'pgcc'"
Running `icc --version` gave "[Errno 2] No such file or directory: 'icc'"
Running `icx --version` gave "[Errno 2] No such file or directory: 'icx'"

And I can't figure out what I need to install to fix that. It looks like on debian based systems there's a "build-essentials" package, but when I "sudo dnf search build-essential" I get nothing. I'll keep searching but if you have any tips please let me know.

[–] riquisimo@lemmy.dbzer0.com 2 points 1 week ago

Ok, so following the MesonBuild website, I needed to install a compiler toolchain:

sudo dnf install gcc-c++

Then I was still missing some dependencies, so I also dnf installed "cmake," "rust-wayland-client+default-devel," and "rust-xkbcommon+wayland-devel"

And now it builds and I was able to install! However, it doesn't work. I get an error "Compositor does not support the virtual keyboard protocol," which, looking at the issues on github, seems to be a known issue with Fedora and other GNOME desktops.

So wtype is out. I'll try ydotool next!

[–] riquisimo@lemmy.dbzer0.com 1 points 1 week ago (1 children)

ydotool is working! However I need to start the daemon in order for it to work, using:

ydotoold --socket-path="/run/user/1000/.ydotool_socket" --socket-own="$(id -u):$(id -g)"

So now I'm looking for a way to automatically run that on login so that it's fully automatic. KDE has startup options that can run scripts, but GNOME seems to only let you run "apps" using GNOME tweaks.

So I need to figure out how to have Fedora/GNOME run a command in the background at startup, then I should be good to go.

(If no one replies to this post I'll edit it later with my results.)

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

[–] just_another_person@lemmy.world 1 points 1 week ago (1 children)
[–] riquisimo@lemmy.dbzer0.com 1 points 1 week ago (1 children)

Yup! I'm here. I know how to add commands, I just don't know the command to run.

I don’t know what command to invoke to trigger “Display Configuration Switcher” to swap configurations.

I appreciate the comment though!

[–] just_another_person@lemmy.world 1 points 1 week ago (1 children)

Just send "CTRL +" if that's what works locally. Am I missing something here?

[–] riquisimo@lemmy.dbzer0.com 1 points 1 week ago (1 children)

How do you send the ctrl key? My mobile keyboard doesn't have ctrl, alt, shift, or super modifiers.

[–] just_another_person@lemmy.world 0 points 1 week ago* (last edited 1 week ago) (1 children)

Literally the link I sent you that you said you read. See the link to Userbase within for examples.

Edit: also https://www.reddit.com/r/kde/comments/v3svo7/alt_ctrl_and_super_key_input_with_kde_connect/

[–] riquisimo@lemmy.dbzer0.com 1 points 1 week ago

Thanks.

So the link you originally sent doesn't say anything about sending ctrl/shift/alt modifier keystrokes. And I didn't click the Userbase link at the end of that page because it said it was linking to scripts.

That Userbase link does mention sending keystrokes! However it uses "nircmd," which is a windows-specific command (Example: nircmd sendkeypress shift+plus)

BUT! The reddit link mentions Unexpected Keyboard, which does work! Once installed and enabled I can go into KDE Connect > remote input > keyboard and hit the language icon/globe thing and my keyboard swaps between my preferred keyboard and Unexpected keyboard. On UK I can press Ctrl and swipe down&right on the "n" key to access semicolon and my display config switches. Success!

However it's still not as clean as I would like it. It's still 5 clicks/taps instead of 2. I decided to post on the app's GitLab page to see if the developer could make a command or something that would trigger the switch. But in the mean time, I have one working solution. So thanks!