Skip to content

Commit a631435

Browse files
committed
Below:
* Fix: Undervolt Go GUI not working due to missing access to XAUTHORITY in PolicyKit policy * Remove some of the dependencies in go.yml GitHub Actions Workflow, that are not needed for GUI build
1 parent f9583ce commit a631435

File tree

2 files changed

+39
-3
lines changed

2 files changed

+39
-3
lines changed

.github/workflows/go.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ jobs:
3838
- name: Prepare dependencies
3939
run: |
4040
sudo apt update
41-
sudo apt install build-essential pkg-config libgl1-mesa-dev libglu1-mesa-dev freeglut3-dev mesa-common-dev xorg-dev
41+
sudo apt install build-essential pkg-config libgl1-mesa-dev mesa-common-dev xorg-dev # add 'libglu1-mesa-dev freeglut3-dev' if needed
4242
go mod tidy # Ensures all required dependencies are installed
4343
echo "All required dependencies are installed"
4444
- name: Build undervolt-go

dist/script/gui/install-undervolt.sh

Lines changed: 38 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,38 @@ WRAPPER_PATH="/usr/bin/undervolt-go-wrapper"
2222
echo "Creating pkexec wrapper at ${WRAPPER_PATH}..."
2323
cat <<EOF > "${WRAPPER_PATH}"
2424
#!/bin/bash
25-
export DISPLAY=:0
26-
export XAUTHORITY=/home/\${SUDO_USER}/.Xauthority
25+
# Determine the user who initiated the pkexec action
26+
if [ -n "$PKEXEC_UID" ]; then
27+
USER=$(id -un "$PKEXEC_UID")
28+
elif [ -n "$SUDO_USER" ]; then
29+
USER="$SUDO_USER"
30+
else
31+
echo "Error: Could not determine the user. PKEXEC_UID and SUDO_USER are unset." >&2
32+
exit 1
33+
fi
34+
# Check if the user was found
35+
if [ -z "$USER" ]; then
36+
echo "Error: Could not determine the user." >&2
37+
exit 1
38+
fi
39+
# Get the user's home directory
40+
USER_HOME=$(eval echo "~${USER}")
41+
# Set up the display environment
42+
if [ -z "$DISPLAY" ]; then
43+
export DISPLAY=:0 # Fallback to :0 if DISPLAY is not set
44+
fi
45+
# Set up Xauthority
46+
if [ -f "${USER_HOME}/.Xauthority" ]; then
47+
export XAUTHORITY="${USER_HOME}/.Xauthority"
48+
else
49+
echo "Warning: .Xauthority file not found for user ${USER}." >&2
50+
fi
51+
# Debugging: Log environment variables
52+
echo "Launching undervolt-go-pro with DISPLAY=$DISPLAY, XAUTHORITY=$XAUTHORITY, USER=$USER" >&2
53+
# Execute the binary
2754
exec ${INSTALL_PATH}
2855
EOF
56+
2957
chmod +x "${WRAPPER_PATH}"
3058

3159
# Install icon (optional: replace with your own icon)
@@ -42,6 +70,8 @@ echo "Creating PolicyKit policy at ${POLKIT_FILE}..."
4270
cat <<EOF > "${POLKIT_FILE}"
4371
<?xml version="1.0" encoding="UTF-8"?>
4472
<policyconfig>
73+
<vendor>Softorage</vendor>
74+
<vendor_url>https://softorage.com</vendor_url>
4575
<action id="com.softorage.undervolt-go">
4676
<description>Run 'Undervolt Go' as root</description>
4777
<message>Authentication is required to run 'Undervolt Go'</message>
@@ -51,10 +81,16 @@ cat <<EOF > "${POLKIT_FILE}"
5181
<allow_inactive>auth_admin</allow_inactive>
5282
<allow_active>auth_admin</allow_active>
5383
</defaults>
84+
<annotate key="org.freedesktop.policykit.exec.path">/usr/bin/undervolt-go-wrapper</annotate>
85+
<annotate key="org.freedesktop.policykit.exec.allow_gui">true</annotate>
86+
<annotate key="org.freedesktop.policykit.exec.environment">DISPLAY XAUTHORITY</annotate>
5487
</action>
5588
</policyconfig>
5689
EOF
5790

91+
# set file permissions, allowing the owner read and write access, while group and others have only read access
92+
chmod 644 /usr/share/polkit-1/actions/com.softorage.undervolt-go.policy
93+
5894
# Install desktop file
5995
DESKTOP_FILE="/usr/share/applications/undervolt-go.desktop"
6096
echo "Creating desktop shortcut at ${DESKTOP_FILE}..."

0 commit comments

Comments
 (0)