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

Commit 4ea7764

Browse files
committed
make lockfile readable
1 parent 237aef3 commit 4ea7764

File tree

2 files changed

+30
-46
lines changed

2 files changed

+30
-46
lines changed

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

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,35 @@
11
#!/bin/bash
22

33
# Lock file to prevent concurrent executions and feedback loops
4-
LOCKFILE="/run/lock/asus-profile-notify.lock"
5-
STATEFILE="/tmp/asus-profile-last-state"
4+
# Use XDG_RUNTIME_DIR (user-writable) instead of /run/lock (root-only)
5+
LOCKFILE="${XDG_RUNTIME_DIR:-/tmp}/asus-profile-notify.lock"
6+
STATEFILE="${XDG_RUNTIME_DIR:-/tmp}/asus-profile-last-state"
7+
DEBOUNCEFILE="${XDG_RUNTIME_DIR:-/tmp}/asus-profile-debounce"
8+
9+
# Debounce: if script was run within last 0.5s, wait for things to settle
10+
if [[ -f "$DEBOUNCEFILE" ]]; then
11+
last_run=$(cat "$DEBOUNCEFILE")
12+
current_time=$(date +%s%3N) # milliseconds
13+
time_diff=$((current_time - last_run))
14+
15+
if [[ $time_diff -lt 500 ]]; then
16+
# Too soon, let the dust settle
17+
sleep 0.5
18+
fi
19+
fi
20+
21+
# Save current timestamp for debouncing
22+
date +%s%3N > "$DEBOUNCEFILE"
623

724
# Try to acquire exclusive lock (non-blocking)
825
exec 200>"$LOCKFILE"
9-
flock -n 200 || exit 0
26+
if ! flock -n 200; then
27+
# Another instance is running, exit silently
28+
exit 0
29+
fi
1030

1131
# Wait for hardware to stabilize after profile change
12-
sleep 0.3
32+
sleep 0.2
1333

1434
# Get current profile
1535
current_profile=$(asusctl profile --profile-get | grep "Active profile" | awk '{print $4}')

unix/fedora/fedora-setup

Lines changed: 6 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -65,57 +65,21 @@ source "$OMAFORGE_INSTALL/helpers/all.sh"
6565
# Function to run a single module
6666
run_single_module() {
6767
local module="$1"
68-
local module_path=""
6968

70-
# Try to find the module file
71-
# First, check if it's a direct path
72-
if [[ -f "$OMAFORGE_INSTALL/$module.sh" ]]; then
73-
module_path="$OMAFORGE_INSTALL/$module.sh"
74-
# Try with .sh extension if not already present
75-
elif [[ -f "$OMAFORGE_INSTALL/${module%.sh}.sh" ]]; then
76-
module_path="$OMAFORGE_INSTALL/${module%.sh}.sh"
77-
# Search for common short names
78-
else
79-
# Common module locations
80-
local search_paths=(
81-
"config/hardware/$module.sh"
82-
"config/$module.sh"
83-
"packaging/$module.sh"
84-
"repositories/$module.sh"
85-
"dotfiles/$module.sh"
86-
"preflight/$module.sh"
87-
"post-install/$module.sh"
88-
)
69+
# Add .sh if not present
70+
[[ "$module" != *.sh ]] && module="$module.sh"
8971

90-
for path in "${search_paths[@]}"; do
91-
if [[ -f "$OMAFORGE_INSTALL/$path" ]]; then
92-
module_path="$OMAFORGE_INSTALL/$path"
93-
break
94-
fi
95-
done
96-
fi
72+
# Find the module file
73+
local module_path=$(find "$OMAFORGE_INSTALL" -name "$module" -type f | head -1)
9774

9875
if [[ -z "$module_path" ]]; then
9976
echo "[ERROR] Module not found: $module"
100-
echo "[ERROR] Searched in common locations but couldn't find the module file"
101-
echo ""
102-
echo "Available modules:"
103-
echo " Hardware: asus, nvidia"
104-
echo " Config: system, git, firmware, multimedia, performance, services, nextdns, secureboot"
105-
echo " Packaging: base, flatpak, rust, bloatware, webapps"
106-
echo " Repositories: rpmfusion, copr, terra, external"
107-
echo " Dotfiles: zsh, fonts, directories, stow"
10877
exit 1
10978
fi
11079

111-
echo "[INFO] Running single module: $(basename "$module_path")"
112-
echo "[INFO] Path: $module_path"
113-
echo ""
114-
80+
echo "[INFO] Running: $module_path"
11581
source "$module_path"
116-
117-
echo ""
118-
echo "[SUCCESS] Module completed: $(basename "$module_path")"
82+
echo "[SUCCESS] Completed"
11983
}
12084

12185
# Check if running single module or full setup

0 commit comments

Comments
 (0)