Skip to content

Commit cff978e

Browse files
committed
fix: shell syntax
1 parent efb081c commit cff978e

3 files changed

Lines changed: 19 additions & 9 deletions

File tree

configs/i3/lock.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ start_sleep_timer() {
3434
# Cancel sleep timer
3535
cancel_sleep_timer() {
3636
if [ -f "$SLEEP_TIMER_PID" ]; then
37-
kill $(cat "$SLEEP_TIMER_PID") 2>/dev/null
37+
kill "$(cat "$SLEEP_TIMER_PID")" 2>/dev/null
3838
rm -f "$SLEEP_TIMER_PID"
3939
fi
4040
}

install.sh

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ check_sudo() {
132132
# Keep sudo alive in background
133133
(while true; do sudo -v; sleep 50; done) &
134134
SUDO_KEEPER_PID=$!
135-
trap "kill $SUDO_KEEPER_PID 2>/dev/null; cleanup" EXIT
135+
trap 'kill $SUDO_KEEPER_PID 2>/dev/null; cleanup' EXIT
136136

137137
print_success "Sudo access OK"
138138
}
@@ -172,7 +172,7 @@ setup_repo() {
172172
if [ -d "$INSTALL_DIR" ]; then
173173
if [ -d "$INSTALL_DIR/.git" ]; then
174174
print_step "Updating existing installation..."
175-
cd "$INSTALL_DIR"
175+
cd "$INSTALL_DIR" || return
176176
git fetch --quiet origin 2>/dev/null || true
177177
git reset --hard origin/latest --quiet 2>/dev/null || git pull --quiet 2>/dev/null || true
178178
else
@@ -390,14 +390,21 @@ configure_hardware() {
390390

391391
# If it's a symlink, copy to real file for editing
392392
if [ -L "$polybar_config" ]; then
393-
local target=$(readlink -f "$polybar_config")
393+
local target
394+
target=$(readlink -f "$polybar_config")
394395
rm -f "$polybar_config"
395396
cp "$target" "$polybar_config"
396397
fi
397398

398399
# Detect battery (for laptops)
399-
BATTERY=$(ls /sys/class/power_supply/ 2>/dev/null | grep -E "^BAT" | head -1 || echo "")
400-
ADAPTER=$(ls /sys/class/power_supply/ 2>/dev/null | grep -E "^AC|^ACAD|^ADP" | head -1 || echo "")
400+
BATTERY=""
401+
for bat in /sys/class/power_supply/BAT*; do
402+
[ -e "$bat" ] && BATTERY=$(basename "$bat") && break
403+
done
404+
ADAPTER=""
405+
for adp in /sys/class/power_supply/AC* /sys/class/power_supply/ACAD* /sys/class/power_supply/ADP*; do
406+
[ -e "$adp" ] && ADAPTER=$(basename "$adp") && break
407+
done
401408

402409
if [ -n "$BATTERY" ]; then
403410
print_step "Battery detected: $BATTERY"
@@ -516,7 +523,8 @@ configure_battery_limit() {
516523
read -r response </dev/tty || response="n"
517524

518525
if [[ "$response" =~ ^[Yy]$ ]]; then
519-
local bat_name=$(basename $(dirname "$battery_path"))
526+
local bat_name
527+
bat_name=$(basename "$(dirname "$battery_path")")
520528

521529
echo 80 | sudo tee "$battery_path" > /dev/null 2>&1
522530

uninstall.sh

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,15 +95,17 @@ remove_configs() {
9595

9696
# Revert fish shell to bash (optional)
9797
revert_shell() {
98-
local current_shell=$(basename "$SHELL")
98+
local current_shell
99+
current_shell=$(basename "$SHELL")
99100

100101
if [ "$current_shell" = "fish" ]; then
101102
echo -e "Your default shell is currently ${YELLOW}fish${NC}."
102103
echo -e "Do you want to revert to ${GREEN}bash${NC}? (y/n)"
103104
read -r response
104105

105106
if [[ "$response" =~ ^[Yy]$ ]]; then
106-
local bash_path=$(command -v bash)
107+
local bash_path
108+
bash_path=$(command -v bash)
107109
if [ -n "$bash_path" ]; then
108110
print_step "Reverting shell to bash..."
109111
if sudo chsh -s "$bash_path" "$USER" 2>/dev/null || chsh -s "$bash_path" 2>/dev/null; then

0 commit comments

Comments
 (0)