debauchee / barrier

Open-source KVM software
Other
27.53k stars 1.51k forks source link

Feature request : configurable shortcuts for triggering scripts on host #1079

Open Potomac opened 3 years ago

Potomac commented 3 years ago

Hello,

a PC monitor can have several inputs : vga, hdmi, dvi, display port,

I decided to connect 2 PCs on my iiyama monitor (VGA and DVI ports), I want to select the input (VGA, DVI) by sending DDC commands to the monitor, instead of using the OSD of my monitor, it is possible by using DDC protocol : https://en.wikipedia.org/wiki/Display_Data_Channel

I can write a bash script with inside commands made by "ddcutil", that can automatically switch the monitor to the desired video input (VGA, DVI) : https://passthroughpo.st/switching-monitor-inputs-software-ddc/ https://www.ddcutil.com/

The feature I want for barrier : have the ability to trigger a custom bash script with the keyboard, by configuring shortcuts, the bash script would run the appropriate ddcutil command for switching the monitor to the correct input (VGA, DVI etc...), according to the PC I want to control.

Thanks.

eldorel commented 2 years ago

@Potomac I have no idea where I found this, but barrier has a command line flag for the server that can be used to trigger a script on screen change.

--screen-change-script /path/to/script

This runs the named script on switch with the name of the screen as the first argument. I have a bash script with a case statement that changes the color of my RGB keyboard to reflect which system i'm currently controlling.


That said, I do actually have a different use case for an 'action' that can be triggered by keypresses to execute a script on the host (and hopefully allow this as a secondary action for that keypress).

I want to configure a single shortcut on all of my systems to toggle screen brightness (also using DDCutil actually) and have barrier send that keypress to everything.

Sending the key works, but the shortcut system in X11 runs at a lower level than barrier and hides the keypress, so I actually can't have barrier trigger a keypress on an action that's linked to an X11 shortcut.

Being able to setup something similar to this: keystroke(F21) = keystroke(F21,*)+run(/path/to/script) or keystroke(F21) = run(/$home/relative/path/to/script,*) would allow me to execute the brightness control script on the server or trigger a script on all clients in the same location.

superuser7777 commented 2 years ago

Is this command line not used anymore? --screen-change-script /path/to/script I checked. It's not there. https://github.com/debauchee/barrier-wiki/blob/master/Command-Line.md#server_cli

I have an AHK script that I want to run only when I am operating on a barrier. I was looking for a way to be a trigger.

Windows to Windows Win10Pro & Barrier latest

mitchcapper commented 2 years ago

Seems like it exists only on the xwindows clients: https://github.com/debauchee/barrier/blob/fc045fc79326cef966405b1cc578e8f062ae5294/src/lib/barrier/ServerApp.cpp#L123

and in the man page: https://github.com/debauchee/barrier/blob/fc045fc79326cef966405b1cc578e8f062ae5294/doc/barriers.1#L50

is captured no matter the client: https://github.com/debauchee/barrier/blob/fc045fc79326cef966405b1cc578e8f062ae5294/src/lib/barrier/ArgParser.cpp#L64

But only run if it is XWindows: https://github.com/debauchee/barrier/blob/fc045fc79326cef966405b1cc578e8f062ae5294/src/lib/barrier/ServerApp.cpp#L690

Extending it to support other platforms would not be overly difficult ( and likely just require modifying that last function around handleScreenSwitched

superuser7777 commented 2 years ago

@mitchcapper Thanks for the details. I look forward to future development.