mirror of
https://github.com/adi1090x/rofi.git
synced 2025-12-10 12:22:49 +01:00
Use `$0` instead of `pwd` command - pwd will cause errors if the script is launched from some other directory. False positive with `[[ -f "$ROFI_DIR/config.rasi" ]]` - This may give a false successful installation message if the user's original 'config.rasi' is still in the directory. - Add `set -eu` which will cause the script to exit if there are any errors to prevent data loss. - Add `trap` command to print error message on script exit. Some more fixes/changes - Check if XDG user direcotries are set. - Simplify script by replacing `if` statements with `||` and `case`.
57 lines
1005 B
Bash
Executable File
57 lines
1005 B
Bash
Executable File
#!/usr/bin/env bash
|
|
|
|
# Install script for rofi themes
|
|
|
|
# Dirs
|
|
DIR="${0%/*}"
|
|
FONT_DIR="${XDG_DATA_HOME:-$HOME/.local/share}/fonts"
|
|
ROFI_DIR="${XDG_CONFIG_HOME:-$HOME/.config}/rofi"
|
|
|
|
set -eu
|
|
exit_msg="[!] Failed to install.\n"
|
|
trap 'echo -e $exit_msg' EXIT
|
|
|
|
# Install Fonts
|
|
install_fonts() {
|
|
echo -e "\n[*] Installing fonts..."
|
|
[[ -d "$FONT_DIR" ]] || mkdir -p "$FONT_DIR"
|
|
cp -r "$DIR"/fonts/* "$FONT_DIR"
|
|
}
|
|
|
|
# Install Themes
|
|
install_themes() {
|
|
if [[ -d "$ROFI_DIR" ]]; then
|
|
echo -e "[*] Creating a backup of your rofi configs..."
|
|
mv -f "$ROFI_DIR" "${ROFI_DIR}.old"
|
|
fi
|
|
cp -r "$DIR/$RES" "$ROFI_DIR"
|
|
}
|
|
|
|
# Main
|
|
main() {
|
|
clear
|
|
cat <<- EOF
|
|
[*] Installing Rofi Themes...
|
|
|
|
[*] Choose your screen resolution -
|
|
[1] 1920x1080
|
|
[2] 1366x768
|
|
|
|
EOF
|
|
|
|
read -p "[?] Select Option : "
|
|
|
|
case $REPLY in
|
|
1) RES='1080p' ;;
|
|
2) RES='720p' ;;
|
|
*) exit_msg="\n[!] Invalid Option, Exiting...\n"; exit 1 ;;
|
|
esac
|
|
|
|
install_fonts
|
|
install_themes
|
|
exit_msg="[*] Successfully Installed.\n"
|
|
exit 0
|
|
}
|
|
|
|
main
|