-
Notifications
You must be signed in to change notification settings - Fork 0
/
cmus-wish.sh
executable file
·100 lines (89 loc) · 2.29 KB
/
cmus-wish.sh
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
#!/usr/bin/wish
#cmus remote control
#variables
set cmus "/usr/bin/cmus"
set cmusr "/usr/bin/cmus-remote"
global cmus
global cmusr
#widow name
wm title . "Cmus control"
#procesos
#puts $test
if { [catch {exec cmus-remote -Q} ] } {
exec terminal -e cmus ; exec sleep 2; exec cmus-remote -p
}
proc stop {} {
global cmusr
exec killall cmus &
}
proc next {} {
global cmusr
exec $cmusr -n &
notify
Log
}
proc prev {} {
global cmusr
exec $cmusr -r &
}
proc pause {} {
global cmusr
exec $cmusr -u &
}
#shuffle functions
proc shuffleon { } {
global cmusr Shuffle
set Shuffle "Shuffle On"
exec $cmusr -S &
set isshuf [eval exec "cmus-remote -Q | grep shuffle | cut -d { } -f 3"] ;
if { $isshuf == "false" } {
set Shuffle "Shuffle off"
}
}
#notify-osd
proc notify { } {
set Cur_song [ exec cmus-remote -Q | grep tag | head -n 3 | sort -r | cut -d { } -f 3-]
exec notify-send -i multimedia-volume-control -t 1800 $Cur_song
}
#log music
proc Log { } {
global log
set line [exec cmus-remote -Q | grep tag | head -n 3 | sort -r | cut -d { } -f 3- | column -c 150]
$log insert end $line\n
$log see end
#puts [exec cmus-remote -Q | grep tag | cut -d { } -f 3- | column]
}
#cmus-remote -Q | grep tag | head -n 3 | sort -r | cut -d ' ' -f 3- | column -c 100
#open file
set types {
{"Music Files" {.mp3 .ogg } }
{"All files" *}
}
proc onSelect { } {
global types
set file [tk_getOpenFile -filetypes $types -parent .]
exec cmus-remote -f $file
}
wm title . "openfile"
proc screen {} {
frame .top -borderwidth 10
pack .top -fill x
button .top.shuffle -text "Shuffle" -textvariable Shuffle -command shuffleon
button .top.next -text "Next" -command next
button .top.prev -text "Prev" -command prev
button .top.pause -text "Pause" -command pause
button .top.file -text "Select a file" \
-command "onSelect"
pack .top.prev .top.pause .top.next .top.shuffle .top.file -side left -padx 0p -pady 0
global log
frame .t
set log [text .t.log -width 130 -height 10 \
-borderwidth 2 -relief raised -setgrid true \
-yscrollcommand {.t.scroll set}]
scrollbar .t.scroll -command {.t.log yview}
pack .t.scroll -side right -fill y
pack .t.log -side left -fill both -expand true
pack .t -side top -fill both -expand true
}
screen
shuffleon