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