@@ -7,96 +7,112 @@ ORIGINAL_SCRIPT_ARGS=("$@")
77SPICE_DIR=" /var/run/omarchy-windows" # SPICE socket directory (tmpfs, auto-cleaned on reboot)
88SPICE_SOCKET_PATH=" $SPICE_DIR /spice.sock" # SPICE Unix socket
99
10+ msg_error () {
11+ echo " ❌ Error: $* "
12+ }
13+
14+ msg_warning () {
15+ echo " ⚠️ Warning: $* "
16+ }
17+
18+ msg_success () {
19+ echo " ✓ $* "
20+ }
21+
22+ msg_info () {
23+ echo " ℹ️ $* "
24+ }
25+
1026echo " Installing Looking Glass B7..."
1127echo " Ultra-low latency VM display as an alternative to RDP."
1228echo " "
1329
1430# Request sudo access upfront (avoids password prompt during compilation)
1531if ! sudo -v 2> /dev/null; then
16- echo " ❌ sudo access required for installation"
32+ msg_error " sudo access required for installation"
1733 exit 1
1834fi
1935
2036# Install kernel headers (required for DKMS)
21- echo " Installing kernel headers..."
37+ msg_info " Installing kernel headers..."
2238KERNEL=$( uname -r)
2339
2440# Validate kernel modules directory exists
2541if [[ ! -d " /lib/modules/$KERNEL " ]]; then
26- echo " ⚠️ Kernel modules directory not found, using default kernel package"
42+ msg_warning " Kernel modules directory not found, using default kernel package"
2743 KERNEL_PACKAGE=" linux"
2844else
2945 KERNEL_PACKAGE=$( pacman -Qo " /lib/modules/$KERNEL " 2> /dev/null | sed -n ' s/.* is owned by \([^ ]*\) .*/\1/p' | head -1)
3046
3147 if [[ -z " $KERNEL_PACKAGE " ]]; then
32- echo " ⚠️ Could not detect kernel package, defaulting to linux"
48+ msg_warning " Could not detect kernel package, defaulting to linux"
3349 KERNEL_PACKAGE=" linux"
3450 fi
3551fi
3652
3753if [[ " $KERNEL_PACKAGE " == " linux" ]]; then
3854 if ! omarchy-pkg-add linux-headers; then
39- echo " ❌ Failed to install linux-headers"
55+ msg_error " Failed to install linux-headers"
4056 exit 1
4157 fi
4258elif [[ " $KERNEL_PACKAGE " == " linux-lts" ]]; then
4359 if ! omarchy-pkg-add linux-lts-headers; then
44- echo " ❌ Failed to install linux-lts-headers"
60+ msg_error " Failed to install linux-lts-headers"
4561 exit 1
4662 fi
4763elif [[ " $KERNEL_PACKAGE " == " linux-zen" ]]; then
4864 if ! omarchy-pkg-add linux-zen-headers; then
49- echo " ❌ Failed to install linux-zen-headers"
65+ msg_error " Failed to install linux-zen-headers"
5066 exit 1
5167 fi
5268else
53- echo " ⚠️ Unknown kernel package: $KERNEL_PACKAGE , installing linux-headers"
69+ msg_warning " Unknown kernel package: $KERNEL_PACKAGE , installing linux-headers"
5470 if ! omarchy-pkg-add linux-headers; then
55- echo " ❌ Failed to install linux-headers"
71+ msg_error " Failed to install linux-headers"
5672 exit 1
5773 fi
5874fi
59- echo " ✓ Kernel headers installed"
75+ msg_success " Kernel headers installed"
6076
6177# Install packages from AUR (yay is pre-installed in Omarchy)
6278if pacman -Q looking-glass looking-glass-module-dkms & > /dev/null; then
63- echo " ✓ Looking Glass packages already installed"
79+ msg_success " Looking Glass packages already installed"
6480else
65- echo " Installing packages (looking-glass, looking-glass-module-dkms)..."
81+ msg_info " Installing packages (looking-glass, looking-glass-module-dkms)..."
6682 echo " This may take a few minutes (downloading and compiling)..."
6783 echo " "
6884 if ! yay -S --noconfirm --needed looking-glass looking-glass-module-dkms; then
6985 echo " "
70- echo " ❌ Failed to install Looking Glass packages"
86+ msg_error " Failed to install Looking Glass packages"
7187 echo " Please check the errors above and try again"
7288 exit 1
7389 fi
7490 echo " "
75- echo " ✓ Packages installed"
91+ msg_success " Packages installed"
7692fi
7793
7894# Configure udev rules
79- echo " Configuring udev rules..."
95+ msg_info " Configuring udev rules..."
8096sudo tee /etc/udev/rules.d/99-kvmfr.rules > /dev/null << 'EOF '
8197SUBSYSTEM=="kvmfr", OWNER="root", GROUP="kvm", MODE="0660"
8298EOF
8399
84100if ! sudo udevadm control --reload-rules 2> /dev/null; then
85- echo " ⚠️ Failed to reload udev rules (non-fatal)"
101+ msg_warning " Failed to reload udev rules (non-fatal)"
86102fi
87103
88104if ! sudo udevadm trigger 2> /dev/null; then
89- echo " ⚠️ Failed to trigger udev (non-fatal)"
105+ msg_warning " Failed to trigger udev (non-fatal)"
90106fi
91107
92- echo " ✓ Udev rules configured"
108+ msg_success " Udev rules configured"
93109
94110# Configure kernel module size (interactive resolution selection)
95111# Check if already configured (unless FORCE_RECONFIGURE=1 to allow changing size)
96112if [[ " ${FORCE_RECONFIGURE:- 0} " != " 1" ]] && [[ -f /etc/modprobe.d/kvmfr.conf ]]; then
97113 IVSHMEM_SIZE=$( grep -oP ' static_size_mb=\K\d+' /etc/modprobe.d/kvmfr.conf 2> /dev/null || echo " " )
98114 if [[ -n " $IVSHMEM_SIZE " ]]; then
99- echo " ✓ Kernel module already configured (${IVSHMEM_SIZE} MB)"
115+ msg_success " Kernel module already configured (${IVSHMEM_SIZE} MB)"
100116 else
101117 # Config file exists but malformed - remove and reconfigure
102118 sudo rm -f /etc/modprobe.d/kvmfr.conf
@@ -141,41 +157,41 @@ if [[ -z "$IVSHMEM_SIZE" ]] || [[ "${FORCE_RECONFIGURE:-0}" == "1" ]]; then
141157
142158 # Validate IVSHMEM_SIZE before use (security check)
143159 if ! [[ " $IVSHMEM_SIZE " =~ ^[0-9]+$ ]] || [[ " $IVSHMEM_SIZE " -lt 32 ]] || [[ " $IVSHMEM_SIZE " -gt 512 ]]; then
144- echo " ❌ Invalid IVSHMEM_SIZE: $IVSHMEM_SIZE (must be 32-512)"
160+ msg_error " Invalid IVSHMEM_SIZE: $IVSHMEM_SIZE (must be 32-512)"
145161 exit 1
146162 fi
147163
148- echo " Configuring kernel module size..."
164+ msg_info " Configuring kernel module size..."
149165 sudo tee /etc/modprobe.d/kvmfr.conf > /dev/null << EOF
150166options kvmfr static_size_mb=$IVSHMEM_SIZE
151167EOF
152- echo " ✓ Kernel module size configured (${IVSHMEM_SIZE} MB)"
168+ msg_success " Kernel module size configured (${IVSHMEM_SIZE} MB)"
153169fi
154170
155171# Configure kernel module auto-load (after modprobe.d to ensure consistency)
156172if [[ ! -f /etc/modules-load.d/kvmfr.conf ]]; then
157- echo " Configuring kernel module auto-load..."
173+ msg_info " Configuring kernel module auto-load..."
158174 echo " kvmfr" | sudo tee /etc/modules-load.d/kvmfr.conf > /dev/null
159- echo " ✓ Kernel module auto-load configured"
175+ msg_success " Kernel module auto-load configured"
160176fi
161177
162178# Add user to kvm group
163- echo " Checking kvm group..."
179+ msg_info " Checking kvm group..."
164180ADDED_TO_KVM=false
165181if ! groups " $USER " | grep -q kvm; then
166182 sudo usermod -aG kvm " $USER "
167- echo " ✓ Added to kvm group"
183+ msg_success " Added to kvm group"
168184 ADDED_TO_KVM=true
169185
170186 # Auto-refresh group membership using sg to avoid logout/login
171187 echo " Refreshing group membership for current session..."
172188 exec sg kvm " $0 " " ${ORIGINAL_SCRIPT_ARGS[@]} "
173189else
174- echo " ✓ Already in kvm group"
190+ msg_success " Already in kvm group"
175191fi
176192
177193# Create client configuration
178- echo " Creating client configuration..."
194+ msg_info " Creating client configuration..."
179195mkdir -p ~ /.config/looking-glass
180196cat > ~/.config/looking-glass/client.ini << EOF
181197[app]
@@ -209,10 +225,10 @@ bufferLatency=5
209225micDefault=allow
210226micShowIndicator=no
211227EOF
212- echo " ✓ Configuration created with SPICE support (~/.config/looking-glass/client.ini)"
228+ msg_success " Configuration created with SPICE support (~/.config/looking-glass/client.ini)"
213229
214230# Install desktop file for Walker launcher
215- echo " Installing desktop launcher..."
231+ msg_info " Installing desktop launcher..."
216232mkdir -p " $HOME /.local/share/applications"
217233
218234# Try to find OMARCHY_PATH if not set
226242
227243if [[ -n " $OMARCHY_PATH " ]] && [[ -f " $OMARCHY_PATH /applications/windows-looking-glass.desktop" ]]; then
228244 cp " $OMARCHY_PATH /applications/windows-looking-glass.desktop" " $HOME /.local/share/applications/"
229- echo " ✓ Desktop launcher installed (Windows [Looking Glass])"
245+ msg_success " Desktop launcher installed (Windows [Looking Glass])"
230246else
231- echo " ⚠️ Desktop file not found - creating basic launcher"
247+ msg_warning " Desktop file not found - creating basic launcher"
232248 cat > " $HOME /.local/share/applications/windows-looking-glass.desktop" << 'DESKEOF '
233249[Desktop Entry]
234250Name=Windows [Looking Glass]
@@ -238,20 +254,20 @@ Terminal=false
238254Type=Application
239255Categories=System;Virtualization;
240256DESKEOF
241- echo " ✓ Basic desktop launcher created"
257+ msg_success " Basic desktop launcher created"
242258fi
243259
244260# Load kernel module (reload if already loaded to apply new configuration)
245- echo " Loading kvmfr module..."
261+ msg_info " Loading kvmfr module..."
246262if lsmod | grep -q kvmfr; then
247263 # Module already loaded - check if device exists with correct size
248264 if [[ ! -e /dev/kvmfr0 ]]; then
249265 echo " Module loaded but /dev/kvmfr0 missing - reloading with new config..."
250266 sudo rmmod kvmfr 2> /dev/null || true
251267 if sudo modprobe kvmfr; then
252- echo " ✓ Module reloaded"
268+ msg_success " Module reloaded"
253269 else
254- echo " ⚠️ Module reload failed (reboot required)"
270+ msg_warning " Module reload failed (reboot required)"
255271 fi
256272 else
257273 # Device exists - verify via modinfo instead of unreliable dmesg parsing
@@ -261,20 +277,20 @@ if lsmod | grep -q kvmfr; then
261277 echo " Module loaded with wrong size (${module_size} MB, expected ${IVSHMEM_SIZE} MB) - reloading..."
262278 sudo rmmod kvmfr 2> /dev/null || true
263279 if sudo modprobe kvmfr; then
264- echo " ✓ Module reloaded with ${IVSHMEM_SIZE} MB"
280+ msg_success " Module reloaded with ${IVSHMEM_SIZE} MB"
265281 else
266- echo " ⚠️ Module reload failed (reboot required)"
282+ msg_warning " Module reload failed (reboot required)"
267283 fi
268284 else
269- echo " ✓ Module already loaded (${IVSHMEM_SIZE} MB)"
285+ msg_success " Module already loaded (${IVSHMEM_SIZE} MB)"
270286 fi
271287 fi
272288else
273289 # Module not loaded - load it
274290 if sudo modprobe kvmfr; then
275- echo " ✓ Module loaded"
291+ msg_success " Module loaded"
276292 else
277- echo " ⚠️ Module load failed (reboot required)"
293+ msg_warning " Module load failed (reboot required)"
278294 fi
279295fi
280296
295311# Note: No need to check kvm group here - we already refreshed it with sg if needed
296312
297313if [[ " $NEEDS_REBOOT " == true ]]; then
298- echo " ⚠️ Reboot required for:"
314+ msg_warning " Reboot required for:"
299315 echo " $REBOOT_REASONS "
300316 echo " "
301317 echo " After reboot, enable Looking Glass during Windows VM installation:"
302318 echo " omarchy-windows-vm install"
303319 echo " "
304320else
305- echo " ✓ Looking Glass client ready!"
321+ msg_success " Looking Glass client ready!"
306322 echo " "
307323 echo " Next step: Install Windows VM with Looking Glass support"
308324 echo " omarchy-windows-vm install"
0 commit comments