Skip to content

Commit

Permalink
Merge pull request #259 from CelticBoozer/development
Browse files Browse the repository at this point in the history
fix #256, implement #257, fix #260
  • Loading branch information
CelticBoozer authored Oct 29, 2024
2 parents 4392474 + f11dc76 commit f0891e4
Show file tree
Hide file tree
Showing 19 changed files with 240 additions and 239 deletions.
6 changes: 3 additions & 3 deletions .bin/check-pacnew.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
pacnews="$(pacdiff --output)"
nb="$(pacdiff --output | grep -c .)"
if [[ $nb -gt 0 ]]; then
echo -e "\e[31m$nb .pacnew files found in system...\e[0m"
printf "%s\n" "$pacnews"
echo -e "\e[31m$nb .pacnew files found in system...\e[0m"
printf "%s\n" "$pacnews"
else
echo -e "\e[32mNo .pacnew files found in system...\e[0m"
echo -e "\e[32mNo .pacnew files found in system...\e[0m"
fi
4 changes: 2 additions & 2 deletions .bin/cliphist-rofi.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ tmp_dir="/tmp/cliphist"
rm -rf "$tmp_dir"

if [[ -n "$1" ]]; then
cliphist decode <<<"$1" | wl-copy
exit
cliphist decode <<<"$1" | wl-copy
exit
fi

mkdir -p "$tmp_dir"
Expand Down
52 changes: 26 additions & 26 deletions .bin/initial-installation.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,38 +13,38 @@ success_color=32
error_color=31

check_file() {
if [ ! -f "$1" ]; then
missing_files="$missing_files\n $1,"
fi
if [ ! -f "$1" ]; then
missing_files="$missing_files\n $1,"
fi
}

check_package() {
if ! pacman -Qs "$1" >/dev/null; then
missing_packages="$missing_packages\n $1,"
fi
if ! pacman -Qs "$1" >/dev/null; then
missing_packages="$missing_packages\n $1,"
fi
}

print_log_message() {
printf "\e[%dmInstallation log: %b\e[0m\n" "$1" "$2"
printf "\e[%dmInstallation log: %b\e[0m\n" "$1" "$2"
}

printf "\e[36mPlease, make sure you move all files to your home directory.\e[0m\n"
printf "\e[36mAlso, the computer must have internet access and git must be installed.\e[0m\n"

while true; do
read -rp "Do you want to continue? (y/n): " choice
case "$choice" in
[Yy])
break
;;
[Nn])
echo "Aborting..."
exit
;;
*)
echo "Invalid input. Please enter 'y' or 'n'."
;;
esac
read -rp "Do you want to continue? (y/n): " choice
case "$choice" in
[Yy])
break
;;
[Nn])
echo "Aborting..."
exit
;;
*)
echo "Invalid input. Please enter 'y' or 'n'."
;;
esac
done

print_log_message $info_color "system installation initiated..."
Expand All @@ -65,14 +65,14 @@ check_file "${HOME}/.system-config-backup/reflector.conf"
check_package "git"

if [ -n "$missing_files" ]; then
print_log_message $error_color "missing files...\n $missing_files"
print_log_message $error_color "installation aborted."
exit 1
print_log_message $error_color "missing files...\n $missing_files"
print_log_message $error_color "installation aborted."
exit 1
fi
if [ -n "$missing_packages" ]; then
print_log_message $error_color "missing packages...\n $missing_packages"
print_log_message $error_color "installation aborted."
exit 1
print_log_message $error_color "missing packages...\n $missing_packages"
print_log_message $error_color "installation aborted."
exit 1
fi

# Installing packages
Expand Down
206 changes: 103 additions & 103 deletions .bin/power-menu.sh
Original file line number Diff line number Diff line change
Expand Up @@ -39,102 +39,102 @@ dryrun=false
showsymbols=true

function check_valid {
shift 1
for entry in "${@}"; do
if [ -z "${actions[$entry]+x}" ]; then
echo "Invalid choice in $1: $entry" >&2
exit 1
fi
done
shift 1
for entry in "${@}"; do
if [ -z "${actions[$entry]+x}" ]; then
echo "Invalid choice in $1: $entry" >&2
exit 1
fi
done
}

# Parse command-line options
parsed=$(getopt --options=h --longoptions=help,dry-run,confirm:,choices:,choose:,symbols,no-symbols --name "$0" -- "$@")
if [ $? -ne 0 ]; then
echo 'Terminating...' >&2
exit 1
echo 'Terminating...' >&2
exit 1
fi
eval set -- "$parsed"
unset parsed
while true; do
case "$1" in
"--dry-run")
dryrun=true
shift 1
;;
"--confirm")
IFS='/' read -ra confirmations <<<"$2"
check_valid "$1" "${confirmations[@]}"
shift 2
;;
"--choices")
IFS='/' read -ra show <<<"$2"
check_valid "$1" "${show[@]}"
shift 2
;;
"--choose")
# Check that the choice is valid
check_valid "$1" "$2"
selectionID="$2"
shift 2
;;
"--symbols")
showsymbols=true
shift 1
;;
"--no-symbols")
showsymbols=false
shift 1
;;
"--")
shift
break
;;
*)
echo "Internal error" >&2
exit 1
;;
esac
case "$1" in
"--dry-run")
dryrun=true
shift 1
;;
"--confirm")
IFS='/' read -ra confirmations <<<"$2"
check_valid "$1" "${confirmations[@]}"
shift 2
;;
"--choices")
IFS='/' read -ra show <<<"$2"
check_valid "$1" "${show[@]}"
shift 2
;;
"--choose")
# Check that the choice is valid
check_valid "$1" "$2"
selectionID="$2"
shift 2
;;
"--symbols")
showsymbols=true
shift 1
;;
"--no-symbols")
showsymbols=false
shift 1
;;
"--")
shift
break
;;
*)
echo "Internal error" >&2
exit 1
;;
esac
done

