Skip to content
This repository was archived by the owner on Feb 13, 2026. It is now read-only.

Commit 660260a

Browse files
committed
Revert "fix: asus profile"
This reverts commit d42c46a.
1 parent d42c46a commit 660260a

File tree

5 files changed

+86
-200
lines changed

5 files changed

+86
-200
lines changed

home/local/.config/systemd/user/asus-profile-sync.service

Lines changed: 0 additions & 12 deletions
This file was deleted.
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
#!/bin/bash
2+
3+
# Lock file to prevent concurrent executions and feedback loops
4+
LOCKFILE="/run/lock/asus-profile-notify.lock"
5+
STATEFILE="/tmp/asus-profile-last-state"
6+
7+
# Try to acquire exclusive lock (non-blocking)
8+
exec 200>"$LOCKFILE"
9+
flock -n 200 || exit 0
10+
11+
# Wait for hardware to stabilize after profile change
12+
sleep 0.3
13+
14+
# Get current profile
15+
current_profile=$(asusctl profile --profile-get | grep "Active profile" | awk '{print $4}')
16+
17+
# Check if this is the same profile as last run (prevent feedback loop)
18+
if [[ -f "$STATEFILE" ]]; then
19+
last_profile=$(cat "$STATEFILE")
20+
if [[ "$last_profile" == "$current_profile" ]]; then
21+
# Same profile, this is likely a feedback loop from tuned-adm
22+
exit 0
23+
fi
24+
fi
25+
26+
# Save current profile to state file
27+
echo "$current_profile" > "$STATEFILE"
28+
29+
# Map ASUS profiles to TuneD profiles
30+
case "$current_profile" in
31+
"Quiet")
32+
/usr/sbin/tuned-adm profile powersave >/dev/null 2>&1
33+
/usr/bin/supergfxctl -m "Integrated" >/dev/null 2>&1
34+
icon="battery-profile-powersave"
35+
message="Profile: Quiet (Power Saver)"
36+
;;
37+
"Balanced")
38+
/usr/sbin/tuned-adm profile balanced-battery >/dev/null 2>&1
39+
/usr/bin/supergfxctl -m "Hybrid" >/dev/null 2>&1
40+
icon="battery-060"
41+
message="Profile: Balanced"
42+
;;
43+
"Performance")
44+
/usr/sbin/tuned-adm profile throughput-performance >/dev/null 2>&1
45+
/usr/bin/supergfxctl -m "Hybrid" >/dev/null 2>&1
46+
icon="battery-profile-performance"
47+
message="Profile: Performance"
48+
;;
49+
*)
50+
icon="preferences-system-power-management"
51+
message="Profile: $current_profile"
52+
;;
53+
esac
54+
55+
# Show OSD toast notification
56+
if command -v qdbus &> /dev/null; then
57+
qdbus org.kde.plasmashell /org/kde/osdService org.kde.osdService.showText "$icon" "$message" 2>/dev/null
58+
elif command -v kwriteconfig5 &> /dev/null && command -v dbus-send &> /dev/null; then
59+
dbus-send --type=method_call --dest=org.kde.plasmashell /org/kde/osdService org.kde.osdService.showText string:"$icon" string:"$message" 2>/dev/null
60+
elif command -v notify-send &> /dev/null; then
61+
notify-send -i "$icon" -t 2000 "ASUS Profile" "$message"
62+
else
63+
echo "$message"
64+
fi
65+
66+
exit 0

home/local/.local/bin/asus-profile-sync.sh

Lines changed: 0 additions & 65 deletions
This file was deleted.

unix/fedora/install/config/hardware/asus.sh

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,19 +33,29 @@ sudo dnf install -y "${packages[@]}"
3333
sudo systemctl enable supergfxd.service || log_warning "Failed to enable supergfxd"
3434
sudo systemctl start asusd || log_warning "Failed to start asusd"
3535

36-
# Set up D-Bus monitoring for profile changes
37-
log_info "Setting up ASUS profile synchronization"
36+
# Configure udev rules for profile notifications
37+
log_info "Setting up ASUS profile change notifications"
3838

3939
# Get the actual user (not root)
4040
REAL_USER="${SUDO_USER:-$USER}"
41+
REAL_UID=$(id -u "$REAL_USER")
42+
REAL_HOME=$(eval echo "~$REAL_USER")
4143

42-
# Enable and start the user service
43-
sudo -u "$REAL_USER" systemctl --user enable asus-profile-sync.service
44-
sudo -u "$REAL_USER" systemctl --user start asus-profile-sync.service
44+
sudo tee /etc/udev/rules.d/99-asus-profile-toast.rules > /dev/null <<EOF
45+
KERNEL=="platform-profile-*", \\
46+
SUBSYSTEM=="platform-profile", \\
47+
ACTION=="change", \\
48+
RUN+="/bin/bash -c ' \\
49+
DISPLAY=:0 \\
50+
XDG_RUNTIME_DIR=/run/user/$REAL_UID \\
51+
/usr/bin/sudo -u $REAL_USER \\
52+
$REAL_HOME/.local/bin/asus-profile-notify.sh \\
53+
'"
54+
EOF
4555

4656
# Configure polkit for profile switching
4757
sudo tee /etc/polkit-1/rules.d/49-asus-profile.rules > /dev/null <<'EOF'
48-
// Allow switching TuneD profiles from user sessions
58+
// Allow switching TuneD profiles from udev/inactive sessions
4959
polkit.addRule(function(action, subject) {
5060
if (action.id == "com.redhat.tuned.switch_profile") {
5161
return polkit.Result.YES;
@@ -54,6 +64,10 @@ polkit.addRule(function(action, subject) {
5464
EOF
5565

5666
sudo chmod 644 /etc/polkit-1/rules.d/49-asus-profile.rules
67+
sudo chmod 644 /etc/udev/rules.d/99-asus-profile-toast.rules
68+
69+
# Restart services
5770
sudo systemctl restart polkit
71+
sudo udevadm control --reload-rules
5872

5973
log_success "ASUS system optimizations applied"

unix/fedora/migrations/1760556181.sh

Lines changed: 0 additions & 117 deletions
This file was deleted.

0 commit comments

Comments
 (0)