2 changed files with 59 additions and 0 deletions
@ -0,0 +1,58 @@ |
|||||||
|
#!/usr/bin/env tclsh |
||||||
|
|
||||||
|
# Ghetto MPD controller |
||||||
|
|
||||||
|
package require Tk |
||||||
|
|
||||||
|
set music_directory "/mnt/DATA/Музыка/" |
||||||
|
|
||||||
|
array set buttons { |
||||||
|
prev 玲 |
||||||
|
toggle ▶ |
||||||
|
next 怜 |
||||||
|
} |
||||||
|
|
||||||
|
proc mpc {args} { |
||||||
|
exec mpc {*}$args |
||||||
|
} |
||||||
|
|
||||||
|
proc current_file {} { |
||||||
|
lindex [split [exec mpc -f {%file%}] "\n"] 0 |
||||||
|
} |
||||||
|
|
||||||
|
proc rate {rating} { |
||||||
|
set filename [file join $::music_directory [current_file]] |
||||||
|
|
||||||
|
exec mid3v2 --delete-frames=COMM $filename |
||||||
|
exec mid3v2 --COMM $rating $filename |
||||||
|
|
||||||
|
mpc update |
||||||
|
} |
||||||
|
|
||||||
|
proc update_status {} { |
||||||
|
set ::mpd_status [mpc] |
||||||
|
after 500 update_status |
||||||
|
} |
||||||
|
|
||||||
|
update_status |
||||||
|
|
||||||
|
frame .status |
||||||
|
frame .rating -pady 10 |
||||||
|
frame .control -pady 10 |
||||||
|
|
||||||
|
pack .status -fill x -expand true -padx 20 -pady 20 |
||||||
|
pack [label .status.current -font {Sans 20} -textvariable ::mpd_status] |
||||||
|
|
||||||
|
pack .rating |
||||||
|
foreach rating {1 2 3 4 5 5+} { |
||||||
|
pack [button .rating.$rating -text $rating -font {Sans 60} -width 2 -command "rate $rating"] -side left |
||||||
|
} |
||||||
|
|
||||||
|
pack .control |
||||||
|
foreach btn {prev toggle next} { |
||||||
|
pack [button .control.$btn -text $buttons($btn) -font {Sans 80} -width 4 -command "mpc $btn"] -side left |
||||||
|
} |
||||||
|
|
||||||
|
bind . <KeyPress-Control_L><KeyPress-q> exit |
||||||
|
bind . <KeyPress-Control_R><KeyPress-q> exit |
||||||
|
|
Loading…
Reference in new issue