sistema_progs

Programas para customizar o meu entorno de traballo nos meus equipos persoais
Log | Files | Refs

launch (1057B)


      1 #!/usr/bin/env sh
      2 
      3 # Description: Independent POSIX-compliant GUI application launcher.
      4 #              Fuzzy find executables in $PATH and launch an application.
      5 #              stdin, stdout, stderr are suppressed so CLI tools exit silently.
      6 #
      7 #              To configure launch as an independent app launcher add a keybind
      8 #              to open launch in a terminal e.g.,
      9 #
     10 #              xfce4-terminal -e "${XDG_CONFIG_HOME:-$HOME/.config}/nnn/plugins/launch
     11 #
     12 # Dependencies: fzf
     13 #
     14 # Usage: launch [delay]
     15 #        delay is in seconds, if omitted launch waits for 1 sec
     16 #
     17 # Integration with nnn: launch is installed with other plugins, nnn picks it up.
     18 #
     19 # Shell: POSIX compliant
     20 # Author: Arun Prakash Jana
     21 
     22 # shellcheck disable=SC2086
     23 
     24 IFS=':'
     25 
     26 get_selection() {
     27     if type fzf >/dev/null 2>&1; then
     28         { IFS=':'; ls -H $PATH; } | sort | fzf
     29     else
     30         exit 1
     31     fi
     32 }
     33 
     34 if selection=$( get_selection ); then
     35     setsid "$selection" 2>/dev/null 1>/dev/null &
     36 
     37     if [ -n "$1" ]; then
     38         sleep "$1"
     39     else
     40         sleep 1
     41     fi
     42 fi