mirror of
https://github.com/ksyasuda/dotfiles.git
synced 2025-12-05 02:53:38 -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%%|*}")
|
||||
get_url() {
|
||||
urls=("$@")
|
||||
display_urls=()
|
||||
declare -A url_map
|
||||
for url in "${urls[@]}"; do
|
||||
display_urls+=("${url%%|*}")
|
||||
label="${url%%|*}"
|
||||
URL_MAP["$label"]="${url##*|}"
|
||||
done
|
||||
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
|
||||
|
||||
@@ -7,5 +7,7 @@ DIR="$HOME/Pictures/wallpapers/favorites"
|
||||
SELECTED_WALL=$(cd "$DIR" && for a in *.jpg *.png; do echo -en "$a\0icon\x1f$a\n"; done | rofi -dmenu -i -no-custom -theme "$THEME" -p "Select a wallpaper" -theme-str 'configuration {icon-size: 128; dpi: 96;} window {width: 45%; height: 45%;}')
|
||||
PTH="$(printf "%s" "$DIR/$SELECTED_WALL" | tr -s '/')"
|
||||
notify-send -a "rofi-wallpaper" "Wallpaper set to" -i "$PTH" "$PTH"
|
||||
hyprctl hyprpaper preload "$PTH"
|
||||
hyprctl hyprpaper wallpaper "DP-1,$PTH"
|
||||
hyprctl hyprpaper unload "$(cat "$HOME/.wallpaper")"
|
||||
echo "$PTH" >"$HOME/.wallpaper"
|
||||
hyprctl hyprpaper reload , "$PTH"
|
||||
|
||||
Reference in New Issue
Block a user