Git-now-playing - Git commits are the new AIM status messages

git-now-playing

git-now-playing is an attempt to bring some of the panache of the early aughts' AIM away messages to your git commits, by including what you're currently listening to when you write a git commit.

It does this by checking in with Spotify and/or Plex every ten seconds to find out what you're listening to, and updating a specified file with that information. You can then use this file as your git commit template. There is some consideration happening about whether "just use a git commit hook, dummy" is a better idea.

Install

There aren't binary releases yet, sorry. I'm lazy and this was a 12 hour nerdsnipe gone awry. So you're gonna need to run go build or go install yourself. go install paddy.dev/git-now-playing should, in theory, do it. Good luck!

Configure

You must use a configuration file when running git-now-playing. You also need to use Vault. Good luck!

Configuration is done mostly through an HCL file:

vault {
  address = "https://my.vault.server:8200/"
  mount_path = "kv_v2_secrets_engine_path"
}

# this block is optional
# if not set, output gets written to $HOME/.config/gitmessage
output {
  path = "/path/where/file/containing/now/playing/track/should/be/written.txt"
}

# this block is optional
# also, you can specify it as many times as you want
# git-now-playing will ask all of them what you're playing
plex {
  server = "https://my.plex.server:32400/"
  
  # this bit is optional and will default to "plex"
  # it's the key inside the kv v2 vault in vault that contains
  # your plex token
  vault_path = "plex"

  # this bit is optional. It's the names of the Plex users that should be
  # considered "you" if multiple people use this Plex server.
  users = ["me", "otherme"]
}

# this block is optional
# if it's excluded, spotify won't be checked
spotify {
  # this attribute is optional, and will default to "spotify"
  # it's the key inside the kv v2 vault in vault that contains your spotify
  # token, client ID, and client secret
  vault_path = "spotify"

  # this attribute is optional, and will default to "0.0.0.0:8765". It's the IP
  # and port you want the web server git-now-playing needs to temporarily stand
  # up to receive the Spotify authorization callback on to listen on
  auth_callback_addr = "0.0.0.0:8765"
}

You'll also need to set up Vault. As mentioned, you're gonna want a kv secrets engine (v2) in Vault set up to hold the sensitive credentials, because writing secrets to config files makes me anxious.

If you want to grant a Vault token that has the least possible access (you should!) you can use this policy:

path "git-now-playing/data/*" {
  capabilities = ["read", "patch"]
}

You're going to want to set up the following credentials:

