#!/usr/bin/env python3 # # GMUISCBROWSER by Derek Taylor (DistroTube) # A simple script that creates an openbox pipemenu that controls gmusicbrowser. # # This program is free software: you can redistribute it and/or modify it under the terms of # the GNU General Public License version 3 as published by the Free Software Foundation. # This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without # even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License along # with this program. If not, see: http://www.gnu.org/licenses # # Copy this file somewhere on your path and make it executable. # Add the following line somewhere to your /.config/openbox/menu.xml # # Be sure to change the PATH/TO to the correct path to this file. # # Reconfigure openbox. # # REQUIRES the gmusicbrowser music player to be installed on your computer. # The playlist submenu is designed to pull all .m3u files from the ~home/$USER/.config/gmusicbrowser/ directory. # Therefore, you must create this folder and export your playlists to this folder. # To enable song information to display, you must enable the NOW PLAYHING plugin in gmusicbrowser. # Add this to "command for when playing song changed": tee /home/$USER/.config/gmusicbrowser/nowplaying.info # Change $USER to your actual username. Tick the checkbox for send title/artist/album in standard input. # You also should go to Preferences > Misc. and tick the checkbox for remember playing position between sessions. # This allows gmusicbrowser to remember the song it was playing within the playlist upon exit. # SETTING import subprocess import os playlistDir = '/home/derek/.config/gmusicbrowser/' cmd1 = "cat /home/derek/.config/gmusicbrowser/*.info | sed -n -e 's/^.*Title=//p' | tr -d '\"'" process = subprocess.Popen(cmd1, stdout=subprocess.PIPE, shell=True) songTitle = process.communicate()[0].decode("utf-8").rstrip() cmd2 = "cat /home/derek/.config/gmusicbrowser/*.info | sed -n -e 's/^.*Artist=//p' | tr -d '\"'" process = subprocess.Popen(cmd2, stdout=subprocess.PIPE, shell=True) songArtist = process.communicate()[0].decode("utf-8").rstrip() cmd3 = "cat /home/derek/.config/gmusicbrowser/*.info | sed -n -e 's/^.*Album=//p' | tr -d '\"'" process = subprocess.Popen(cmd3, stdout=subprocess.PIPE, shell=True) songAlbum = process.communicate()[0].decode("utf-8").rstrip() cmd4 = "cat /home/derek/.config/gmusicbrowser/*.info | sed -n -e 's/^.*Length=//p' | tr -d '\"'" process = subprocess.Popen(cmd4, stdout=subprocess.PIPE, shell=True) songLength = process.communicate()[0].decode("utf-8").rstrip() cmd5 = "cat /home/derek/.config/gmusicbrowser/*.info | sed -n -e 's/^.*Year=//p' | tr -d '\"'" process = subprocess.Popen(cmd5, stdout=subprocess.PIPE, shell=True) songYear = process.communicate()[0].decode("utf-8").rstrip() cmd6 = "cat /home/derek/.config/gmusicbrowser/*.info | sed -n -e 's/^.*Track=//p' | tr -d '\"'" process = subprocess.Popen(cmd6, stdout=subprocess.PIPE, shell=True) songTrack = process.communicate()[0].decode("utf-8").rstrip() cmd7 = "ls -l /home/derek/.config/gmusicbrowser/*m3u | wc -l | sed -n '1p'" process = subprocess.Popen(cmd7, stdout=subprocess.PIPE, shell=True) playlistNum = process.communicate()[0].decode("utf-8").rstrip() # OPENBOX PIPEMENU print ('') print ('') print ('') print ('gmusicbrowser -cmd PlayPause') print ('gmusicbrowser -cmd PlayPause') print ('') print ('gmusicbrowser -cmd') print ('') print ('') for filename in os.listdir('/home/derek/.config/gmusicbrowser/'): plist = "echo "+filename+" | rev | cut -d\"/\" -f1 | rev" process = subprocess.Popen(plist, stdout=subprocess.PIPE, shell=True) playlist = process.communicate()[0].decode("utf-8").rstrip() if playlist.endswith(".m3u"): print ('gmusicbrowser '+playlistDir+filename+'') print ('') print ('') print ('gmusicbrowser -cmd Play') print ('gmusicbrowser -cmd Pause') print ('gmusicbrowser -cmd Stop') print ('gmusicbrowser -cmd NextSong') print ('gmusicbrowser -cmd PrevSong') print ('') print ('gmusicbrowser -cmd IncVolume') print ('gmusicbrowser -cmd DecVolume') print ('') print ('gmusicbrowser -cmd ShowHide') print ('gmusicbrowser -cmd Quit') print ('')