mirror of
https://github.com/ksyasuda/dotfiles.git
synced 2025-12-07 02:53:37 -08:00
update rofi scripts
This commit is contained in:
@@ -1,20 +1,68 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
BROWSER=/usr/bin/zen-browser
|
||||
URLS=(
|
||||
OPTIONS=(
|
||||
"Arch Linux (btw)"
|
||||
"Hyprland"
|
||||
)
|
||||
ARCH=(
|
||||
"Archlinux Wiki|https://wiki.archlinux.org/title/Main_page"
|
||||
)
|
||||
HYPRLAND=(
|
||||
"Hyprland Docs|https://wiki.hypr.land/"
|
||||
"Hyprland Window Rules|https://wiki.hypr.land/Configuring/Window-Rules/"
|
||||
)
|
||||
|
||||
DISPLAY_URLS=()
|
||||
declare -A URL_MAP
|
||||
for url in "${URLS[@]}"; do
|
||||
DISPLAY_URLS+=("${url%%|*}")
|
||||
label="${url%%|*}"
|
||||
URL_MAP["$label"]="${url##*|}"
|
||||
done
|
||||
get_url() {
|
||||
urls=("$@")
|
||||
display_urls=()
|
||||
declare -A url_map
|
||||
for url in "${urls[@]}"; do
|
||||
display_urls+=("${url%%|*}")
|
||||
label="${url%%|*}"
|
||||
url_map["$label"]="${url##*|}"
|
||||
done
|
||||
display_urls+=("Back")
|
||||
url_map["Back"]="Back"
|
||||
|
||||
SELECTION="$(printf "%s\n" "${DISPLAY_URLS[@]}" | rofi -theme-str 'window {width: 25%;} listview {columns: 1; lines: 10;}' -theme ~/.config/rofi/launchers/type-2/style-2.rasi -dmenu -l 5 -i -p "Select Documentation")"
|
||||
URL="${URL_MAP[$SELECTION]}"
|
||||
$BROWSER "$URL" &>/dev/null &
|
||||
selection="$(printf "%s\n" "${display_urls[@]}" | rofi -theme-str 'window {width: 25%;} listview {columns: 1; lines: 10;}' -theme ~/.config/rofi/launchers/type-2/style-2.rasi -dmenu -l 5 -i -p "Select Documentation")"
|
||||
url="${url_map[$selection]}"
|
||||
|
||||
if [ -z "$url" ]; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
printf "%s\n" "$url"
|
||||
}
|
||||
|
||||
get_docs_list() {
|
||||
selection="$(printf "%s\n" "${OPTIONS[@]}" | rofi -theme-str 'window {width: 25%;} listview {columns: 1; lines: 10;}' -theme ~/.config/rofi/launchers/type-2/style-2.rasi -dmenu -l 5 -i -p "Select Documentation Group")"
|
||||
case "$selection" in
|
||||
"Arch Linux (btw)")
|
||||
urls=("${ARCH[@]}")
|
||||
;;
|
||||
"Hyprland")
|
||||
urls=("${HYPRLAND[@]}")
|
||||
;;
|
||||
*)
|
||||
exit 0
|
||||
;;
|
||||
esac
|
||||
|
||||
printf "%s\n" "${urls[@]}"
|
||||
}
|
||||
|
||||
main() {
|
||||
urls=("$(get_docs_list)")
|
||||
url="$(get_url "${urls[@]}")"
|
||||
if [ -z "$url" ]; then
|
||||
printf "No URL selected.\n"
|
||||
exit 0
|
||||
elif [ "$url" == "Back" ]; then
|
||||
main
|
||||
exit 0
|
||||
fi
|
||||
$BROWSER "$url" &>/dev/null &
|
||||
}
|
||||
|
||||
main
|
||||
|
||||
Reference in New Issue
Block a user