bazzite/spec_files/jupiter-hw-support/priv-write.patch

70 lines
2.1 KiB
Diff

diff --git a/usr/bin/steamos-polkit-helpers/steamos-priv-write b/usr/bin/steamos-polkit-helpers/steamos-priv-write
index 296996e..ae0ae3e 100755
--- a/usr/bin/steamos-polkit-helpers/steamos-priv-write
+++ b/usr/bin/steamos-polkit-helpers/steamos-priv-write
@@ -2,6 +2,9 @@
set -eu
+source /etc/default/steam-hardware-control
+SYS_ID="$(cat /sys/devices/virtual/dmi/id/product_name)"
+
if [[ $EUID -ne 0 ]];
then
exec pkexec --disable-internal-agent "$0" "$@"
@@ -12,21 +15,25 @@
function CommitWrite()
{
- if [ ! -z "$WRITE_VALUE" ]
- then
- echo "commit: $WRITE_VALUE -> $WRITE_PATH" | systemd-cat -t p-steamos-priv-write -p warning
- echo "$WRITE_VALUE" > "$WRITE_PATH"
+ if [[ ":Jupiter:" =~ ":$SYS_ID:" || ":Galileo:" =~ ":$SYS_ID:" || "$ENABLE_HARDWARE_CONTROL_ON_NON_DECK_HARDWARE" = 1 ]]; then
+ if [ ! -z "$WRITE_VALUE" ]
+ then
+ echo "commit: $WRITE_VALUE -> $WRITE_PATH" | systemd-cat -t p-steamos-priv-write -p warning
+ chmod a+w "$WRITE_PATH"
+ echo "$WRITE_VALUE" > "$WRITE_PATH"
+ fi
+
+ echo "chmod a+w: $WRITE_PATH" | systemd-cat -t p-steamos-priv-write -p warning
+ else
+ echo "commit: Skipped - see /etc/default/steam-hardware-control" | systemd-cat -t p-steamos-priv-write -p warning
fi
- chmod a+w "$WRITE_PATH"
- echo "chmod a+w: $WRITE_PATH" | systemd-cat -t p-steamos-priv-write -p warning
exit 0
}
function DeclineWrite()
{
echo "decline: $WRITE_VALUE -> $WRITE_PATH" | systemd-cat -t p-steamos-priv-write -p err
- echo "$WRITE_VALUE" > "$WRITE_PATH"
exit 1
}
@@ -40,11 +47,19 @@
fi
if [[ "$WRITE_PATH" == /sys/class/drm/card*/device/power_dpm_force_performance_level ]]; then
- CommitWrite
+ for i in $(ls /sys/class/drm/card*/device/power_dpm_force_performance_level)
+ do
+ WRITE_PATH="$i"
+ CommitWrite
+ done
fi
if [[ "$WRITE_PATH" == /sys/class/drm/card*/device/pp_od_clk_voltage ]]; then
- CommitWrite
+ for i in $(ls /sys/class/drm/card*/device/pp_od_clk_voltage)
+ do
+ WRITE_PATH="$i"
+ CommitWrite
+ done
fi
if [[ "$WRITE_PATH" == /sys/class/hwmon/hwmon*/power*_cap ]]; then