dotfiles-x112959479
add tms, madd
+45 −0
2 files changed
- A .local/bin/madd +20 −0
- A .local/bin/tms +25 −0
| @@ -0,0 +1,20 @@ | |||
| 1 | + | #!/bin/sh | |
| 2 | + | ||
| 3 | + | madd() { | |
| 4 | + | queue="$(mpc playlist)" | |
| 5 | + | if [ -z "$queue" ]; then | |
| 6 | + | mpc insert "$filename" | |
| 7 | + | mpc play | |
| 8 | + | else | |
| 9 | + | mpc insert "$filename" | |
| 10 | + | mpc next | |
| 11 | + | fi | |
| 12 | + | } | |
| 13 | + | ||
| 14 | + | filename=$(mpc listall | dmenu -i -l 30) | |
| 15 | + | if [ -z "$filename" ]; then | |
| 16 | + | notify-send "Nothing was selected. Skipping." | |
| 17 | + | else | |
| 18 | + | madd | |
| 19 | + | fi | |
| 20 | + | ||
| @@ -0,0 +1,25 @@ | |||
| 1 | + | #!/bin/env bash | |
| 2 | + | ||
| 3 | + | if [[ $# -eq 1 ]]; then | |
| 4 | + | selected=$1; | |
| 5 | + | else | |
| 6 | + | selected=$(find ~/code/dev ~/code/repos ~/code/rust -mindepth 1 -maxdepth 1 -type d | fzf); | |
| 7 | + | fi | |
| 8 | + | ||
| 9 | + | if [[ -z $selected ]]; then | |
| 10 | + | exit 0 | |
| 11 | + | fi | |
| 12 | + | ||
| 13 | + | selected_name=$(basename "$selected" | tr . _) | |
| 14 | + | tmux_running=$(pgrep tmux) | |
| 15 | + | ||
| 16 | + | if [[ -z $TMUX ]] && [[ -z $tmux_running ]]; then | |
| 17 | + | tmux new-session -s $selected_name -c $selected | |
| 18 | + | exit 0 | |
| 19 | + | fi | |
| 20 | + | ||
| 21 | + | if ! tmux has-session -t=$selected_name 2> /dev/null; then | |
| 22 | + | tmux new-session -ds $selected_name -c $selected | |
| 23 | + | fi | |
| 24 | + | ||
| 25 | + | tmux switch-client -t $selected_name | |