mirror of
https://github.com/basecamp/omarchy.git
synced 2025-07-28 04:39:25 +00:00
Tweaks and refinements to the Omarchy TUI
This commit is contained in:
200
bin/omarchy
200
bin/omarchy
@ -1,16 +1,9 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
# omarchy: Main TUI menu for Omarchy tools
|
OMARCHY_VERSION=$(git -C ~/.local/share/omarchy describe --tags --abbrev=0 2>/dev/null)
|
||||||
# Usage: omarchy
|
|
||||||
|
|
||||||
RED='\033[0;31m'
|
|
||||||
GREEN='\033[0;32m'
|
|
||||||
BLUE='\033[0;34m'
|
|
||||||
NC='\033[0m'
|
|
||||||
BIN_DIR="$(dirname "$0")"
|
|
||||||
OMARCHY_ASCII_SHOWN=0
|
|
||||||
|
|
||||||
show_ascii_art() {
|
show_ascii_art() {
|
||||||
|
clear
|
||||||
cat <<'EOF'
|
cat <<'EOF'
|
||||||
▄██████▄ ▄▄▄▄███▄▄▄▄ ▄████████ ▄████████ ▄████████ ▄█ █▄ ▄██ ▄
|
▄██████▄ ▄▄▄▄███▄▄▄▄ ▄████████ ▄████████ ▄████████ ▄█ █▄ ▄██ ▄
|
||||||
███ ███ ▄██▀▀▀███▀▀▀██▄ ███ ███ ███ ███ ███ ███ ███ ███ ███ ██▄
|
███ ███ ▄██▀▀▀███▀▀▀██▄ ███ ███ ███ ███ ███ ███ ███ ███ ███ ██▄
|
||||||
@ -22,100 +15,43 @@ show_ascii_art() {
|
|||||||
▀██████▀ ▀█ ███ █▀ ███ █▀ ███ ███ ████████▀ ███ █▀ ▀█████▀
|
▀██████▀ ▀█ ███ █▀ ███ █▀ ███ ███ ████████▀ ███ █▀ ▀█████▀
|
||||||
███ ███
|
███ ███
|
||||||
EOF
|
EOF
|
||||||
|
echo " $OMARCHY_VERSION"
|
||||||
}
|
}
|
||||||
|
|
||||||
show_help() {
|
main_menu() {
|
||||||
cat <<EOF
|
show_ascii_art
|
||||||
Omarchy CLI - Usage:
|
|
||||||
|
|
||||||
omarchy [command]
|
local options=("Theme" "Setup" "Update" "Manual" "Exit")
|
||||||
|
choice=$(printf "%s\n" "${options[@]}" | gum choose --header "") || exit 0
|
||||||
Available commands:
|
|
||||||
omarchy Launch the Omarchy TUI menu
|
|
||||||
-v, --version, version Show Omarchy version
|
|
||||||
-h, --help, help Show this help menu
|
|
||||||
|
|
||||||
update Update Omarchy
|
|
||||||
refresh-waybar Refresh waybar
|
|
||||||
theme-install <git-url> Install a theme from a git repo
|
|
||||||
theme-remove <theme-name> Remove a theme by name
|
|
||||||
EOF
|
|
||||||
}
|
|
||||||
|
|
||||||
show_version() {
|
|
||||||
BLUE='\033[0;34m'
|
|
||||||
NC='\033[0m'
|
|
||||||
(
|
|
||||||
cd ~/.local/share/omarchy 2>/dev/null
|
|
||||||
tag=$(git describe --tags --abbrev=0 2>/dev/null)
|
|
||||||
echo -e "${BLUE}Omarchy Version:${NC} $tag"
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
install_theme_prompt() {
|
|
||||||
local url
|
|
||||||
url=$(gum input --placeholder="Git repo URL for theme" --header="Enter theme git repo URL:") || theme_menu
|
|
||||||
if [[ -n "$url" ]]; then
|
|
||||||
"$BIN_DIR/omarchy-theme-install" "$url"
|
|
||||||
fi
|
|
||||||
theme_menu
|
|
||||||
}
|
|
||||||
|
|
||||||
remove_theme_prompt() {
|
|
||||||
local theme
|
|
||||||
theme=$(gum input --placeholder="Theme name" --header="Enter the theme name to remove:") || theme_menu
|
|
||||||
if [[ -n "$theme" ]]; then
|
|
||||||
"$BIN_DIR/omarchy-theme-remove" "$theme"
|
|
||||||
fi
|
|
||||||
theme_menu
|
|
||||||
}
|
|
||||||
|
|
||||||
# Menu functions
|
|
||||||
show_tui_menu() {
|
|
||||||
local columns choice
|
|
||||||
columns=$(tput cols 2>/dev/null || echo 80)
|
|
||||||
|
|
||||||
if [[ $OMARCHY_ASCII_SHOWN -eq 0 ]]; then
|
|
||||||
if [[ $columns -ge 100 ]]; then
|
|
||||||
echo
|
|
||||||
show_ascii_art
|
|
||||||
else
|
|
||||||
echo "Omarchy"
|
|
||||||
fi
|
|
||||||
echo
|
|
||||||
OMARCHY_ASCII_SHOWN=1
|
|
||||||
fi
|
|
||||||
|
|
||||||
local main_menu=("System" "Theme" "Tools" "Exit")
|
|
||||||
choice=$(printf "%s\n" "${main_menu[@]}" | gum choose --header="Select a category:") || exit 0
|
|
||||||
case "$choice" in
|
case "$choice" in
|
||||||
System) system_menu ;;
|
Theme) theme_menu ;;
|
||||||
Theme) theme_menu ;;
|
Update) update_menu ;;
|
||||||
Tools) tools_menu ;;
|
Setup) setup_menu ;;
|
||||||
Exit) exit 0 ;;
|
Manual) open_manual ;;
|
||||||
|
Exit) clear && exit 0 ;;
|
||||||
esac
|
esac
|
||||||
}
|
}
|
||||||
|
|
||||||
system_menu() {
|
update_menu() {
|
||||||
local menu=("Version" "Update" "Refresh Waybar" "Back")
|
show_ascii_art
|
||||||
|
local menu=("Omarchy" "Wofi Apps" "Waybar" "Plymouth" "Back")
|
||||||
local commands=(
|
local commands=(
|
||||||
"show_version"
|
"omarchy-update"
|
||||||
"$BIN_DIR/omarchy-update"
|
"omarchy-sync-applications"
|
||||||
"$BIN_DIR/omarchy-refresh-waybar"
|
"omarchy-refresh-waybar"
|
||||||
"show_tui_menu"
|
"omarchy-refresh-plymouth"
|
||||||
|
"main_menu"
|
||||||
)
|
)
|
||||||
local choice
|
local choice
|
||||||
choice=$(printf "%s\n" "${menu[@]}" | gum choose --header="System:") || show_tui_menu
|
choice=$(printf "%s\n" "${menu[@]}" | gum choose --header="Update") || main_menu
|
||||||
for i in "${!menu[@]}"; do
|
for i in "${!menu[@]}"; do
|
||||||
if [[ "${menu[$i]}" == "$choice" ]]; then
|
if [[ "${menu[$i]}" == "$choice" ]]; then
|
||||||
if [[ "$choice" == "Back" ]]; then
|
if [[ "$choice" == "Back" ]]; then
|
||||||
show_tui_menu
|
main_menu
|
||||||
else
|
else
|
||||||
if [[ "${commands[$i]}" == "show_version" ]]; then
|
eval "${commands[$i]}"
|
||||||
show_version
|
ack_command
|
||||||
else
|
main_menu
|
||||||
eval "${commands[$i]}"
|
|
||||||
fi
|
|
||||||
fi
|
fi
|
||||||
break
|
break
|
||||||
fi
|
fi
|
||||||
@ -123,77 +59,77 @@ system_menu() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
theme_menu() {
|
theme_menu() {
|
||||||
local menu=("Switch Theme" "Install Theme" "Remove Theme" "Back")
|
show_ascii_art
|
||||||
|
local menu=("Install" "Remove" "Back")
|
||||||
local commands=(
|
local commands=(
|
||||||
"$BIN_DIR/omarchy-theme-menu"
|
|
||||||
"install_theme_prompt"
|
"install_theme_prompt"
|
||||||
"remove_theme_prompt"
|
"remove_theme_prompt"
|
||||||
"show_tui_menu"
|
"main_menu"
|
||||||
)
|
)
|
||||||
local choice
|
local choice
|
||||||
choice=$(printf "%s\n" "${menu[@]}" | gum choose --header="Theme:") || show_tui_menu
|
choice=$(printf "%s\n" "${menu[@]}" | gum choose --header="Theme") || main_menu
|
||||||
for i in "${!menu[@]}"; do
|
for i in "${!menu[@]}"; do
|
||||||
if [[ "${menu[$i]}" == "$choice" ]]; then
|
if [[ "${menu[$i]}" == "$choice" ]]; then
|
||||||
if [[ "$choice" == "Back" ]]; then
|
if [[ "$choice" == "Back" ]]; then
|
||||||
show_tui_menu
|
main_menu
|
||||||
else
|
else
|
||||||
eval "${commands[$i]}"
|
eval "${commands[$i]}"
|
||||||
|
ack_command
|
||||||
|
main_menu
|
||||||
fi
|
fi
|
||||||
break
|
break
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
tools_menu() {
|
install_theme_prompt() {
|
||||||
local menu=("Setup Fingerprint" "Sync Applications" "Back")
|
local url
|
||||||
|
url=$(gum input --placeholder="Git repo URL for theme" --header="")
|
||||||
|
if [[ -n "$url" ]]; then
|
||||||
|
omarchy-theme-install "$url"
|
||||||
|
fi
|
||||||
|
theme_menu
|
||||||
|
}
|
||||||
|
|
||||||
|
remove_theme_prompt() {
|
||||||
|
local theme
|
||||||
|
theme=$(gum input --placeholder="Theme name" --header="")
|
||||||
|
if [[ -n "$theme" ]]; then
|
||||||
|
omarchy-theme-remove "$theme"
|
||||||
|
fi
|
||||||
|
theme_menu
|
||||||
|
}
|
||||||
|
|
||||||
|
setup_menu() {
|
||||||
|
show_ascii_art
|
||||||
|
local menu=("Fingerprint sensor" "Back")
|
||||||
local commands=(
|
local commands=(
|
||||||
"$BIN_DIR/omarchy-fingerprint-setup"
|
"omarchy-fingerprint-setup"
|
||||||
"$BIN_DIR/omarchy-sync-applications"
|
"main_menu"
|
||||||
"show_tui_menu"
|
|
||||||
)
|
)
|
||||||
local choice
|
local choice
|
||||||
choice=$(printf "%s\n" "${menu[@]}" | gum choose --header="Tools:") || show_tui_menu
|
choice=$(printf "%s\n" "${menu[@]}" | gum choose --header="Setup") || main_menu
|
||||||
for i in "${!menu[@]}"; do
|
for i in "${!menu[@]}"; do
|
||||||
if [[ "${menu[$i]}" == "$choice" ]]; then
|
if [[ "${menu[$i]}" == "$choice" ]]; then
|
||||||
if [[ "$choice" == "Back" ]]; then
|
if [[ "$choice" == "Back" ]]; then
|
||||||
show_tui_menu
|
main_menu
|
||||||
else
|
else
|
||||||
eval "${commands[$i]}"
|
eval "${commands[$i]}"
|
||||||
|
ack_command
|
||||||
|
main_menu
|
||||||
fi
|
fi
|
||||||
break
|
break
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
if [[ $# -eq 0 ]]; then
|
open_manual() {
|
||||||
show_tui_menu
|
xdg-open "https://manuals.omamix.org/2/the-omarchy-manual"
|
||||||
exit 0
|
}
|
||||||
fi
|
|
||||||
|
ack_command() {
|
||||||
|
gum spin --spinner "globe" --title "Done!" -- sleep 1
|
||||||
|
}
|
||||||
|
|
||||||
|
main_menu
|
||||||
|
|
||||||
case "$1" in
|
|
||||||
-v|--version|version)
|
|
||||||
show_version
|
|
||||||
;;
|
|
||||||
-h|--help|help)
|
|
||||||
show_help
|
|
||||||
;;
|
|
||||||
update)
|
|
||||||
echo -e "${BLUE}🔄 Updating Omarchy...${NC}"
|
|
||||||
"$BIN_DIR/omarchy-update"
|
|
||||||
;;
|
|
||||||
refresh-waybar)
|
|
||||||
echo -e "${BLUE}🔄 Refreshing waybar...${NC}"
|
|
||||||
"$BIN_DIR/omarchy-refresh-waybar"
|
|
||||||
;;
|
|
||||||
theme-install)
|
|
||||||
"$BIN_DIR/omarchy-theme-install" "${@:2}"
|
|
||||||
;;
|
|
||||||
theme-remove)
|
|
||||||
"$BIN_DIR/omarchy-theme-remove" "${@:2}"
|
|
||||||
;;
|
|
||||||
*)
|
|
||||||
echo -e "${RED}Unknown command: $1${NC}"
|
|
||||||
show_help
|
|
||||||
exit 1
|
|
||||||
;;
|
|
||||||
esac
|
|
Reference in New Issue
Block a user