Last active
May 12, 2025 20:06
-
-
Save zhulik/5f106addffaec4f90b11c5f94242bbc1 to your computer and use it in GitHub Desktop.
A script to switch between two monitors and a TV for a Plasma Desktop
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/ruby | |
require 'json' | |
LG = "DP-1" | |
BENQ = "DP-2" | |
TV = 'HDMI-A-1' | |
def switch_monitor(name, state) = `kscreen-doctor output.#{name}.#{state ? 'enable' : 'disable'}` | |
active = JSON.parse(`kscreen-doctor -j`, symbolize_names: true)[:outputs].find{ _1[:enabled] }[:name] | |
if active == TV | |
switch_monitor(LG, true) | |
switch_monitor(BENQ, true) | |
switch_monitor(TV, false) | |
else | |
switch_monitor(TV, true) | |
switch_monitor(LG, false) | |
switch_monitor(BENQ, false) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment