Last active
February 7, 2025 00:54
-
-
Save eugene-eeo/7203603df18a7a99538d6a54d3961cc9 to your computer and use it in GitHub Desktop.
lightweight rofi alternative
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
GEOMETRY="80x20+570+300" | |
_st_fzf() { | |
fzf +m --tiebreak=length,end --layout=reverse --color=prompt:7,pointer:7,spinner:2,info:8,hl:2,hl+:2,marker:0 --margin=1,2 --prompt='∴ ' $@ | |
} | |
_st_run() { | |
st -t 'st-launch' -a -g $GEOMETRY -e "$0" "$1" & | |
} | |
case "$1" in | |
# for some weird reason we need to sleep when we run pdetach | |
# to prevent it from exiting prematurely | |
_run) | |
f=$(compgen -c | sort | grep -v '[:!.{}]\|\[\[\|]]\|\[' | _st_fzf) | |
if [ $? = 0 ]; then | |
pdetach "$f" | |
sleep 0.25 | |
fi | |
;; | |
_filter) | |
f=$(find ~ -name '.*' -prune -o -print | _st_fzf) | |
if [ $? = 0 ]; then | |
pdetach xdg-open "$f" | |
sleep 0.25 | |
fi | |
;; | |
_window) | |
window_ids=$(xprop -root | grep '^_NET_CLIENT_LIST(WINDOW)' | cut -d ' ' -f5-) | |
IFS=', ' read -ra IDS <<< "$window_ids" | |
choice=$( | |
for wid in "${IDS[@]}"; do | |
name=$(xwininfo -id "$wid" -wm | grep '^xwininfo:' | cut -d ' ' -f 5-) | |
name="${name:1:-1}" | |
[[ $name != 'st-launch' ]] && echo "$wid $name" | |
done | _st_fzf --with-nth 2.. | |
) | |
if [ $? = 0 ]; then | |
xdotool windowactivate $(echo "$choice" | cut -d ' ' -f1) | |
fi | |
;; | |
run) _st_run _run ;; | |
filter) _st_run _filter ;; | |
window) _st_run _window ;; | |
*) echo 'usage: st-launch run' | |
echo ' st-launch filter' | |
echo ' st-launch window' | |
esac |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment