Skip to content

Instantly share code, notes, and snippets.

View bonelifer's full-sized avatar

William Jacoby bonelifer

View GitHub Profile
@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
@bonelifer
bonelifer / mpd-tray.py
Created January 16, 2025 19:37
MPD Tray application(similar to RadioTray-NG) to manage and play categorized radio station URLs.
#!/usr/bin/python3
"""
MPD Tray application(similar to RadioTray-NG) to manage and play categorized radio station URLs.
Provides Stop, Stations (organized by categories), Refresh, and Exit options in the tray menu.
Uses `mpc load URL` equivalent functionality, ensuring reconnection to MPD.
Pressing Stop clears the queue.
"""
# Editable variables
menu_icon = False # Set to True to use system icon (XFce add-folder-to-archive icon), False for custom icon
#!/usr/bin/bash
# Description:
# This script generates a random playlist of tracks from a local music directory using MPC.
# It filters tracks by artist, limits the number of tracks from each artist, and saves the
# generated playlist as an M3U file in the specified playlist directory.
#
# The script:
# - Scans the specified local music directory for MP3 tracks.
# - Filters tracks by artist and limits the number of tracks based on the artist's total.
@bonelifer
bonelifer / mpdsimilar.sh
Created January 10, 2025 20:44
Script description: Fetches similar artist tracks based on the currently playing track or all tracks in the queue.
#!/usr/bin/bash
# Script description: Fetches similar artist tracks based on the currently playing track or all tracks in the queue.
# Accepts arguments:
# -c, --current: Retrieves similar artist tracks for the currently playing track.
# -a, --all: Retrieves similar artist tracks for each track in the current playlist.
# Configurable parameters:
# lastfm_api_key: Last.fm API key (replace LAST_FM_API_KEY).
# similar_limit: Limit for similar artists fetched.
# per_artist_limit: Maximum tracks per similar artist.
# This is a anonymized version of the script I use to renew all my SSL certs
# across my servers. This will not work out of the box for anyone as your network will be
# different. But may be useful starting place for others.
#
# I use a cronjob that runs this every week. It only replaces certificates when a certificate has been renewed.
# Renews/creates cert from letsencrypt & places it where it needs to be.
# Currently, that is:
# * Nginx (local for plex)
# * Plex Media Server
@bonelifer
bonelifer / README.md
Created October 19, 2024 18:04 — forked from thereisnotime/README.md
Install Home Assistant Supervised on Debian 12

Setup HA Supervised on Debian 12

How to Run

  1. Do sudo su
  2. Copy-paste the script (it will reboot the machine)

NOTE: I am using with with Vagrat's shell provisioner as it is easier (with privileged execution).

Next Steps