rj1
about | log | files | refs | license
commit ef99d26cdc30c86d22f028eb724043cd57599e72
author: rj1 <[email protected]>
date:   Sun,  4 Dec 2022 20:11:00 -0600

first

Diffstat:
ALICENSE | 21+++++++++++++++++++++
AREADME.md | 18++++++++++++++++++
Arofimpd | 76++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
3 files changed, 115 insertions(+), 0 deletions(-)

diff --git a/LICENSE b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2022 rj1 <[email protected]> + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/README.md b/README.md @@ -0,0 +1,18 @@ +# rofimpd + +barebones mpd client using rofi + mpc to select the music you're listening to + +## todo + +funcionality for: +- [ ] creating playlists +- [ ] adding tracks/albums/artists to current playlist + +## screenshot + +![](https://rj1.localghost.org/img/rofimpd-sshot.png) + +## alternatives +https://github.com/JakeStanger/Rofi_MPD +https://github.com/Marco98/rofi-mpc +https://github.com/magnouvean/rofi-mpc diff --git a/rofimpd b/rofimpd @@ -0,0 +1,76 @@ +#!/bin/sh + +launcher() { + rofi -mesg "$current" -i -dmenu -p "$1" +} + +# sed for pango markup +current=$(mpc current | sed 's/&/\&amp;/g; s/</\&lt;/g; s/>/\&gt;/g; s/"/\&quot;/g; s/'"'"'/\&#39;/g') +if [[ -z "$current" ]]; then + current="mpd isn't playing anything right now" +else + current="current track: ${current}" +fi + +# modes +modes="current playlist\nplaylists\nshuffle\ntracks\nalbums\nartists" +mode=$(echo -e "$modes" | launcher "mpd: ") + +# tracks in current playlist +if [[ "$mode" == "current playlist" ]]; then + playlist=$(mpc playlist) + track=0 + tlist="" + while read -r line; do + track=$((track + 1)) + tlist="$tlist[$track] $line\n" + done <<< "$playlist" + track=$(echo -e "$tlist" | launcher "playlist: ") + track=$(expr "$track" : "\[\([^]]*\)\]") + mpc play "$track" + +# list of playlists +elif [[ "$mode" == "playlists" ]]; then + playlist=$(mpc lsplaylists | launcher "choose a playlist" ) + [ ! ${playlist} ] && exit + mpc clear + mpc load "$playlist" + mpc play + +# shuffle mode +elif [[ "$mode" == "shuffle" ]]; then + mpc clear + mpc listall | shuf -n 1000 | mpc add + mpc play + +# list of tracks +elif [[ "$mode" == "tracks" ]]; then + track=$(mpc list title | sort -f | launcher "choose a track: " ) + [ ! ${track} ] && exit + mpc clear + mpc search "(title==\"${track}\")" | mpc add + mpc play + +# list of albums +elif [[ "$mode" == "albums" ]]; then + album="$(mpc list album | sort -f | launcher "choose an album: ")" + [ ! ${album} ] && exit + mpc clear + mpc find album "${album}" | mpc add + mpc play + +# list of artists +elif [[ "$mode" == "artists" ]]; then + + # list artists + artist="$(mpc list artist | sort -f | launcher "choose an artist: ")" + [ ! ${artist} ] && exit + + # list albums from chosen artist + album="$(mpc list album artist "${artist}" | launcher "choose album: ")" + [ ! ${album} ] && exit + + mpc clear + mpc find artist "$artist" album "$album" | mpc add + mpc play +fi