2025-08-11 00:47:47 +03:30
|
|
|
#!/bin/sh
|
2025-07-21 12:57:44 +03:30
|
|
|
|
2025-08-11 00:47:47 +03:30
|
|
|
WMENU="wmenu"
|
|
|
|
DMENU="dmenu"
|
2025-08-15 16:33:23 +03:30
|
|
|
BROWSER="firefox-bin"
|
2025-08-11 00:47:47 +03:30
|
|
|
NOTIFY="notify-send"
|
2025-07-21 12:57:44 +03:30
|
|
|
|
2025-08-11 00:47:47 +03:30
|
|
|
CHOICES="Paulgo
|
|
|
|
URL
|
|
|
|
Incognito URL
|
|
|
|
YouTube
|
|
|
|
Codeberg
|
|
|
|
Tildegit
|
|
|
|
IPLeak
|
|
|
|
Safebooru
|
|
|
|
Wikipedia"
|
2025-07-21 12:57:44 +03:30
|
|
|
|
2025-08-11 00:47:47 +03:30
|
|
|
notify() {
|
|
|
|
"$NOTIFY" "$1" "$2" 2>/dev/null
|
|
|
|
}
|
2025-07-22 11:21:55 +03:30
|
|
|
|
2025-08-11 00:47:47 +03:30
|
|
|
run_wmenu() {
|
|
|
|
printf '%s\n' "$1" | $WMENU -p "$2"
|
|
|
|
}
|
2025-07-22 11:21:55 +03:30
|
|
|
|
2025-08-11 00:47:47 +03:30
|
|
|
run_dmenu() {
|
|
|
|
printf '' | $DMENU -p "$1"
|
|
|
|
}
|
2025-07-22 11:21:55 +03:30
|
|
|
|
2025-08-11 00:47:47 +03:30
|
|
|
urlencode() {
|
|
|
|
python3 -c "import sys, urllib.parse as ul; print(ul.quote_plus(sys.argv[1]))" "$1"
|
|
|
|
}
|
2025-07-31 01:51:10 +03:30
|
|
|
|
2025-08-11 00:47:47 +03:30
|
|
|
open_url() {
|
|
|
|
url="$1"
|
|
|
|
if pgrep -x "$BROWSER" >/dev/null; then
|
|
|
|
"$BROWSER" --new-tab "$url" &
|
|
|
|
else
|
|
|
|
"$BROWSER" "$url" &
|
|
|
|
fi
|
|
|
|
}
|
2025-07-22 11:21:55 +03:30
|
|
|
|
2025-08-11 00:47:47 +03:30
|
|
|
main() {
|
|
|
|
choice=$(run_wmenu "$CHOICES" "Where to?")
|
|
|
|
[ -z "$choice" ] && notify "Error" "No selection made" && exit 1
|
2025-07-31 01:51:10 +03:30
|
|
|
|
2025-08-11 00:47:47 +03:30
|
|
|
case "$choice" in
|
|
|
|
Codeberg)
|
|
|
|
repo=$(run_dmenu "Username & repo (user/repo):")
|
|
|
|
[ -z "$repo" ] && notify "Error" "No input" && exit 1
|
|
|
|
open_url "https://codeberg.org/$repo"
|
|
|
|
;;
|
|
|
|
Tildegit)
|
|
|
|
repo=$(run_dmenu "Username & repo (user/repo):")
|
|
|
|
[ -z "$repo" ] && notify "Error" "No input" && exit 1
|
|
|
|
open_url "https://tildegit.org/$repo"
|
|
|
|
;;
|
|
|
|
IPLeak)
|
|
|
|
open_url "https://ipleak.net"
|
|
|
|
;;
|
|
|
|
Paulgo)
|
|
|
|
query=$(run_dmenu "Search Paulgo:")
|
|
|
|
[ -z "$query" ] && notify "Error" "No input" && exit 1
|
|
|
|
qenc=$(urlencode "$query")
|
|
|
|
open_url "https://paulgo.io/search?q=$qenc"
|
|
|
|
;;
|
|
|
|
Wikipedia)
|
|
|
|
query=$(run_dmenu "Search Wikipedia:")
|
|
|
|
[ -z "$query" ] && notify "Error" "No input" && exit 1
|
|
|
|
qenc=$(urlencode "$query")
|
|
|
|
open_url "https://en.wikipedia.org/wiki/Special:Search?search=$qenc"
|
|
|
|
;;
|
|
|
|
URL)
|
|
|
|
url=$(run_dmenu "Enter URL:")
|
|
|
|
[ -z "$url" ] && notify "Error" "No URL entered" && exit 1
|
|
|
|
case "$url" in
|
|
|
|
http*) ;;
|
|
|
|
*) url="https://$url" ;;
|
|
|
|
esac
|
|
|
|
open_url "$url"
|
|
|
|
;;
|
|
|
|
"Incognito URL")
|
|
|
|
url=$(run_dmenu "Enter incognito URL:")
|
|
|
|
[ -z "$url" ] && notify "Error" "No URL entered" && exit 1
|
|
|
|
case "$url" in
|
|
|
|
http*) ;;
|
|
|
|
*) url="https://$url" ;;
|
|
|
|
esac
|
|
|
|
"$BROWSER" --private-window "$url" &
|
|
|
|
;;
|
|
|
|
YouTube)
|
|
|
|
query=$(run_dmenu "Search YouTube:")
|
|
|
|
[ -z "$query" ] && notify "Error" "No input" && exit 1
|
|
|
|
qenc=$(urlencode "$query")
|
|
|
|
open_url "https://youtube.com/results?search_query=$qenc"
|
|
|
|
;;
|
|
|
|
Safebooru)
|
|
|
|
query=$(run_dmenu "Search Safebooru:")
|
|
|
|
[ -z "$query" ] && notify "Error" "No input" && exit 1
|
|
|
|
qenc=$(urlencode "$query")
|
|
|
|
open_url "https://safebooru.org/index.php?page=post&s=list&tags=$qenc"
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
notify "Error" "Invalid selection: $choice"
|
|
|
|
exit 1
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
}
|
2025-07-22 11:21:55 +03:30
|
|
|
|
2025-08-11 00:47:47 +03:30
|
|
|
for cmd in "$WMENU" "$DMENU" "$BROWSER" "$NOTIFY"; do
|
|
|
|
if ! command -v "$cmd" >/dev/null 2>&1; then
|
|
|
|
echo "Error: required command '$cmd' not found" >&2
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
|
|
|
|
main
|
2025-07-31 01:51:10 +03:30
|
|
|
|