允许我输入热点登录凭据的应用程序名称是什么?

允许我输入热点登录凭据的应用程序名称是什么?

Ubuntu 22.04,我有时使用默认的 Gnome,有时使用 xmonad 窗口管理器。

当我使用 Gnome 连接到需要登录的热点时,会弹出一个热点登录窗口。

当我使用 xmonad 执行相同操作时,没有任何内容弹出。

  • 允许我输入热点登录凭据的应用程序名称是什么?
  • 我可以手动启动它吗?
  • 当从 xmonad 连接到这样的网络时,我怎样才能自动弹出它?

答案1

允许我输入热点登录凭据的应用程序名称是什么?

该应用程序只是指向 HTTP 页面(而非 HTTPS)的嵌入式 Web 浏览器。我们在 2010 年代中期手动完成了这项工作。我认为它有名称,/usr/libexec/gnome-shell-portal-helper但它的身份并不重要,因为下一节中有一个更简单的解决方案。

我可以手动启动它吗?

打开 Firefox 或其他浏览器到任何 HTTP 页面会更简单。只需打开浏览器http://captive.apple.com(非 HTTPS),您将被重定向到热点登录页面。如果没有热点或您已经登录,您将看到“成功”。要确保此操作有效,请检查 HTTPS-only 模式是否已关闭,或者只需单击忽略警告即可。

当从 xmonad 连接到这样的网络时,我怎样才能自动弹出它?

GNOME 是一个桌面环境。xmonad 似乎只是桌面环境的一个组件,即窗口管理器。您需要一些服务守护进程来执行此操作。您需要使用您正在使用的电源管理策略,例如安装单独的软件。这可以通过查找或编写一些软件来实现,这些软件通过系统 DBus 监听 NetworkManager 以获取某些信号,检查该网站是否返回“成功”,如果没有,则启动 Web 浏览器。

我目前没有公共 WiFi 来测试它是否能/usr/libexec/gnome-shell-portal-helper在 GNOME 之外工作。这是我尝试实现的一种不假设用户已安装 GNOME 的实现:

#!/bin/bash
# Put this in `~/bin/captive.sh`
echo "[captive.sh] A script alternative to simulate GNOME's captive portal" >&2

# Ensure 1 instance of captive.sh, and prevent multiple orphaned nmcli processes
trap : SIGTERM
killall captive.sh nmcli 2> /dev/null
trap - SIGTERM
set -e

sleep 5 # Rate limit
while : ; do
  if ! pgrep -cu "$UID" xmonad > /dev/null; then
    echo '[captive.sh] Exiting for logout or other desktop environment'
    exit
  fi

  # Query any simple website that is HTTP not HTTPS.
  # The WiFi provider will intercept this and redirect it to
  # their website if they want you to log in.
  echo '[captive.sh] Checking connectivity' >&2
  if ! curl -s captive.apple.com | head -n1 | grep -q Success; then
    MSG='[captive.sh] Opening browser to log in. If there are any warnings, just click past them.'
    notify-send "$MSG"
    echo "$MSG" >&2
    xdg-open http://captive.apple.com
  else
    echo '[captive.sh] No login required' >&2
  fi

  sleep 5 # Rate limit

  # Listen for connected or connecting state, where
  # we need to check for a captive portal to log in to.
  # Ignore disconnect, where we have nothing to do.
  # Not taking advantage of NetworkManager's connectivity check
  # with the connecting state in case that isn't set up.
  echo '[captive.sh] Waiting for reconnect' >&2
  coproc nmcli monitor
  grep -q ': connect' <&"${COPROC[0]}"
  kill "$COPROC_PID"
done

然后chmod +x ~/bin/captive.sh,或者使用 xmonad 的自动启动功能进行注册(如果有),将以下内容粘贴到~/.config/autostart

[Desktop Entry]
Type=Application
Name=Captive portal simulator
Description=Captive portal https://askubuntu.com/a/1501247/1004020
Exec=/bin/sh -c 'exec ~/bin/captive.sh'
Terminal=false
StartupNotify=false

一个好看的替代方案是https://github.com/elementary/capnet-assist.另一个是https://github.com/FiloSottile/captive-browser/。Arch Wiki 脚本似乎不安全,并且卡在 X11 上。除了我自己的脚本,我没有测试过其他脚本。

答案2

看来 Gnome 只是打开了一个热点登录页面的 URL。我可以复制此 URL 并在 xmonad 中的浏览器中打开它以进入登录页面。

但我怀疑这个 URL 可能会随着时间而改变,而且它实际上来自 Wifi 本身。所以我想我可能需要以某种方式从 Wifi 中提取该 URL。

相关内容