Unsolved
1 Rookie
•
2 Posts
0
4889
November 3rd, 2022 07:00
U2723QE, KVM using a keyboard shortcut to switch in Linux
Dell U2723QE
I was trying to come up with an easy way to use a keyboard shortcut to switch my monitor + KVM under Linux. This is what I ended up coming up with in case it helps anyone else. Monitor settings can be queried and changed using the `ddcutil` utility. This was in the main repositories for me. After installing =
sudo apt install ddcutil
I could then query my monitor settings (you may need to change the number at the end to match your monitor) =
sudo ddcutil capabilities -d 1
Which gave me =
....
Feature: 60 (Input Source)
Values:
1b: Unrecognized value
0f: DisplayPort-1
11: HDMI-1
....
Using those values I could switch between my work and person laptop using =
ddcutil setvcp 60 0x1b # the last two inputs correspond to the values above
This command can be used in a simple bash script, but I decided to make a executable so I could run it without sudo. The c code =
// switch_screen.c
#include
#include
#include
#include
int main()
{
setuid(0);
system("ddcutil setvcp 60 0x1b"); // Change this for each computer
return 0;
}
Compiling and setting the appropriate permissions (this could easy just be a Makefile) =
gcc switch_screen.c -o switch_screen
sudo chown root:root switch_screen
sudo chmod 7445 switch_screen
The resulting executable `switch_screen` can then be used by your favorite desktop shortcut manager.
Tested under Debian (Gnome) and Ubuntu (KDE) on a Dell U2723QE monitor. ddcutil should also be available for Fedora+ and there exists an experimental GUI, see the above link, if you are more comfortable starting with that.
just-passing-by
1 Rookie
1 Rookie
•
2 Posts
0
November 3rd, 2022 07:00
Note the c code is taken from here and is not my own:
https://unix.stackexchange.com/questions/703048/how-do-i-run-a-sudo-command-from-kde-shortcuts-command
nik123y
2 Posts
0
August 25th, 2023 20:49
@just-passing-by THANK YOU
nik123y
2 Posts
0
August 25th, 2023 20:49
@lainosantos THANK YOU