(Note: for all these examples, we're using git-now-playing as the mount_path of your Vault secrets engine. Replace it with whatever you're using. We're also using the default vault_paths for each service. Replace them with whatever you're using if you're not using the defaults.)

Spotify

$ vault kv put git-now-playing/spotify client_id=$SPOTIFY_CLIENT_ID client_secret=$SPOTIFY_CLIENT_SECRET redirect_url=$SPOTIFY_REDIRECT_URL

You're gonna need to set up a Spotify app to do this bit. You can do that here. $SPOTIFY_CLIENT_ID and $SPOTIFY_CLIENT_ID are on the main application page after you create it. For $SPOTIFY_REDIRECT_URL, you're going to need to add a callback URL to your app. You gotta click "Edit Settings" to do this. Make the callback URL http://localhost:8765/ or whatever will reach the auth_callback_addr configured in the spotify block of your HCL config.

The first time you run git-now-playing, it's gonna ask you to authorize your application. Click the link and it'll take care of the rest. After this happens, the token will be stored in Vault, and should manage itself. Sorta. Though now that I think about it, I don't think I ever wrote the bit where it updates the token after it gets refreshed. Whoooops. Probably should do that.

Plex

This bit is easier. You just need to get your hands on a Plex token and then run

$ vault kv put git-now-playing/plex token=$PLEX_TOKEN

Running

Run this program as a background process. I use systemd. This bit is left as an exercise for the reader for now. You need to pass in a VAULT_TOKEN environment variable with the Vault token that git-now-playing can use to read and update secrets with. So running it looks like this:

$ VAULT_TOKEN={vault token here} git-now-playing /path/to/config.hcl

Setting Up Your Commit Template

To set up the output as the default template for your git commit messages, run:

$ git config --global commit.template ~/.config/gitmessage

If you used the output block in your HCL config, use the path there instead of ~/.config/gitmessage.

License

This software is licensed under the MIT license, and I'd like to direct your attention to the bits about no liability or warranty. This software is a bad idea that I ran with and I think you probably shouldn't use it because it's deeply cursed.

Similar Resources

A command-line tool that makes git easier to use with GitHub.

hub is a command line tool that wraps git in order to extend it with extra features and commands that make working with GitHub easier. For an official

Jan 1, 2023

A tool to monitor git repositories and automatically pull & push changes

git-o-matic A tool to monitor git repositories and automatically pull & push changes Installation Packages & Binaries Arch Linux: gitomatic Binaries f

Dec 20, 2022

SQL interface to git repositories, written in Go. https://docs.sourced.tech/gitbase

gitbase gitbase, is a SQL database interface to Git repositories. This project is now part of source{d} Community Edition, which provides the simplest

Dec 25, 2022

Fast and powerful Git hooks manager for any type of projects.

Fast and powerful Git hooks manager for any type of projects.

Lefthook The fastest polyglot Git hooks manager out there Fast and powerful Git hooks manager for Node.js, Ruby or any other type of projects. Fast. I

Jan 4, 2023

Implementation of git internals from scratch in Go language

Implementation of git internals from scratch in Go language

This project is part of a learning exercise to implement a subset of "git" commands. It can be used to create and maintain git objects, such as blobs, trees, commits, references and tags.

Nov 27, 2022

A Simple and Comprehensive Vulnerability Scanner for Container Images, Git Repositories and Filesystems. Suitable for CI

A Simple and Comprehensive Vulnerability Scanner for Container Images, Git Repositories and Filesystems. Suitable for CI

A Simple and Comprehensive Vulnerability Scanner for Containers and other Artifacts, Suitable for CI. Abstract Trivy (tri pronounced like trigger, vy

Jan 9, 2023

go mod vendor lets you check in your dependencies to git, but that's both bloaty (for developers) and tedious (remembering to update it).

go-mod-archiver Afraid of being unable to build historical versions of your Go program? go mod vendor lets you check in your dependencies to git, but

Dec 1, 2022

Quickly clone git repositories into a nested folders like GOPATH.

cl cl clones git repositories into nested folders like GOPATH and outputs the path of the cloned directory. Example: cl https://github.com/foo/bar Is

Nov 30, 2022

Switch between your git profiles easily

Switch between your git profiles easily

Git Profile Switcher Switch between your git profiles easily Install With Brew brew install theykk/tap/git-switcher With golang go get github.com/the

Dec 11, 2022
Comments
  • 📖 README

    📖 README

    Gotta set up a README talking about how to install and use this thing.

    • Downloading (probably should publish some binaries, huh?)
    • Setting up Vault
    • Writing the config file
    • Getting the Spotify API token
    • Getting Plex tokens
    • Running as a daemon
    • Configuring git
  • 🤔 Consider invoking this on a git hook instead of running it as a daemon?

    🤔 Consider invoking this on a git hook instead of running it as a daemon?

    So @dstaley pointed out that, in theory, this could be run as a pre-commit hook instead of being run as a background daemon.

    Pros:

    • I'm not making API requests every 5 seconds and writing to disk every few minutes
    • Spotify would probably appreciate it
    • There's now an operator in the loop for failures so when, e.g., I forget to restart the systemd service after unlocking Vault on a server restart, there's an actual error at commit time instead of getting wrong/no info

    Cons:

    • The API requests are now blocking for committing, meaning I'm introducing a potentially seconds-long delay between git commit and the editor popping up
    • I'd have to actually do something, because it's already written the other way

    This is probably the Right Way To Do Things, and I'll end up doing it some day when I get annoyed enough, ugggh.

  • ⚒️ Add a CLI tool for extracting info between two revisions

    ⚒️ Add a CLI tool for extracting info between two revisions

    We should be able to pass in any two git refs (tag, branch, commit, etc.) and then pull all the music logged in between those two refs. This would let us have "release playlists", containing all the songs (ordered by frequency? ordered by date? ordered by both?) that developers listened to during a release.

🥄A simple generator for semantic git messages.

?? Tablespoon EXPERIMENTAL PREVIEW A simple generator for semantic git messages. Installation | Contributing Tablespoon is a simple generator which ca

Jul 22, 2022
Git with a cup of tea, painless self-hosted git service
Git with a cup of tea, painless self-hosted git service

Gitea - Git with a cup of tea View the chinese version of this document Purpose The goal of this project is to make the easiest, fastest, and most pai

Jan 2, 2023
ReGit: A Tiny Git-Compatible Git Implementation written in Golang

ReGit is a tiny Git implementation written in Golang. It uses the same underlying file formats as Git. Therefore, all the changes made by ReGit can be checked by Git.

Oct 31, 2022
A Git RPC service for handling all the git calls made by GitLab
A Git RPC service for handling all the git calls made by GitLab

Quick Links: Roadmap | Want to Contribute? | GitLab Gitaly Issues | GitLab Gitaly Merge Requests | Gitaly is a Git RPC service for handling all the gi

Nov 13, 2021
A simple cli tool for switching git user easily inspired by Git-User-Switch
A simple cli tool for switching git user easily inspired by Git-User-Switch

gitsu A simple cli tool for switching git user easily inspired by Git-User-Switch Installation Binary releases are here. Homebrew brew install matsuyo

Dec 31, 2022
Removes unnecessarily saved git objects to optimize the size of the .git directory.

Git Repo Cleaner Optimizes the size of the .git directory by removing all of the files that are unnecessarily-still-saved as part of the git history.

Mar 24, 2022
Gum - Git User Manager (GUM) - Switch between git user profiles
Gum - Git User Manager (GUM) - Switch between git user profiles

Git User Manager (GUM) Add your profile info to config.yaml Build project: go bu

Feb 14, 2022
Gogs is a painless self-hosted Git service
Gogs is a painless self-hosted Git service

Gogs - A painless self-hosted Git service 简体中文 ?? Vision The Gogs (/gɑgz/) project aims to build a simple, stable and extensible self-hosted Git servi

Jan 9, 2023
A highly extensible Git implementation in pure Go.
A highly extensible Git implementation in pure Go.

go-git is a highly extensible git implementation library written in pure Go. It can be used to manipulate git repositories at low level (plumbing) or

Jan 8, 2023
commit/branch/workdir explorer for git

gitin gitin is a commit/branch/status explorer for git gitin is a minimalist tool that lets you explore a git repository from the command line. You ca

Dec 31, 2022