如何控制房间内多台 Windows 计算机的屏幕?

如何控制房间内多台 Windows 计算机的屏幕?

我想在房间周围设置只读屏幕,在不同时间显示不同的消息。一台笔记本电脑将运行一个 BASH 脚本来检查时间,并决定将哪些消息发送到哪个显示器以及何时发送。这可以是纯文本(可能是控制台,但字体很大)或图片,无论哪种都可以。一个非常基本的脚本可能看起来像这样:

#!/bin/bash
echo "Good morning!" > /dev/screen1
echo "Please stack the blocks as high as you can!" > /dev/screen2

我的工作场所有许多未使用的联想 Yoga,因此我可以折叠键盘并在房间周围安装七八个,只显示屏幕。我认为工作场所不会允许我从这些设备上删除 Windows 10。

  • 文字或者图片,都可以。
  • Yogas 确实有 HDMI 端口。
  • 房间里的人不会与屏幕互动,他们只显示信息。

问题是,如何从运行 Linux 的笔记本电脑上的 BASH 脚本获取文本(或可选的图片),以在分散在房间各处的 Windows 屏幕上显示这些不同的消息或图片?

答案1

在 Linux 机器上设置一个简单的 http 服务器,其中包含许多静态 html 页面。直接将 bash 中的消息写入这些页面。在 Windows 计算机上的浏览器中打开这些页面。当新数据到来时,您可以使用一些 JavaScript 魔法来自动重新加载其内容。

例子:

在 Linux 机器上:

设置静态 http 服务器并让它从以下位置提供服务/var/www/room/

mkdir /var/www/room/
cd /var/www/room/
python3 -m http.server

创建一个页面/var/www/room/index.html

<head>
<meta charset="UTF-8">
</head>
<body>
<div id="data">
  <!-- here will be an autoreloaded data -->
</div>
<script>
const AUTORELOAD_TIMEOUT = 1000;  // milliseconds

setInterval(async () => {
  /*
    Load data from an address after the hash-sign (#) and put it into div#data

    E.g. if the browser location is:

       http://somesite/some/path#some/file/name

    then the function will load data from the page:

       http://somesite/some/file/name

  */
  const hash = document.location.hash
  if (hash.length <= 1) {
    return
  }
  const file = hash.slice(1)
  const response = await fetch(file)
  if (response.status === 200) {
    document.getElementById("data").innerHTML = await response.text()
  }
}, AUTORELOAD_TIMEOUT)
</script>
</body>

在 Windows 机器上:

  • 打开浏览器http://your-linux-machine-ip:your-linux-machine-port/index.html#screen1

在 Linux 机器上:

  • 写入文件screen1
echo "Hello, world!" > /var/www/room/screen1

检查 Windows 机器:

  • 页面应显示文本Hello, world!

相关内容