Skip to content

Commit

Permalink
pci-latency: Replace sudo with root checks
Browse files Browse the repository at this point in the history
This speeds up startup of the systemd service from 40ms -> 18ms
  • Loading branch information
ventureoo committed Jun 18, 2024
1 parent 56a7145 commit d4862de
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions usr/bin/pci-latency
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,15 @@
# devices, which can help prevent devices with high default latency timers from
# causing gaps in sound.

sudo -s -- <<EOF
# Check if the script is run with root privileges
if [ "$(id -u)" -ne 0 ]; then
echo "Error: This script must be run with root privileges."
exit 1
fi

# Reset the latency timer for all PCI devices
setpci -v -s '*:*' latency_timer=20
setpci -v -s '0:0' latency_timer=0

# Set latency timer for all sound cards
setpci -v -d "*:*:04xx" latency_timer=80
EOF

0 comments on commit d4862de

Please sign in to comment.