Notes ·
Arch Linux + KDE as a wireless display station: Miracast, AirPlay, scrcpy and a hotspot that coexists with Wi-Fi
Getting one screen onto another without a cable is a question that comes up in every meeting room. This kit answers it for an Arch Linux laptop with KDE Plasma on Wayland: two taskbar buttons that cast to a TV, receive an iPhone or Android screen, and start a Wi-Fi hotspot that doesn’t drop the laptop’s own Wi-Fi. Below is how it works, and the code.
Download: wireless-display-kit.zip (MIT licence). The three main programs are also shown in full at the end of this page.
Turn an Arch Linux laptop running KDE Plasma (Wayland) into a complete wireless-display station:
- Send your screen to a Samsung TV, projector or Chromecast (Miracast and Google Cast).
- Receive screens from an iPhone/iPad/Mac (AirPlay), an Android or Samsung phone (scrcpy, with a DeX-style desktop), or another PC (Moonlight/Sunshine).
- Host a Wi-Fi hotspot that runs at the same time as your normal Wi-Fi connection, so guests can join the laptop directly and use the receivers above.
- Two taskbar launchers with small Qt windows: Wireless Display (big icon buttons) and Wi-Fi Hotspot (QR code, Start/Stop, change password).
Everything here was built and tested on Arch Linux, KDE Plasma 6.8 (Wayland), an Intel Arrow Lake laptop with an Intel Wi-Fi 7 adapter and NetworkManager + firewalld.
1. Quick install
curl -LO https://www.lohn.cc/downloads/wireless-display-kit.zip
unzip wireless-display-kit.zip
cd wireless-display-kit
./install.sh
The installer detects your Wi-Fi interface, installs packages, enables Avahi, offers to open firewall ports, installs the launchers, creates the hotspot profile and pins both launchers to the Plasma taskbar. Needs an AUR helper (yay or paru) for three packages.
Override the detected interface with WIFI_IF=wlan0 ./install.sh.
2. What gets installed
| Purpose | Package | Source |
|---|---|---|
| Miracast + Chromecast sender | gnome-network-displays | AUR |
| AirPlay receiver | uxplay | AUR |
| Cast files/URLs to Chromecast from CLI | catt | AUR |
| Android mirroring / DeX desktop | scrcpy, android-tools | extra |
| Receive another PC’s screen | moonlight-qt | extra |
| Video pipeline + codecs | gst-plugins-good/bad/ugly, gst-libav, gst-plugin-pipewire, pipewire, wireplumber | extra |
| Hardware H.264 encoding (Intel) | intel-media-driver, libva-utils | extra |
| Screen capture on Wayland/KDE | xdg-desktop-portal-kde | extra |
| Service discovery (mDNS) | avahi | extra |
| Launcher windows and QR codes | python-pyqt6, qrencode, kdialog, iw | extra |
Despite its name, GNOME Network Displays works perfectly on KDE: it uses the standard screencast portal that KDE provides.
Check your hardware first
iw phy | grep -E 'P2P-client|P2P-GO|\* AP'
vainfo | grep -i h264
You want P2P-client, P2P-GO (Miracast) and AP (hotspot) listed, and an H264 EncSlice entry for hardware encoding.
3. Sending your screen (Miracast / Chromecast)
- On the TV open Sources → Screen Mirroring (Samsung) or make sure the Chromecast is on the same Wi-Fi.
- Click Wireless Display → Cast to TV.
- Pick the TV in the list, choose the screen or window in the KDE portal dialog, confirm on the TV if asked.
Miracast uses Wi-Fi Direct and does not need a router. Your Wi-Fi may blink for a second while it negotiates.
Firewall: gnome-network-displays ships its own firewalld zone (P2P-WiFi-Display) that it applies automatically to the Wi-Fi Direct link. A firewall-cmd --reload after installing is enough to load it. Chromecast additionally needs mdns and 8008-8009/tcp in your normal zone.
For just playing a file or YouTube link on a Chromecast without mirroring:
catt cast movie.mp4
catt cast https://youtu.be/...
4. Receiving screens
There is no working Miracast receiver for Linux today (miraclecast is abandoned), so Windows “Connect to a wireless display” and Samsung wireless DeX cannot target a Linux laptop. Everything else is covered:
| Source | Tool | How |
|---|---|---|
| iPhone / iPad / Mac | UxPlay | Wireless Display → AirPlay receiver, then pick the laptop in Screen Mirroring on the Apple device |
| Android / Samsung phone | scrcpy | Enable USB debugging, plug in once, Mirror phone. Wireless afterwards with scrcpy --tcpip |
| Samsung DeX-style desktop | scrcpy virtual display | DeX desktop runs scrcpy --new-display=1920x1080 --no-vd-system-decorations |
| Another Windows / Linux / Mac PC | Sunshine on that PC + Moonlight here | Other PC screen. Alternative: Deskreen on the other PC and open its URL in a browser here |
UxPlay firewall ports: 7000,7001,7100/tcp and 6000-6001,7011/udp.
5. Wi-Fi hotspot that coexists with your Wi-Fi connection
The problem
Starting a NetworkManager hotspot on the Wi-Fi interface replaces your current Wi-Fi connection: the laptop drops off the internet while hosting. The NetworkManager log says activated -> deactivating (reason 'new-activation').
The fix: a virtual AP interface on the same channel
Most Intel adapters allow one access point plus one client at the same time, as long as both sit on the same radio channel and run on separate interfaces. Check with:
iw phy | grep -A6 'valid interface combinations'
Look for a line like #{ managed } <= 2, #{ AP, P2P-client, P2P-GO } <= 1, ... #channels <= 1.
Set it up:
# 1. second (virtual) interface in AP mode
sudo iw dev wlp0s20f3 interface add ap0 type __ap
# 2. hotspot profile bound to ap0, shared IPv4 (NAT), trusted firewall zone
nmcli con add type wifi ifname ap0 con-name Display-Hotspot autoconnect no ssid ArchDisplay \
802-11-wireless.mode ap ipv4.method shared ipv6.method disabled \
wifi-sec.key-mgmt wpa-psk wifi-sec.psk 'YourPassword' connection.zone trusted
# 3. match the channel of your current Wi-Fi link, then start
ch=$(iw dev wlp0s20f3 info | awk '/channel/{print $2}')
band=$([ "$ch" -gt 14 ] && echo a || echo bg)
nmcli con mod Display-Hotspot 802-11-wireless.band $band 802-11-wireless.channel $ch
nmcli con up Display-Hotspot
Result on the test machine: home Wi-Fi on wlp0s20f3 (channel 149, 80 MHz) and the hotspot on ap0 (channel 149, 20 MHz), internet intact, guests get internet through NAT, laptop reachable at 10.42.0.1.
The kit’s launcher does steps 1 and 3 automatically every time you press Start, and the systemd unit wifi-ap0.service recreates ap0 at boot.
Firewall zone
The hotspot profile uses connection.zone trusted, so joined devices can reach AirPlay, scrcpy and Moonlight without extra rules. NetworkManager’s shared mode adds the NAT and DHCP (dnsmasq) itself.
Caveats
- The hotspot inherits your uplink’s band. On a 5 GHz home network some older devices or TVs will not see it. Connect the laptop to a 2.4 GHz network first if that happens.
- If your router changes channel while the hotspot runs, press Stop then Start to resync.
- Sending via Miracast while the hotspot is on may fail (both want the radio). Receiving is fine.
6. The launchers
Wireless Display
~/.local/bin/wireless-display [mode] — with no argument it opens a Qt window with six big icon buttons; with a mode it runs that mode directly (used by the right-click actions):
| Mode | Does |
|---|---|
cast | gnome-network-displays |
airplay | uxplay -n ArchLaptop in a Konsole window (close it to stop) |
phone | scrcpy in Konsole |
dex | scrcpy --new-display=1920x1080 --no-vd-system-decorations |
moonlight | moonlight |
hotspot | opens the Wi-Fi Hotspot window |
hotspot-start / hotspot-stop / hotspot-qr | headless hotspot actions with a kdialog popup |
Wi-Fi Hotspot
~/.local/bin/wifi-hotspot-gui — PyQt6 window:
- Status line (ON/OFF, IP, channel), refreshed every 3 s.
- QR code in the standard
WIFI:T:WPA;S:<ssid>;P:<psk>;;format; phones join by scanning it. - Hide QR / Show QR also masks the password, so the window is safe to project.
- Start / Stop (only the applicable one enabled).
- Change password… (8–63 chars; restarts the hotspot if it is running).
Both .desktop files include Actions= so the same functions appear on right-click in the Plasma task manager and app menu.
Pinning to the taskbar from a script
Plasma exposes its scripting API over D-Bus; this appends a launcher to every task manager:
qdbus6 org.kde.plasmashell /PlasmaShell org.kde.PlasmaShell.evaluateScript '
for (var p of panels()) for (var w of p.widgets()) {
if (w.type.indexOf("tasks") === -1) continue;
w.currentConfigGroup = ["General"];
var l = w.readConfig("launchers","").split(",").filter(function(s){return s;});
if (l.indexOf("applications:wifi-hotspot.desktop") === -1) l.push("applications:wifi-hotspot.desktop");
w.writeConfig("launchers", l.join(","));
}'
7. File layout
wireless-display-kit/
├── install.sh # one-shot installer
├── bin/
│ ├── wireless-display # bash dispatcher (modes + hotspot helpers)
│ ├── wireless-display-gui # PyQt6 icon-button window
│ └── wifi-hotspot-gui # PyQt6 hotspot window
├── applications/
│ ├── wireless-display.desktop
│ └── wifi-hotspot.desktop
├── systemd/
│ └── wifi-ap0.service # recreates the virtual AP interface at boot
└── LICENSE # MIT
__WIFI_IF__ and __HOME__ placeholders in the source files are filled in by install.sh.
8. Troubleshooting
| Symptom | Fix |
|---|---|
| TV never appears in Network Displays | Run gnome-network-displays from a terminal; check iw phy shows P2P modes; make sure firewalld loaded the P2P-WiFi-Display zone (firewall-cmd --get-zones) |
| “Failed to create avahi client” | sudo systemctl enable --now avahi-daemon |
| Chromecast not found | mdns service missing in your firewall zone, or different Wi-Fi network |
| Apple device does not see the laptop | UxPlay ports not open, or Avahi down |
| Hotspot start kicks you off Wi-Fi | Profile is bound to the main interface instead of ap0; run nmcli con mod Display-Hotspot connection.interface-name ap0 |
ap0 missing after reboot | systemctl status wifi-ap0.service |
| Guests have no internet | Check `nft list ruleset |
License
MIT. Use, copy, adapt.
The source code
The three main programs, as they are in the zip. __WIFI_IF__ and __HOME__ are filled in by install.sh.
Fixed before publishing (15 November 2026):
install.shstopped at the hotspot step on a first install: withset -o pipefail,tr … </dev/urandom | headends with SIGPIPE, which counts as a failure. The password is now made from a fixed number of random bytes.- The join QR code now escapes
\ ; , " :in the network name and password, as theWIFI:format requires, so a changed password with those characters still works when scanned. - The password and network name are escaped before they are shown in the Qt window and the kdialog popup.
- Stopping the hotspot from the right-click menu now shows an error if it fails.
bin/wireless-display
#!/usr/bin/env bash
# Wireless Display launcher: pick a mode or pass it as $1
set -u
WIFI_IF="${WIFI_IF:-__WIFI_IF__}" # main Wi-Fi interface (installer fills this in)
mode="${1:-}"
if [ -z "$mode" ]; then
exec "$HOME/.local/bin/wireless-display-gui"
fi
case "$mode" in
cast) exec gnome-network-displays ;;
airplay) exec konsole --title "AirPlay receiver (close window to stop)" -e uxplay -n ArchLaptop ;;
phone) exec konsole --title "scrcpy phone mirror" -e bash -c 'scrcpy || { echo; read -rp "scrcpy exited. Press Enter to close."; }' ;;
dex) exec konsole --title "scrcpy DeX desktop" -e bash -c 'scrcpy --new-display=1920x1080 --no-vd-system-decorations || { echo; read -rp "scrcpy exited. Press Enter to close."; }' ;;
moonlight) exec moonlight ;;
hotspot|hotspot-start|hotspot-stop|hotspot-qr)
con=Display-Hotspot
hs_on() { nmcli -t -f NAME con show --active | grep -qx "$con"; }
hs_qr() {
local ssid psk ip png
ssid=$(nmcli -g 802-11-wireless.ssid con show "$con")
psk=$(nmcli -s -g 802-11-wireless-security.psk con show "$con")
ip=$(nmcli -g IP4.ADDRESS con show "$con" 2>/dev/null | cut -d/ -f1)
png=$(mktemp --suffix=.png)
qe() { printf '%s' "$1" | sed 's/[\\;,":]/\\&/g'; } # escape for the WIFI: QR format
he() { printf '%s' "$1" | sed 's/&/\&/g; s/</\</g; s/>/\>/g'; } # escape for the dialog's HTML
qrencode -s 8 -m 2 -o "$png" "WIFI:T:WPA;S:$(qe "$ssid");P:$(qe "$psk");;"
kdialog --title "Hotspot: scan to join" --msgbox \
"<img src=\"file://$png\"><br><b>Network:</b> $(he "$ssid")<br><b>Password:</b> $(he "$psk")<br><b>Laptop IP:</b> ${ip:-not running}<br><b>Status:</b> $(hs_on && echo ON || echo OFF)" >/dev/null
rm -f "$png"
}
hs_start() {
hs_on && { kdialog --passivepopup "Hotspot already on" 3; return 0; }
iw dev ap0 info >/dev/null 2>&1 || pkexec iw dev "$WIFI_IF" interface add ap0 type __ap
local ch band
ch=$(iw dev "$WIFI_IF" info 2>/dev/null | awk '/channel/{print $2}')
if [ -n "$ch" ]; then
if [ "$ch" -gt 14 ]; then band=a; else band=bg; fi
else ch=6; band=bg; fi
nmcli con mod "$con" connection.interface-name ap0 802-11-wireless.band "$band" 802-11-wireless.channel "$ch"
if nmcli con up "$con" >/dev/null 2>&1; then kdialog --passivepopup "Hotspot ON (channel $ch)" 4; else kdialog --error "Could not start hotspot. Run: nmcli con up $con"; return 1; fi
}
hs_stop() {
hs_on || { kdialog --passivepopup "Hotspot already off" 3; return 0; }
if nmcli con down "$con" >/dev/null 2>&1; then kdialog --passivepopup "Hotspot OFF" 4; else kdialog --error "Could not stop hotspot. Run: nmcli con down $con"; return 1; fi
}
case "$mode" in
hotspot-start) hs_start ;;
hotspot-stop) hs_stop ;;
hotspot-qr) hs_qr ;;
hotspot) exec "$HOME/.local/bin/wifi-hotspot-gui" ;;
esac
;;
*) kdialog --error "Unknown mode: $mode"; exit 1 ;;
esac
bin/wireless-display-gui
#!/usr/bin/env python3
"""Wireless Display launcher: big icon buttons, one per mode."""
import os, subprocess, sys
from PyQt6.QtWidgets import QApplication, QWidget, QGridLayout, QToolButton, QLabel, QVBoxLayout
from PyQt6.QtGui import QIcon
from PyQt6.QtCore import Qt, QSize
SCRIPT = os.path.expanduser("~/.local/bin/wireless-display")
# (mode, label, icon theme name, tooltip)
MODES = [
("cast", "Cast to TV", "video-television", "Send this screen to a Miracast / Chromecast TV or projector"),
("airplay", "AirPlay receiver", "network-wireless", "Receive the screen of an iPhone, iPad or Mac"),
("phone", "Mirror phone", "phone", "Mirror an Android / Samsung phone (scrcpy, USB or Wi-Fi)"),
("dex", "DeX desktop", "computer", "Samsung DeX-style desktop from the phone"),
("moonlight", "Other PC screen", "input-gaming", "Use another PC's screen via Moonlight / Sunshine"),
("hotspot", "Wi-Fi hotspot", "network-wireless-hotspot", "Start / stop the hotspot, show the join QR code"),
]
class Win(QWidget):
def __init__(self):
super().__init__()
self.setWindowTitle("Wireless Display")
self.setWindowIcon(QIcon.fromTheme("video-display"))
lay = QVBoxLayout(self)
title = QLabel("What do you want to do?")
title.setAlignment(Qt.AlignmentFlag.AlignCenter)
title.setStyleSheet("font-size: 15px; font-weight: bold; margin: 4px;")
lay.addWidget(title)
grid = QGridLayout(); grid.setSpacing(10)
lay.addLayout(grid)
for i, (mode, label, icon, tip) in enumerate(MODES):
b = QToolButton()
b.setText(label); b.setToolTip(tip)
b.setIcon(QIcon.fromTheme(icon, QIcon.fromTheme("video-display")))
b.setIconSize(QSize(64, 64))
b.setToolButtonStyle(Qt.ToolButtonStyle.ToolButtonTextUnderIcon)
b.setFixedSize(150, 120)
b.setStyleSheet("QToolButton { font-size: 13px; border-radius: 10px; }")
b.clicked.connect(lambda _=False, m=mode: self.launch(m))
grid.addWidget(b, i // 3, i % 3)
self.setFixedSize(self.sizeHint())
def launch(self, mode):
subprocess.Popen([SCRIPT, mode], start_new_session=True,
stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
self.close()
if __name__ == "__main__":
app = QApplication(sys.argv)
if QIcon.fromTheme("computer").isNull():
QIcon.setThemeSearchPaths(QIcon.themeSearchPaths() + ["/usr/share/icons", os.path.expanduser("~/.local/share/icons")])
QIcon.setThemeName("breeze")
w = Win(); w.show()
sys.exit(app.exec())
bin/wifi-hotspot-gui
#!/usr/bin/env python3
"""Wi-Fi hotspot control window: QR (show/hide), start/stop, change password."""
import subprocess, tempfile, os, sys, re, html
from PyQt6.QtWidgets import (QApplication, QWidget, QVBoxLayout, QHBoxLayout, QLabel,
QPushButton, QInputDialog, QLineEdit, QMessageBox)
from PyQt6.QtGui import QPixmap, QIcon
from PyQt6.QtCore import Qt, QTimer
CON = "Display-Hotspot"
WIFI_IF = os.environ.get("WIFI_IF", "__WIFI_IF__") # installer fills this in
AP_IF = "ap0"
def run(*cmd, **kw):
return subprocess.run(cmd, text=True, capture_output=True, **kw)
def nm(*args):
return run("nmcli", "-t", *args).stdout.strip()
def is_on():
return CON in nm("-f", "NAME", "con", "show", "--active").splitlines()
def ssid(): return nm("-g", "802-11-wireless.ssid", "con", "show", CON)
def psk(): return run("nmcli", "-s", "-g", "802-11-wireless-security.psk", "con", "show", CON).stdout.strip()
def ip(): return nm("-g", "IP4.ADDRESS", "con", "show", CON).split("/")[0]
def channel():
for line in run("iw", "dev", WIFI_IF, "info").stdout.splitlines():
if "channel" in line:
return line.split()[1]
return ""
def start():
if is_on():
return True, "already on"
if run("iw", "dev", AP_IF, "info").returncode != 0:
r = run("pkexec", "iw", "dev", WIFI_IF, "interface", "add", AP_IF, "type", "__ap")
if r.returncode != 0:
return False, "Could not create virtual interface ap0:\n" + r.stderr
ch = channel()
if ch:
band = "a" if int(ch) > 14 else "bg"
else:
ch, band = "6", "bg"
run("nmcli", "con", "mod", CON, "connection.interface-name", AP_IF,
"802-11-wireless.band", band, "802-11-wireless.channel", ch)
r = run("nmcli", "con", "up", CON)
return r.returncode == 0, (f"Hotspot ON (channel {ch})" if r.returncode == 0 else r.stderr)
def stop():
if not is_on():
return True, "already off"
r = run("nmcli", "con", "down", CON)
return r.returncode == 0, ("Hotspot OFF" if r.returncode == 0 else r.stderr)
def set_password(new):
r = run("nmcli", "con", "mod", CON, "wifi-sec.psk", new)
if r.returncode != 0:
return False, r.stderr
if is_on():
stop(); start()
return True, "Password changed"
def qr_escape(s):
"""Escape \\ ; , " : for the WIFI: QR format."""
return re.sub(r'([\\;,":])', r'\\\1', s)
def qr_pixmap(text):
fd, png = tempfile.mkstemp(suffix=".png"); os.close(fd)
try:
run("qrencode", "-s", "7", "-m", "1", "-o", png, text)
return QPixmap(png)
finally:
os.unlink(png)
class Win(QWidget):
def __init__(self):
super().__init__()
self.setWindowTitle("Wi-Fi Hotspot")
self.setWindowIcon(QIcon.fromTheme("network-wireless-hotspot"))
lay = QVBoxLayout(self)
self.status = QLabel(); self.status.setAlignment(Qt.AlignmentFlag.AlignCenter)
self.status.setStyleSheet("font-size: 15px; font-weight: bold;")
lay.addWidget(self.status)
self.qr = QLabel(); self.qr.setAlignment(Qt.AlignmentFlag.AlignCenter)
lay.addWidget(self.qr)
self.info = QLabel(); self.info.setAlignment(Qt.AlignmentFlag.AlignCenter)
self.info.setTextInteractionFlags(Qt.TextInteractionFlag.TextSelectableByMouse)
lay.addWidget(self.info)
self.toggle = QPushButton("Hide QR")
self.toggle.setCheckable(True); self.toggle.setChecked(True)
self.toggle.toggled.connect(self.refresh)
lay.addWidget(self.toggle)
row = QHBoxLayout()
self.b_start = QPushButton(QIcon.fromTheme("media-playback-start"), "Start")
self.b_stop = QPushButton(QIcon.fromTheme("media-playback-stop"), "Stop")
self.b_start.clicked.connect(lambda: self.act(start))
self.b_stop.clicked.connect(lambda: self.act(stop))
row.addWidget(self.b_start); row.addWidget(self.b_stop)
lay.addLayout(row)
row2 = QHBoxLayout()
b_pw = QPushButton(QIcon.fromTheme("dialog-password"), "Change password…")
b_pw.clicked.connect(self.change_pw)
b_close = QPushButton(QIcon.fromTheme("window-close"), "Close")
b_close.clicked.connect(self.close)
row2.addWidget(b_pw); row2.addWidget(b_close)
lay.addLayout(row2)
self.msg = QLabel(""); self.msg.setAlignment(Qt.AlignmentFlag.AlignCenter)
self.msg.setStyleSheet("color: gray;")
lay.addWidget(self.msg)
self.refresh()
t = QTimer(self); t.timeout.connect(self.refresh); t.start(3000)
def act(self, fn):
self.setCursor(Qt.CursorShape.WaitCursor); QApplication.processEvents()
ok, text = fn()
self.unsetCursor()
self.msg.setText(text if ok else "")
if not ok:
QMessageBox.critical(self, "Hotspot", text)
self.refresh()
def change_pw(self):
new, ok = QInputDialog.getText(self, "Change hotspot password",
"New password (8–63 characters):", QLineEdit.EchoMode.Normal, psk())
if not ok:
return
if not 8 <= len(new) <= 63:
QMessageBox.warning(self, "Hotspot", "Password must be 8 to 63 characters.")
return
self.act(lambda: set_password(new))
def refresh(self):
on = is_on()
s, p = ssid(), psk()
self.status.setText(f"● Hotspot is {'ON' if on else 'OFF'}")
self.status.setStyleSheet("font-size: 15px; font-weight: bold; color: %s;" % ("#2e9e3f" if on else "#999"))
show = self.toggle.isChecked()
self.toggle.setText("Hide QR" if show else "Show QR")
self.qr.setVisible(show)
if show:
self.qr.setPixmap(qr_pixmap(f"WIFI:T:WPA;S:{qr_escape(s)};P:{qr_escape(p)};;"))
pw_txt = html.escape(p) if show else "•" * len(p)
extra = f"<br>Laptop IP: {ip()} Channel: {channel()}" if on else ""
self.info.setText(f"<b>Network:</b> {html.escape(s)}<br><b>Password:</b> {pw_txt}{extra}")
self.b_start.setEnabled(not on); self.b_stop.setEnabled(on)
self.adjustSize()
if __name__ == "__main__":
app = QApplication(sys.argv)
if QIcon.fromTheme("computer").isNull():
QIcon.setThemeSearchPaths(QIcon.themeSearchPaths() + ["/usr/share/icons", os.path.expanduser("~/.local/share/icons")])
QIcon.setThemeName("breeze")
w = Win(); w.show()
sys.exit(app.exec())