[GH-ISSUE #938] Wishlist: Run a command when switching screens #749

Open
opened 2026-05-05 07:01:51 -06:00 by gitea-mirror · 3 comments
Owner

Originally created by @mathrick on GitHub (Nov 6, 2020).
Original GitHub issue: https://github.com/debauchee/barrier/issues/938

Context

I have a setup where my personal laptop and work laptop are connected to two different docks, which are then connected to the same monitors. Since I don't want to have multiple keyboards on my desk, I'm trying to use Barrier to share it. But since the two machines are displaying on the same physical monitors, I need to cause them to switch inputs when going to the other machine. The monitor controls are for that are really clunky and take about 10 button presses per monitor, but I can run a command (xset dpmi force off) to turn off video output, which causes the monitor to search for another active input automatically.

Request

It'd be very useful if Barrier had an action type that runs a command, and a way to run that command when control switches away from a screen. This way, whenever I switch to the other machine, the one that's being deactivated could automatically run xset dpmi force off. This might need to be split into multiple issues, since as far as I can tell, it'd need multiple enhancements to implement (namely: new "command" action type, and the ability run actions when switching away from a screen).

Originally created by @mathrick on GitHub (Nov 6, 2020). Original GitHub issue: https://github.com/debauchee/barrier/issues/938 ### Context I have a setup where my personal laptop and work laptop are connected to two different docks, which are then connected to the same monitors. Since I don't want to have multiple keyboards on my desk, I'm trying to use Barrier to share it. But since the two machines are displaying on the same physical monitors, I need to cause them to switch inputs when going to the other machine. The monitor controls are for that are really clunky and take about 10 button presses per monitor, but I can run a command (`xset dpmi force off`) to turn off video output, which causes the monitor to search for another active input automatically. ### Request It'd be very useful if Barrier had an action type that runs a command, and a way to run that command when control switches away from a screen. This way, whenever I switch to the other machine, the one that's being deactivated could automatically run `xset dpmi force off`. This might need to be split into multiple issues, since as far as I can tell, it'd need multiple enhancements to implement (namely: new "command" action type, and the ability run actions when switching away from a screen).
Author
Owner

@mickdarling commented on GitHub (May 17, 2021):

General solution

There is a more elegant way of switching the monitor input (if the monitor supports it), but it still requires triggers a terminal command. You need to send DDC codes to the monitor.

It would be great to be able to trigger a terminal command on_screen_change, and it could make it almost seamless to swipe from one computer to another on the same Monitor.

MacOS

For MacOS ddcctl (https://github.com/kfix/ddcct ) allows you to send a signal via the video signal to change the monitor input on the monitor.

e.g. This is my script for changing from HDMI-1 to DVI-1 ddcctl -d 1 -i 3

I run these on the Barrier server computer, even when my the screen is on another input, with a command shortcut using Better Touch Tools (https://folivora.ai/ ) but I am sure other shortcut/macro tools can be used.

Linux

On linux ddcutil (https://www.ddcutil.com/ ) fulfills the same purpose.

Windows

Not sure, and several older windows apps seem to be abandoned that might have done the trick. This Autohotkey script may be able to switch monitors. Autohotkey Change Monitor Input Source (https://autohotkey.com/board/topic/96884-change-monitor-input-source/)

<!-- gh-comment-id:842594211 --> @mickdarling commented on GitHub (May 17, 2021): ### General solution There is a more elegant way of switching the monitor input (if the monitor supports it), but it still requires triggers a terminal command. You need to send DDC codes to the monitor. It would be great to be able to trigger a terminal command on_screen_change, and it could make it almost seamless to swipe from one computer to another on the same Monitor. ### MacOS For MacOS **ddcctl** (https://github.com/kfix/ddcct ) allows you to send a signal via the video signal to change the monitor input on the monitor. _e.g. This is my script for changing from HDMI-1 to DVI-1_ `ddcctl -d 1 -i 3` I run these on the Barrier server computer, even when my the screen is on another input, with a command shortcut using **Better Touch Tools** (https://folivora.ai/ ) but I am sure other shortcut/macro tools can be used. ### Linux On linux **ddcutil** (https://www.ddcutil.com/ ) fulfills the same purpose. ### Windows Not sure, and several older windows apps seem to be abandoned that might have done the trick. This Autohotkey script may be able to switch monitors. **Autohotkey Change Monitor Input Source** (https://autohotkey.com/board/topic/96884-change-monitor-input-source/)
Author
Owner

@Scoopie commented on GitHub (Jan 25, 2022):

Windows

ControlMyMonitor by Nirsoft https://www.nirsoft.net/utils/control_my_monitor.html allows sending DDC codes to the monitor. You can modify the monitor settings from the GUI and from command-line.

<!-- gh-comment-id:1021503728 --> @Scoopie commented on GitHub (Jan 25, 2022): ### Windows **ControlMyMonitor** by Nirsoft https://www.nirsoft.net/utils/control_my_monitor.html allows sending DDC codes to the monitor. You can modify the monitor settings from the GUI and from command-line.
Author
Owner

@mem- commented on GitHub (Feb 9, 2023):

I also like the idea of running scripts at edge. Then one of the computers can send correct ddccontrol commands to the monitor(s).

Today I use some bash aliases to ssh to the correct computer to execute the ddccontrol commands. To automate this would be really nice.

<!-- gh-comment-id:1424559898 --> @mem- commented on GitHub (Feb 9, 2023): I also like the idea of running scripts at edge. Then one of the computers can send correct ddccontrol commands to the monitor(s). Today I use some bash aliases to ssh to the correct computer to execute the ddccontrol commands. To automate this would be really nice.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: github-starred/barrier#749
No description provided.