-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmpdctl.lib
More file actions
executable file
·101 lines (86 loc) · 2.4 KB
/
mpdctl.lib
File metadata and controls
executable file
·101 lines (86 loc) · 2.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
#!/usr/bin/env bash
#
# ############################################################################
# Project: scripts (none)
# File...: mpdctl.lib
# Created: Thursday, 2023/07/20 - 00:02:53
# Author.: @fbnmtz, (fabiano.matoz@gmail.com)
# ~·~·~·~·~·~·~·~·~·~·~·~·~~·~·~·~·~·~·~·~·~·~·~·~·~~·~·~·~·~·~~·~·~·~·~·~·~·~
# Last Modified: Wednesday, 2023/09/27 - 02:13:37
# Modified By..: @fbnmtz, (fabiano.matoz@gmail.com)
# ~·~·~·~·~·~·~·~·~·~·~·~·~~·~·~·~·~·~·~·~·~·~·~·~·~~·~·~·~·~·~~·~·~·~·~·~·~·~
# Version: 0.0.10.220
# ~·~·~·~·~·~·~·~·~·~·~·~·~~·~·~·~·~·~·~·~·~·~·~·~·~~·~·~·~·~·~~·~·~·~·~·~·~·~
# Description:
# >
# ############################################################################
# HISTORY:
#
_xLIB_MPDCTL_=true
# set ROFI command and arguments
_MENU_CMD_="rofi -no-config -dmenu -i -p"
# validates installation of required binaries
xrequirements rofi watch pgrep cut aw
_mpd_check_(){
if [ "$f" != 'r' ] && ! pgrep mpd >/dev/null; then
echo "Error! MPD is not running."
exit 1
fi
}
mUpdate(){
mpc update --wait; mpc rescan --wait
}
mPlayAll(){
mpc listall | mpc add; mpc play
}
mListPlay(){
local music index
music=$(mpc playlist | $_MENU_CMD_ "Select one Music" -format "d%s");
if [ -n "$music" ]; then
index=$(echo "$music" | cut -d '%' -f1)
echo "$music";
echo "$index"
mpc play "$index"
fi
}
mPlaylists(){
local menu_items choice
menu_items="all;Play all songs\nclear;Empty current queue\n------\n$(_lists_info | sort -f)"
choice=$(echo -en "$menu_items" | column -t -s ';' | $_MENU_CMD_ "Playlist Functions" | aw 1)
if [ -n "$choice" ]; then
case "$choice" in
clear) queue_clear ;;
all ) queue_all ;;
* ) queue_playlist "$choice";;
esac
fi
}
mWatch(){
watch -n 1 mpc status
}
_lists_info(){
for i in $(mpc lsplaylists); do
echo -en "$i;($(mpc playlist $i | wc -l) Músicas)\n"
done
}
queue_clear(){
mpc clear
}
queue_all(){
mpc listall | mpc add
}
queue_playlist(){
mpc clear && mpc load "$choice" && mpc play
}
mOptions(){
if [ -n "$value" ]; then
for opt in $(echo "$value" | cut -d ',' -f1); do
case "$opt" in
s|single ) mpc single ;;
r|repeat ) mpc repeat ;;
z|shuffle) mpc shuffle ;;
* ) echo "Invalid option!" ;;
esac
done
fi
}