Skip to content

Headless Linux box share mouse and keyboard to windows #1135

@ghost

Description

This issue has been migrated from old Barrier Github repository debauchee/barrier#1135

Issue created on: 2021-04-19 by @lededev
Issue last updated on: 2021-05-18

Can I use barrier on a Linux box no monitor, but have USB port and mouse and keyboard, and share them to a Windows PC?
I need this because fiber HDMI can transmit video far distance, but some of them have no USB channel, to provide input devices.
A raspberry pi or openwrt box which have USB port, do this job I think is enough.
I tried USB over Ethernet, but the newest windows usbip still unstable, so I come here.


Commented on: 2021-04-20 by @lededev

  • progress

I am now using a RK3288 TV box, install Armbian, and barrier as server, connect USB kbd and mice.
because Armbian act like other TV box, it will directly go into user desktop by default. I can lunch barriers by using xfce4's autostart.
After this TV box power on, wait about 60s, press hotkey CTRL+ALT+o, my windows client got kbd and mice.

As the next step in the future, I will add some C++ code to make the switch screen action automatically. When server find remote client connected, it will switch screen input focus to remote client immediately, because a headless box hold USB HID devices is pointless.
The primary(headless) client which on server will only got input focus by using hotkey CTRL+ALT+p, for maintenance purposes.

filename: /home/user/.config/autostart/barriers.desktop

[Desktop Entry]
Encoding=UTF-8
Version=0.9.4
Type=Application
Name=barriers focus remote client
Comment=share keybd mice
Exec=/usr/bin/barriers --debug INFO --name headless --enable-crypto -c /home/user/remote_client.sgc --address :24800
OnlyShowIn=XFCE;
RunHook=0
StartupNotify=false
Terminal=false
Hidden=false

filename /home/user/remote_client.sgc

section: screens
        remote_client:
                halfDuplexCapsLock = false
                halfDuplexNumLock = false
                halfDuplexScrollLock = false
                xtestIsXineramaUnaware = false
                preserveFocus = false
                switchCorners = none +top-left +top-right +bottom-left +bottom-right
                switchCornerSize = 99
        headless:
                halfDuplexCapsLock = false
                halfDuplexNumLock = false
                halfDuplexScrollLock = false
                xtestIsXineramaUnaware = false
                preserveFocus = false
                switchCorners = none +top-right +bottom-right
                switchCornerSize = 99
end

section: aliases
end

section: links
        remote_client:
        headless:
end

section: options
        relativeMouseMoves = true
        screenSaverSync = false
        win32KeepForeground = false
        clipboardSharing = false
        switchCorners = none
        switchCornerSize = 0
        keystroke(Control+Alt+o) = switchToScreen(remote_client)
        keystroke(Control+Alt+p) = switchToScreen(headless)
end


Commented on: 2021-04-21 by @lededev

step 2 complete. Just add an option --headless-mode in server command line, with my PR debauchee/barrier#1139 applied:
Exec=/usr/bin/barriers --debug INFO --name headless --enable-crypto -c /home/user/remote_client.sgc --address :24800
replace to
Exec=/usr/bin/barriers --debug INFO --name headless --enable-crypto --headless-mode -c /home/user/remote_client.sgc --address :24800
You will got an out of the box headless USB HID server.

Step 3 in future: I will replace my RK3288 TV box to an even more cheaper RK3188 TV stick, as headless Linux device.


Commented on: 2021-04-30 by @lededev

headless: add hotkey bind userscript
let headless server easy to restart service and reboot server, by using hotkey bind userscript.
Usage:
in remote_client.sgc section: options

        keystroke(Control+Alt+k) = userScript(/home/user/Barrier-script-restart.sh)
        keystroke(Control+Alt+l) = userScript(sudo reboot)

Commented on: 2021-05-18 by @lededev

Update PR, login screen reconnect delay change from 15s to 2s. Some more changes backport from upstream, to resolve pointer jump.

Metadata

Metadata

Assignees

No one assigned

    Labels

    barrier-importImported from Barrier - likely outdated.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions