Repository navigation
Avoid lspci in favor of sysfs #11259
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: quattro
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| 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 | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
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 | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.