dmenu

Repositório dmenu
git clone git://git.sivaldodavi.com/dmenu.git
Log | Files | Refs | README

dmenu_run (1648B)


      1 #!/bin/sh
      2 
      3 categoria=$(printf '%s\n' "Programas" "Arquivos" "Links" | dmenu -i -p "Menu:")
      4 [ -z "$categoria" ] && exit 0
      5 
      6 case "$categoria" in
      7 
      8 Programas)
      9     choice=$(dmenu_path | dmenu "$@")
     10     [ -z "$choice" ] && exit 0
     11     echo "$choice" | "${SHELL:-/bin/sh}" &
     12     ;;
     13 
     14 Arquivos)
     15     _find_in() { [ -d "$1" ] && find "$1" -name ".git" -prune -o -type f -print 2>/dev/null; }
     16 
     17     sel=$(
     18         { _find_in "$DIR_NOTES"
     19           _find_in "$XDG_DOCUMENTS_DIR"
     20           _find_in "$XDG_VIDEOS_DIR"
     21           _find_in "$XDG_PICTURES_DIR"
     22           _find_in "$HOME/.local/bin"
     23         } | sed \
     24             -e "s|^$HOME/.local/bin/|bin/|" \
     25             -e "s|^$HOME/||" \
     26         | dmenu -i -l 20 -p "Arquivo:"
     27     )
     28     [ -z "$sel" ] && exit 0
     29 
     30     case "$sel" in
     31         bin/*) path="$HOME/.local/bin/${sel#bin/}" ;;
     32         *)     path="$HOME/$sel" ;;
     33     esac
     34 
     35     [ -f "$path" ] || exit 1
     36 
     37     open "$path"
     38     ;;
     39 
     40 Links)
     41     BM_FILE="${XDG_DATA_HOME:-$HOME/.local/share}/bookmarks"
     42     SEARCH_URL="https://search.undertale.uk/search?q="
     43     mkdir -p "$(dirname "$BM_FILE")"
     44     [ -f "$BM_FILE" ] || touch "$BM_FILE"
     45 
     46     sel=$(tac "$BM_FILE" 2>/dev/null | dmenu -i -l 20 -p "Web:")
     47     [ -z "$sel" ] && exit 0
     48 
     49     case "$sel" in
     50         "y! "*)
     51             yt "${sel#y! }" & ;;
     52         "p! "*)
     53             q=$(printf '%s' "${sel#p! }" | tr ' ' '+')
     54             $BROWSER "${SEARCH_URL}${q}" & ;;
     55         http://*|https://*)
     56             $BROWSER "$sel" & ;;
     57         www.*)
     58             $BROWSER "https://$sel" & ;;
     59         *)
     60             q=$(printf '%s' "$sel" | tr ' ' '+')
     61             $BROWSER "${SEARCH_URL}${q}" & ;;
     62     esac
     63     ;;
     64 
     65 esac