diff options
| author | Pinapelz <yukais@pinapelz.com> | 2026-07-10 11:21:24 -0700 |
|---|---|---|
| committer | Pinapelz <yukais@pinapelz.com> | 2026-07-10 11:21:24 -0700 |
| commit | 24de2a31a52d17b6f7214197bdbfeab7428742dd (patch) | |
| tree | f7736c4712d5a394525a3da2f2b4294e81ba9540 /config/hypr/scripts/ChangeStarshipPrompt.sh | |
| parent | 861bf5be200bfcf2440fec4cda911d29ec18493f (diff) | |
| parent | bca86bbec4757cec1f6f5bdea2ed210542f10fae (diff) | |
Merge remote-tracking branch 'upstream'
Diffstat (limited to 'config/hypr/scripts/ChangeStarshipPrompt.sh')
| -rwxr-xr-x | config/hypr/scripts/ChangeStarshipPrompt.sh | 78 |
1 files changed, 78 insertions, 0 deletions
diff --git a/config/hypr/scripts/ChangeStarshipPrompt.sh b/config/hypr/scripts/ChangeStarshipPrompt.sh new file mode 100755 index 00000000..44e50936 --- /dev/null +++ b/config/hypr/scripts/ChangeStarshipPrompt.sh @@ -0,0 +1,78 @@ +#!/usr/bin/env bash +# ================================================== +# KoolDots (2026) +# Project URL: https://github.com/LinuxBeginnings +# License: GNU GPLv3 +# SPDX-License-Identifier: GPL-3.0-or-later +# ================================================== +# Switch Starship prompt configs via Rofi. + +CONFIG_HOME="${XDG_CONFIG_HOME:-$HOME/.config}" +STARSHIP_DIR="$CONFIG_HOME/starship" +HYPR_STARSHIP_DIR="$CONFIG_HOME/hypr/starship" +STARSHIP_CONFIG="$CONFIG_HOME/starship.toml" +BACKUP_FILE="$STARSHIP_CONFIG.original" +ROFI_THEME="$CONFIG_HOME/rofi/config-starship.rasi" +RESTORE_LABEL="Retore orignal prompt" + +if ! command -v starship >/dev/null 2>&1; then + echo "starship is not installed" + exit 1 +fi + +if [[ ! -f "$ROFI_THEME" ]]; then + echo "Rofi theme not found: $ROFI_THEME" + exit 1 +fi + +if [[ ! -d "$STARSHIP_DIR" ]]; then + echo "Starship config directory not found: $STARSHIP_DIR" + exit 1 +fi + +mapfile -t available_prompts < <(find "$STARSHIP_DIR" -maxdepth 1 -type f -name "*.toml" -printf "%f\n" 2>/dev/null | sort -V) + +if [[ ${#available_prompts[@]} -eq 0 ]]; then + echo "No Starship prompt files found in $STARSHIP_DIR" + exit 1 +fi + +rofi_options=("${available_prompts[@]}") +if [[ -f "$BACKUP_FILE" ]]; then + rofi_options+=("$RESTORE_LABEL") +fi + +selection="$(printf '%s\n' "${rofi_options[@]}" | rofi -dmenu -i -p "Select Starship Prompt" -mesg "Select Starship Prompt" -theme "$ROFI_THEME")" + +if [[ -z "$selection" ]]; then + exit 0 +fi + +if [[ "$selection" == "$RESTORE_LABEL" ]]; then + if [[ -f "$BACKUP_FILE" ]]; then + if [[ -L "$STARSHIP_CONFIG" ]]; then + rm -f "$STARSHIP_CONFIG" + fi + cp -f "$BACKUP_FILE" "$STARSHIP_CONFIG" + else + echo "Backup not found: $BACKUP_FILE" + fi + exit 0 +fi + +selected_path="$STARSHIP_DIR/$selection" +if [[ ! -f "$selected_path" && -f "$HYPR_STARSHIP_DIR/$selection" ]]; then + selected_path="$HYPR_STARSHIP_DIR/$selection" +fi + +if [[ ! -f "$selected_path" ]]; then + echo "Selected prompt not found: $selection" + exit 1 +fi + +if [[ -f "$STARSHIP_CONFIG" && ! -L "$STARSHIP_CONFIG" ]]; then + cp -f "$STARSHIP_CONFIG" "$BACKUP_FILE" + rm -f "$STARSHIP_CONFIG" +fi + +ln -sfn "$selected_path" "$STARSHIP_CONFIG" |
