local/bin/start

   1 #!/bin/bash
   2 
   3 title=${1^}
   4 start(){ xfce4-terminal -T $title -x bash -ic "$@" & }
   5 dmenu(){ rofi -columns $1 -dmenu -i -p "$title" "${@:1}"; }
   6 bloge(){ # {{{
   7     n=$(
   8         awk -F \| 'END { print "+" } { print NR ". #" $2 " " substr($3, 1, 70) }' \
   9         ~/Projects/lexa.by/bloge/2019/news.txt | tac | dmenu 2 | cut -d . -f 1
  10     )
  11 
  12     [[ $n ]] && gvim blo$n
  13 } # }}}
  14 dotfiles(){ # {{{
  15     cd ~/.dotfiles
  16     find * -type f -printf '%T+\t%p\n' | sort -r |
  17     cut -f 2 | dmenu 3 -multi-select | xargs -r gvim
  18 } # }}}
  19 kino(){ # {{{
  20     { echo "%) - $(xsel -b)"; tac ~/.config/mpv/history.log; } |
  21     dmenu 1 | awk -F '%) - ' '{ print $2 }' | sed "s|~|$HOME|" |
  22     tr \\n \\0 | xargs -0I % mpv --profile pseudo-gui '%' &
  23 } # }}}
  24 nerdfont(){ # {{{
  25     f=~/.cache/nerdfont
  26 
  27     [[ ! -f $f ]] &&
  28     curl -s https://www.nerdfonts.com/cheat-sheet |
  29     grep 'class-name">nf-' | tr '<>' '\t\t' | cut -f 3,7 |
  30     while read n s; do printf '%b %s\n' "\u$s" "$n"; done > $f
  31 
  32     printf $'\u200e'' %s %s\n' $(< $f) | dmenu 3 -multi-select |
  33     cut -d ' ' -f 2 | tr \\n ' ' | xsel -i
  34 } # }}}
  35 notes(){ # {{{
  36     cd ~/Documents
  37     find *.md -printf '%T+\t%p\n' | sort -r |
  38     cut -f 2 | dmenu 3 -l 3 -multi-select | xargs -r gvim
  39 } # }}}
  40 theme(){ # {{{
  41     wal --theme | while read a b c; do
  42         [[ $a == *Light* ]] && l=' -l'
  43         [[ $a != - || $c ]] && continue
  44         echo "$b$l"
  45     done | dmenu 4 | xargs -r wall --theme
  46 } # }}}
  47 
  48 case ${1,,} in
  49     editor) gvim &;;
  50     files) start ranger;;
  51     terminal) xfce4-terminal &;;
  52 
  53     bloge) bloge;;
  54     mail) start mutt;;
  55     news) start newsboat;;
  56     torrents) start transmission-remote-cli;;
  57     browser) chromium --new-window lexa.by &;;
  58 
  59     kino) kino;;
  60     music) start mocp;;
  61     mixer) pavucontrol &;;
  62 
  63     days) status -n days;;
  64     calendar) start calcurse;;
  65     weather) status -n weather;;
  66 
  67     theme) theme;;
  68     notes) notes;;
  69     dotfiles) dotfiles;;
  70     nerdfont) nerdfont;;
  71     windows) rofi -show window;;
  72     apps) rofi -show drun -columns 2 -show-icons -terminal $0;;
  73 
  74     symbols) gucharmap &;;
  75     redshift) pkill redshift || exec redshift -r &;;
  76     picker) gpick -spo | tr A-Z a-z | tr -d \\n | xsel -i;;
  77 
  78     -l) grep -Po '^\s+[\w^)]+\)' $0 | tr -d ') ' | sort;;
  79     --list) $0 -l | while read i; do echo "$(status -i $i) ${i^}"; done;;
  80 
  81     '') $0 --list | dmenu 5 -l 5 | awk '{ print $NF }' | xargs -r $0;;
  82     -*) shift; title=${1^} start "$*";;
  83      *) start "$*";;
  84 esac