feat: implement distraction toggle script for hosts file management; feat: add privacy toggle script with status checking capability; refactor: improve grayscale toggle script with status parameter support; refactor: reorganize hyprland gestures and input configuration; chore: remove unused bspwm script and btop configuration files; chore: delete obsolete rofi-wayland launcher themes and configurations; feat: extend nvim filetype recognition for pascal scripts; feat: enhance swaync configuration with new toggle buttons and layout adjustments; chore: update waybar goal file content; chore: modify gitignore patterns for cava assets and thunar configurations; fix: adjust thunar custom actions to use swww instead of hyprpaper
62 lines
1.9 KiB
Bash
Executable File
62 lines
1.9 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
# Define the configuration file path
|
|
FILE="/etc/hosts"
|
|
TMP_FILE="/tmp/hosts.$$" # Use PID to make temp file unique
|
|
|
|
if [ ! -f "$FILE" ]; then
|
|
echo "File not found: $FILE"
|
|
exit 1
|
|
fi
|
|
|
|
# Variables to identify the distraction remover section
|
|
START_LINE=$(grep -n '^# Distraction removers' "$FILE" | cut -d: -f1)
|
|
END_LINE=$(grep -n '^# End of distraction removers' "$FILE" | cut -d: -f1)
|
|
|
|
if [ -n "$START_LINE" ] && [ -n "$END_LINE" ]; then
|
|
# Calculate lines for sed
|
|
START=$((START_LINE + 1))
|
|
END=$((END_LINE - 1))
|
|
|
|
# If the first line of the distraction section is not commented, comment them
|
|
if ! sed -n "${START}p" "$FILE" | grep -q '^#'; then
|
|
if [ "$1" = 'g' ]; then
|
|
echo "true"
|
|
exit 0
|
|
fi
|
|
# Copy to temp file, edit, then copy back
|
|
cp "$FILE" "$TMP_FILE"
|
|
sed -i "${START},${END}s/^/#/" "$TMP_FILE"
|
|
# Use sudo to copy back if needed, or direct copy if run as root
|
|
if [ "$(id -u)" -eq 0 ]; then
|
|
cp "$TMP_FILE" "$FILE"
|
|
echo "Commented out distraction removers in $FILE."
|
|
else
|
|
cp "$TMP_FILE" "$FILE"
|
|
echo "Commented out distraction removers in $FILE."
|
|
fi
|
|
rm -f "$TMP_FILE"
|
|
else
|
|
if [ "$1" = 'g' ]; then
|
|
echo "false"
|
|
exit 0
|
|
fi
|
|
# Uncomment the section
|
|
cp "$FILE" "$TMP_FILE"
|
|
sed -i "${START},${END}s/^#//" "$TMP_FILE"
|
|
if [ "$(id -u)" -eq 0 ]; then
|
|
cp "$TMP_FILE" "$FILE"
|
|
echo "Uncommented distraction removers in $FILE."
|
|
else
|
|
cp "$TMP_FILE" "$FILE"
|
|
echo "Uncommented distraction removers in $FILE."
|
|
fi
|
|
rm -f "$TMP_FILE"
|
|
fi
|
|
else
|
|
echo "Distraction removers section not found in $FILE."
|
|
exit 1
|
|
fi
|
|
|
|
systemd-resolve --flush-cache || notify-send "System Resolve" "Error flushing cache. Are you allowed to run the command?"
|