-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path_zpotify
43 lines (42 loc) · 2.71 KB
/
_zpotify
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
#compdef zpotify
_zpotify() {
local state line
_arguments -s \
'1: :->cmd' \
'*: :->args'
case $state in
cmd)
main_commands=('print\:"Display current track info in a specific format" search\:"Search a track, playlist, album, or artist with a TUI" play\:"Play a track, playlist, album, or artist from your library" pause\:"Toggle pause state" prev\:"Skip to previous track" next\:"Skip to next track" repeat\:"Get/Set repeat mode" shuffle\:"Toggle shuffle mode" seek\:"Skip to a specific time (seconds) of the current track" vol\:"Get/Set volume" like\:"Add the current track to your liked songs" devices\:"List all available devices" transfer\:"Transfer playback to another device" waybar\:"Display infos about the current playback for a waybar module" logout\:"Remove the stored credentials from the config file" help\:"Display information about a command" version\:"Display program version"')
main_commands=($main_commands)
_alternative "args:command:(($main_commands))"
;;
args)
case $line[1] in
print)
format_options=('{title}\:"prints the title of the current track" {state}\:"prints the current playback state" {album}\:"prints the name of the current album" {artist}\:"prints the name of the first artist of the current track" {artists}\:"prints all artists" {device}\:"prints the name of the current device" {volume}\:"prints the current volume" {repeat}\:"prints the current repeat state" {shuffle}\:"prints the current shuffle state" {bar\\\:50}\:"prints a progress bar" {progress}\:"prints the current progress as min:sec" {duration}\:"prints the duration of the current track as min:sec" {url}\:"prints the URL of the current track" {image}\:"prints the URL of the current track album cover" {icon}\:"prints the URL of the current track album cover with the smallest size"')
format_options=($format_options)
_arguments -s "*:format:(($format_options))"
;;
play|search)
_arguments -s "2:query_type:(track playlist album artist)"
;;
repeat)
_arguments -s "2:repeat_mode:(track context off)"
;;
seek)
_arguments -s "2:seconds:(0:00 $(zpotify print {duration} 2>/dev/null))"
;;
vol)
_arguments -s "2:volume:(up down $(zpotify print {volume} 2>/dev/null))"
;;
transfer)
devices=$(zpotify devices _name 2>/dev/null)
_arguments -s "2:device:(($devices))"
;;
help)
_arguments -s "2:commands:(print search play pause prev next repeat shuffle seek vol like devices transfer waybar logout help version)"
;;
esac
;;
esac
}