Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 3 additions & 11 deletions bin/omarchy-hw-hybrid-gpu
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,11 @@

# omarchy:summary=Detect whether the system has an active hybrid GPU configuration

# Count display controllers (PCI class 0x03) from the cached sysfs IDs rather
# than lspci, which reads PCI config space and resumes a runtime-suspended
# dGPU -- on every menu open, since the menu's Hybrid GPU row asks this.
pci_devices_path="${OMARCHY_PCI_DEVICES_PATH:-/sys/bus/pci/devices}"
export OMARCHY_PATH="${OMARCHY_PATH:-/usr/share/omarchy}"
source "$OMARCHY_PATH/install/helpers/pci-sysfs.sh"

multiple_gpus() {
local device class count=0

for device in "$pci_devices_path"/*; do
[[ -r $device/class ]] && read -r class <"$device/class" && [[ $class == 0x03* ]] && ((count += 1))
done

((count >= 2))
(( $(omarchy-pci-class-count 0x03) >= 2 ))
Comment thread
greptile-apps[bot] marked this conversation as resolved.
Resolved
}

if omarchy-cmd-present supergfxctl; then
Expand Down
14 changes: 3 additions & 11 deletions bin/omarchy-hw-nvidia
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,7 @@

# omarchy:summary=Detect whether the computer has an NVIDIA GPU.

# Read the cached sysfs IDs rather than lspci, which reads PCI config space and
# resumes runtime-suspended GPUs.
pci_devices_path="${OMARCHY_PCI_DEVICES_PATH:-/sys/bus/pci/devices}"
export OMARCHY_PATH="${OMARCHY_PATH:-/usr/share/omarchy}"
source "$OMARCHY_PATH/install/helpers/pci-sysfs.sh"
Comment thread
neheb marked this conversation as resolved.
Resolved

shopt -s nullglob

for device in "$pci_devices_path"/*; do
[[ $(< "$device/vendor") == "0x10de" ]] || continue
[[ $(< "$device/class") == 0x03* ]] && exit 0
done

exit 1
omarchy-pci-class-vendor 0x03 0x10de
9 changes: 6 additions & 3 deletions bin/omarchy-install-gaming-gpu-lib32
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,19 @@ set -e
# x86_64. aarch64 runs Valve's native arm64 Steam client and needs none.
omarchy-hw-x86 || exit 0

export OMARCHY_PATH="${OMARCHY_PATH:-/usr/share/omarchy}"
source "$OMARCHY_PATH/install/helpers/pci-sysfs.sh"

echo "Installing lib32 graphics drivers..."

PACKAGES=()

declare -A VULKAN_DRIVERS=(
[Intel]=lib32-vulkan-intel
[AMD]=lib32-vulkan-radeon
[0x8086]=lib32-vulkan-intel
[0x1002]=lib32-vulkan-radeon
)
for vendor in "${!VULKAN_DRIVERS[@]}"; do
if lspci | grep -iE "(VGA|Display).*$vendor" >/dev/null; then
if omarchy-pci-class-vendor 0x03 "$vendor"; then
PACKAGES+=("${VULKAN_DRIVERS[$vendor]}")
fi
done
Expand Down
6 changes: 4 additions & 2 deletions install/hardware/apple/fix-brcmfmac-supplicant.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,13 @@ if omarchy-hw-aarch64-apple; then
return 0
fi

source "$OMARCHY_PATH/install/helpers/pci-sysfs.sh"

sys_vendor="$(cat /sys/class/dmi/id/sys_vendor 2>/dev/null || true)"

if lspci -nn | grep "106b:180[12]" >/dev/null ||
if omarchy-pci-id 0x106b 0x1801 0x1802 ||
{ [[ $sys_vendor == Apple* ]] &&
lspci -nn | grep -E "14e4:(43ba|43bb|43bc|43a3|43dc|4464|4488|4425|4433)" >/dev/null; }; then
omarchy-pci-id 0x14e4 0x43ba 0x43bb 0x43bc 0x43a3 0x43dc 0x4464 0x4488 0x4425 0x4433; }; then
echo "Detected a Mac with Broadcom Wi-Fi; running the WPA handshake in software"

mkdir -p /etc/modprobe.d
Expand Down
4 changes: 3 additions & 1 deletion install/hardware/apple/fix-t2.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# Detect T2 MacBook models using PCI IDs
# Vendor: 106b (Apple), Device IDs: 1801 or 1802 (T2 Security Chip)
if lspci -nn | grep "106b:180[12]" >/dev/null; then
source "$OMARCHY_PATH/install/helpers/pci-sysfs.sh"

if omarchy-pci-id 0x106b 0x1801 0x1802; then
echo "Detected MacBook with T2 chip. Installing support items..."

# apple-bcm-firmware-fetcher reads its firmware off an on-disk macOS volume —
Expand Down
4 changes: 2 additions & 2 deletions install/hardware/fix-bcm43xx.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
# - BCM4360 (2013–2015 MacBooks)
# - BCM4331 (2012, early 2013 MacBooks)

pci_info=$(lspci -nn)
source "$OMARCHY_PATH/install/helpers/pci-sysfs.sh"

if (echo "$pci_info" | grep -q "14e4:43a0" || echo "$pci_info" | grep -q "14e4:4331"); then
if omarchy-pci-id 0x14e4 0x43a0 0x4331; then
echo "BCM4360 / BCM4331 detected"
omarchy-pkg-add broadcom-wl-dkms
fi
4 changes: 3 additions & 1 deletion install/hardware/intel/fix-wifi7-eht.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@
# back to WiFi 6 (HE/802.11ax) which works at full speed.
# This should be removed when Intel fixes the firmware/driver.

if lspci -nn | grep -qE '\[8086:(e440|272b)\]'; then
source "$OMARCHY_PATH/install/helpers/pci-sysfs.sh"

if omarchy-pci-id 0x8086 0xe440 0x272b; then
mkdir -p /etc/modprobe.d
cat > /etc/modprobe.d/iwlwifi-disable-eht.conf <<'EOF'
# Temporary fix Dell XPS 14/16 on Panther lake
Expand Down
2 changes: 1 addition & 1 deletion install/hardware/nvidia.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# system firmware and on the DKMS build, and there are no 32-bit libraries.
if omarchy-hw-aarch64-n1x; then
echo "NVIDIA N1x platform detected; GPU driver policy is owned by hardware/n1x.sh"
elif lspci | grep -qi 'nvidia'; then
elif omarchy-hw-nvidia; then
# The 32-bit libraries come from multilib, which only x86_64 has.
if omarchy-hw-nvidia-gsp; then
PACKAGES=(nvidia-open-dkms nvidia-utils)
Expand Down
4 changes: 3 additions & 1 deletion install/hardware/pacman.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# Hardware-specific pacman repository extensions that must survive the final
# pacman.conf restore.
if lspci -nn | grep "106b:180[12]" >/dev/null; then
source "$OMARCHY_PATH/install/helpers/pci-sysfs.sh"

if omarchy-pci-id 0x106b 0x1801 0x1802; then
if ! grep -q '^\[arch-mact2\]' /etc/pacman.conf; then
cat >> /etc/pacman.conf <<'EOF'

Expand Down
10 changes: 6 additions & 4 deletions install/hardware/vulkan.sh
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
# Install Vulkan drivers matching detected GPU hardware
# (NVIDIA Vulkan is handled by nvidia.sh via nvidia-utils)

source "$OMARCHY_PATH/install/helpers/pci-sysfs.sh"

declare -A VULKAN_DRIVERS=(
[Intel]=vulkan-intel
[AMD]=vulkan-radeon
[Apple]=vulkan-asahi
[0x8086]=vulkan-intel
[0x1002]=vulkan-radeon
[0x106b]=vulkan-asahi
)

PACKAGES=()

for vendor in "${!VULKAN_DRIVERS[@]}"; do
if lspci | grep -iE "(VGA|Display).*$vendor" > /dev/null; then
if omarchy-pci-class-vendor 0x03 "$vendor"; then
PACKAGES+=("${VULKAN_DRIVERS[$vendor]}")
fi
done
Expand Down
69 changes: 69 additions & 0 deletions install/helpers/pci-sysfs.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
# Detect PCI devices from cached sysfs fields instead of lspci.
#
# lspci reads PCI config space, and the kernel resumes a runtime-suspended
# device to serve that read. On a hybrid laptop the discrete GPU idles in
# D3cold, so a bare lspci can take over a second waking it. The vendor, device,
# class, and subsystem IDs are served from cached sysfs fields that never touch
# config space, so nothing wakes.
#
# Each matcher walks /sys/bus/pci/devices once and returns 0 on the first match.
# Tests point OMARCHY_PCI_DEVICES_PATH at a fixture tree of the same layout.

# Point the helpers at a fixture tree instead of the real sysfs in tests.
: "${OMARCHY_PCI_DEVICES_PATH:=/sys/bus/pci/devices}"

# Each matcher walks the devices dir once and returns 0 on the first match.
shopt -s nullglob

# First argument is a vendor ID; the remaining arguments are device IDs for that
# vendor to accept. Returns 0 if any device carries both.
omarchy-pci-id() {
local vendor="$1"
shift
local device id
for device in "$OMARCHY_PCI_DEVICES_PATH"/*; do
[[ $(<"$device/vendor") == "$vendor" ]] || continue
for id in "$@"; do
[[ $(<"$device/device") == "$id" ]] && return 0
done
done
return 1
}

# First argument is a class prefix (e.g. 0x03 for a display controller); the
# second is a vendor ID. Returns 0 if any device's class begins with the prefix
# and its vendor matches.
omarchy-pci-class-vendor() {
local class="$1" vendor="$2"
local device
for device in "$OMARCHY_PCI_DEVICES_PATH"/*; do
[[ $(<"$device/class") == "${class}"* && $(<"$device/vendor") == "$vendor" ]] && return 0
done
return 1
}

# First argument is a class prefix. Prints how many devices have a class that
# begins with it, regardless of vendor; for aggregation and count checks where
# a boolean matcher is not enough.
omarchy-pci-class-count() {
local class="$1"
local device
local count=0
for device in "$OMARCHY_PCI_DEVICES_PATH"/*; do
[[ $(<"$device/class") == "${class}"* ]] && count=$((count + 1))
done
printf '%s\n' "$count"
}

# Returns 0 if any device is bound to the named driver, read from the bound
# driver symlink.
omarchy-pci-driver() {
local driver="$1"
local device bound
for device in "$OMARCHY_PCI_DEVICES_PATH"/*; do
[[ -L $device/driver ]] || continue
bound="$(readlink "$device/driver")"
[[ ${bound##*/} == "$driver" ]] && return 0
done
return 1
}
6 changes: 3 additions & 3 deletions install/user/hardware/fix-nouveau-cursor.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@
# older NVIDIA GPUs, leaving the mouse pointer invisible under Hyprland.
# Skip the fix when the proprietary driver was configured: supported GPUs can
# still use nouveau during installation before switching drivers on reboot.
source "$OMARCHY_PATH/install/helpers/pci-sysfs.sh"

nvidia_config="${OMARCHY_NVIDIA_MODPROBE_CONFIG:-/etc/modprobe.d/nvidia.conf}"

if [[ ! -f $nvidia_config ]] &&
omarchy-cmd-present lspci &&
LC_ALL=C lspci -k | grep -qi 'Kernel driver in use: nouveau'; then
if [[ ! -f $nvidia_config ]] && omarchy-pci-driver nouveau; then
Comment on lines +7 to +11

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Hardware tests lose their fixtures

nouveau-cursor-test.sh and brcmfmac-supplicant-test.sh still fake lspci, which these scripts no longer call. Neither test supplies OMARCHY_PATH or OMARCHY_PCI_DEVICES_PATH. In a clean environment, sourcing the helper fails. Setting OMARCHY_PATH alone still makes the tests read the host's hardware instead of their fake devices.

Update both tests to supply the helper path and PCI fixtures, including driver links for the cursor test.

looknfeel="$HOME/.config/hypr/looknfeel.lua"

if [[ -f $looknfeel ]] && ! grep -q 'no_hardware_cursors' "$looknfeel"; then
Expand Down