# Define the messages after parsing the CLI options so that it is possible to
# configure them in the future.

function write_message {
icon="<span font_size=\"medium\">$1</span>"
text="<span font_size=\"medium\">$2</span>"
if [ "$showsymbols" = "true" ]; then
echo -n "\u200e$icon \u2068$text\u2069"
else
echo -n "$text"
fi
icon="<span font_size=\"medium\">$1</span>"
text="<span font_size=\"medium\">$2</span>"
if [ "$showsymbols" = "true" ]; then
echo -n "\u200e$icon \u2068$text\u2069"
else
echo -n "$text"
fi
}

function print_selection {
echo -e "$1" | $(
read -r -d '' entry
echo "echo $entry"
)
echo -e "$1" | $(
read -r -d '' entry
echo "echo $entry"
)
}

declare -A messages
declare -A confirmationMessages
for entry in "${all[@]}"; do
messages[$entry]=$(write_message "${icons[$entry]}" "${texts[$entry]^}")
messages[$entry]=$(write_message "${icons[$entry]}" "${texts[$entry]^}")
done
for entry in "${all[@]}"; do
confirmationMessages[$entry]=$(write_message "${icons[$entry]}" "Yes, ${texts[$entry]}")
confirmationMessages[$entry]=$(write_message "${icons[$entry]}" "Yes, ${texts[$entry]}")
done
confirmationMessages[cancel]=$(write_message "${icons[cancel]}" "No, cancel")

if [ $# -gt 0 ]; then
# If arguments given, use those as the selection
selection="${*}"
# If arguments given, use those as the selection
selection="${*}"
else
# Otherwise, use the CLI passed choice if given
if [ -n "${selectionID+x}" ]; then
selection="${messages[$selectionID]}"
fi
# Otherwise, use the CLI passed choice if given
if [ -n "${selectionID+x}" ]; then
selection="${messages[$selectionID]}"
fi
fi

# Don't allow custom entries
Expand All @@ -143,42 +143,42 @@ echo -e "\0no-custom\x1ftrue"
echo -e "\0markup-rows\x1ftrue"

if [ -z "${selection+x}" ]; then
echo -e "\0prompt\x1fPower"
for entry in "${show[@]}"; do
echo -e "${messages[$entry]}\0icon\x1f${icons[$entry]}"
done
echo -e "\0prompt\x1fPower"
for entry in "${show[@]}"; do
echo -e "${messages[$entry]}\0icon\x1f${icons[$entry]}"
done
else
for entry in "${show[@]}"; do
if [ "$selection" = "$(print_selection "${messages[$entry]}")" ]; then
# Check if the selected entry is listed in confirmation requirements
for confirmation in "${confirmations[@]}"; do
if [ "$entry" = "$confirmation" ]; then
# Ask for confirmation
echo -e "\0prompt\x1fAre you sure"
echo -e "${confirmationMessages[$entry]}\0icon\x1f${icons[$entry]}"
echo -e "${confirmationMessages[cancel]}\0icon\x1f${icons[cancel]}"
exit 0
fi
done
# If not, then no confirmation is required, so mark confirmed
selection=$(print_selection "${confirmationMessages[$entry]}")
fi
if [ "$selection" = "$(print_selection "${confirmationMessages[$entry]}")" ]; then
if [ $dryrun = true ]; then
# Tell what would have been done
echo "Selected: $entry" >&2
else
# Perform the action
${actions[$entry]}
fi
exit 0
fi
if [ "$selection" = "$(print_selection "${confirmationMessages[cancel]}")" ]; then
# Do nothing
exit 0
fi
done
# The selection didn't match anything, so raise an error
echo "Invalid selection: $selection" >&2
exit 1
for entry in "${show[@]}"; do
if [ "$selection" = "$(print_selection "${messages[$entry]}")" ]; then
# Check if the selected entry is listed in confirmation requirements
for confirmation in "${confirmations[@]}"; do
if [ "$entry" = "$confirmation" ]; then
# Ask for confirmation
echo -e "\0prompt\x1fAre you sure"
echo -e "${confirmationMessages[$entry]}\0icon\x1f${icons[$entry]}"
echo -e "${confirmationMessages[cancel]}\0icon\x1f${icons[cancel]}"
exit 0
fi
done
# If not, then no confirmation is required, so mark confirmed
selection=$(print_selection "${confirmationMessages[$entry]}")
fi
if [ "$selection" = "$(print_selection "${confirmationMessages[$entry]}")" ]; then
if [ $dryrun = true ]; then
# Tell what would have been done
echo "Selected: $entry" >&2
else
# Perform the action
${actions[$entry]}
fi
exit 0
fi
if [ "$selection" = "$(print_selection "${confirmationMessages[cancel]}")" ]; then
# Do nothing
exit 0
fi
done
# The selection didn't match anything, so raise an error
echo "Invalid selection: $selection" >&2
exit 1
fi
12 changes: 6 additions & 6 deletions .bin/random-background.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ swaybg -i "$(find "${HOME}/.wallpaper/." -type f | shuf -n1)" -m fill &
OLD_PID=$!

while true; do
sleep 300
swaybg -i "$(find "${HOME}/.wallpaper/." -type f | shuf -n1)" -m fill &
NEXT_PID=$!
sleep 5
kill $OLD_PID
OLD_PID=$NEXT_PID
sleep 300
swaybg -i "$(find "${HOME}/.wallpaper/." -type f | shuf -n1)" -m fill &
NEXT_PID=$!
sleep 5
kill $OLD_PID
OLD_PID=$NEXT_PID
done
Loading

0 comments on commit f0891e4

Please sign in to comment.