Skip to content

Instantly share code, notes, and snippets.

View bonelifer's full-sized avatar

William Jacoby bonelifer

View GitHub Profile
@bonelifer
bonelifer / mpc-guardian.sh
Last active January 26, 2025 06:23 — forked from moopet/mpc-guardian.sh
With a shared MPD server, sometimes other people will add shit music. Stop the rot. Also watch Christmas genre and limit it to specific date range.
#!/usr/bin/env bash
# Automatically removes songs from your playlist that match a blacklist or the Christmas genre
# unless it is between the day after U.S. Thanksgiving and before January 15.
BLACKLIST=/var/music/blacklist.txt
MPD_HOST=localhost
REJECT_GENRE="Christmas"
# Define the date range
@bonelifer
bonelifer / mpd_delete_duplicates.sh
Created January 26, 2025 05:56 — forked from hiqua/mpd_delete_duplicates.sh
Delete duplicates from mpd playlist
#!/usr/bin/bash
# Script: MPD Duplicate Removal
# Purpose: This script identifies and removes duplicate entries from an MPD playlist.
# It finds the first duplicate based on file names, and removes it from the playlist.
# The script continues removing duplicates until there are no more left.
#
# Functions:
# 1. mpd_first_duplicate: Identifies the position of the first duplicate file in the playlist.
# 2. mpd_delete_duplicates: Loops through the playlist and deletes duplicates using the first function.
#!/bin/bash
# Send notification with album art (if found) when mpd plays a new song, depends on libnotify
readonly MUSIC_DIR="${HOME}/Music"
while true; do
SONG_PATH="$(mpc --format '%file%' current --wait)"
if [[ ! -z "$SONG_PATH" ]]; then # check if song is being played
SONG_DIR="$(dirname "${SONG_PATH}")"
#!/usr/bin/env bash
# -----------------------------------------------------------------------------
# Script: mpc_state_manager.sh
# Description:
# This script manages saving and loading the current track and playback state
# of the MPD (Music Player Daemon) client `mpc` to/from a file. It provides
# two main operations:
# 1. Saving the current track and its state (playing/paused) into a file.
# 2. Loading a previously saved track and state, and resuming playback.
@bonelifer
bonelifer / mpc-control.sh
Created January 26, 2025 05:11 — forked from kenanpelit/gist:e5eea8618a813ac20da3cbffafcb9556
mpc-control - full function
#!/usr/bin/env bash
# Icon Definitions (Nerd Font Icons)
# Define custom icons for different playback states (play, pause, stop, etc.)
PLAY_ICON="󰐊"
PAUSE_ICON="󰏤"
STOP_ICON="󰓛"
NEXT_ICON="󰒭"
PREV_ICON="󰒮"
VOLUME_UP_ICON="󰝝"
@bonelifer
bonelifer / mpc.sh
Last active January 26, 2025 05:04 — forked from kostix/mpc.sh
mpc wrapper with a bit of interactivity
#!/bin/sh
# This script interacts with the `mpc` (Music Player Client) to manage playlists in MPD (Music Player Daemon).
# It allows the user to perform operations such as:
# - Viewing the current playlist with enumerated items.
# - Selecting, loading, or replacing playlists interactively.
# - Clearing the current playlist and loading a new one.
# Usage:
# - Run the script with no arguments to execute `mpc` commands.
# - Use specific arguments like 'playlist', 'iload', or 'replace' to invoke specialized functions.
@bonelifer
bonelifer / my-mpc
Last active January 26, 2025 04:52 — forked from jladan/my-mpc
Bash script for easy MPD hotkeys
#!/usr/bin/env bash
# Script to interact with the music queue and manage song ratings and statuses using "stickers"
# The stickers feature is used for marking songs with specific labels (e.g., "broken" or "rating").
# This script supports rating songs, flagging songs as "bad" (broken), removing songs from the queue,
# listing songs flagged as bad, and jumping to a random song in the queue.
# Ratings are compatible with clients such as Cantata, mpedv, and myMPD.
# Function to display usage instructions
usage () {
@bonelifer
bonelifer / mpd-notify.sh
Last active January 26, 2025 04:35 — forked from Jipok/mpd-notifications
Show music info(with cover) for mpd. Will show gray cover, when paused. defaultimage can be found here: https://williamjacoby.net/files/unknown.jpg
#!/bin/bash
expireTime="9200"
mpddir="/media/william/NewData/Music/MP3B/"
defaultimage="$mpddir/unknown.jpg"
update_cover() {
path=$mpddir$(mpc -f %file% current)
album=$(mpc -f %file% current)
ffmpeg -loglevel quiet -y -i "$path" /tmp/cover
@bonelifer
bonelifer / mpd_skipper.service
Last active January 26, 2025 02:59 — forked from Pigpog/skipdetect.sh
FOR MPD - Skips songs you don't like. Uses a per-song score, calculated based on whether you skip the song or let it play. The only dependencies are `mpc` and `argparse(python module)` , as this script is implemented entirely in Python 3. When the next song's score is negative, the script "rolls the dice," and if the score is less than or equal …
[Unit]
Description=MPD Song Skipper
After=mpd.service
Wants=mpd.service
[Service]
ExecStart=/usr/bin/python3 /path/to/your/script/skipdetect.py -d
ExecStop=/usr/bin/python3 /path/to/your/script/skipdetect.py -k
Restart=on-failure
RestartSec=5
@bonelifer
bonelifer / client.py
Created January 24, 2025 01:30 — forked from sjlongland/client.py
mpd music selection algorithm
#!/usr/bin/env python
# vim: ai ts=4 sw=4 sts=4 expandtab fileencoding=utf-8
from mpd import MPDClient
## SETTINGS
##
HOST = 'localhost'
PORT = '6600'
PASSWORD = False