HASH 0cf4f07ab027
DATE 2026-07-11
SUBJECT media: add spotify and jam join helper
FILES 3 CHANGED
HASH 0cf4f07ab027
DATE 2026-07-11
SUBJECT media: add spotify and jam join helper
FILES 3 CHANGED
┌─ modules/home/nixos/media/music.nix ───────────────────────────────────────┐
│ diff --git a/modules/home/nixos/media/music.nix b/modules/home/nixos/media/music.n │
│ ix │
│ index 03c462b..3f8221f 100644 │
│ --- a/modules/home/nixos/media/music.nix │
│ +++ b/modules/home/nixos/media/music.nix │
│ @@ -14,6 +14,7 @@ │
│ inherit (osConfig.age.secrets) spotify_key; │
│ inherit (config.ooknet) binds; │
│ inherit (ook) color; │
│ + spotifyMime."x-scheme-handler/spotify" = ["spotify.desktop"]; │
│ in { │
│ config = mkIf (elem "media" profiles) { │
│ home.packages = attrValues { │
│ @@ -21,9 +22,15 @@ in { │
│ (pkgs) │
│ alsa-utils │
│ mpv │
│ + spotify │
│ ; │
│ }; │
│ │
│ + xdg.mimeApps = { │
│ + associations.added = spotifyMime; │
│ + defaultApplications = spotifyMime; │
│ + }; │
│ + │
│ ooknet.binds.spotify = { │
│ launch = "${binds.terminalLaunch} spotify_player"; │
│ next = "spotify_player playback next"; │
└────────────────────────────────────────────────────────────────────────────────────┘
┌─ ...es/home/nixos/media/music.nix ───┐
│ diff --git a/modules/home/nixos/media/music. │
│ nix b/modules/home/nixos/media/music.nix │
│ index 03c462b..3f8221f 100644 │
│ --- a/modules/home/nixos/media/music.nix │
│ +++ b/modules/home/nixos/media/music.nix │
│ @@ -14,6 +14,7 @@ │
│ inherit (osConfig.age.secrets) spotify_ke │
│ y; │
│ inherit (config.ooknet) binds; │
│ inherit (ook) color; │
│ + spotifyMime."x-scheme-handler/spotify" = │
│ ["spotify.desktop"]; │
│ in { │
│ config = mkIf (elem "media" profiles) { │
│ home.packages = attrValues { │
│ @@ -21,9 +22,15 @@ in { │
│ (pkgs) │
│ alsa-utils │
│ mpv │
│ + spotify │
│ ; │
│ }; │
│ │
│ + xdg.mimeApps = { │
│ + associations.added = spotifyMime; │
│ + defaultApplications = spotifyMime; │
│ + }; │
│ + │
│ ooknet.binds.spotify = { │
│ launch = "${binds.terminalLaunch} spo │
│ tify_player"; │
│ next = "spotify_player playback next" │
│ ; │
└──────────────────────────────────────────────┘
┌─ modules/home/nixos/tools/default.nix ─────────────────────────────────────┐
│ diff --git a/modules/home/nixos/tools/default.nix b/modules/home/nixos/tools/defau │
│ lt.nix │
│ index f2c5b77..51581da 100644 │
│ --- a/modules/home/nixos/tools/default.nix │
│ +++ b/modules/home/nixos/tools/default.nix │
│ @@ -13,5 +13,6 @@ │
│ ./nemo.nix │
│ ./qtscrcpy.nix │
│ ./discordify.nix │
│ + ./join-jam.nix │
│ ]; │
│ } │
└────────────────────────────────────────────────────────────────────────────────────┘
┌─ .../home/nixos/tools/default.nix ───┐
│ diff --git a/modules/home/nixos/tools/defaul │
│ t.nix b/modules/home/nixos/tools/default.nix │
│ index f2c5b77..51581da 100644 │
│ --- a/modules/home/nixos/tools/default.nix │
│ +++ b/modules/home/nixos/tools/default.nix │
│ @@ -13,5 +13,6 @@ │
│ ./nemo.nix │
│ ./qtscrcpy.nix │
│ ./discordify.nix │
│ + ./join-jam.nix │
│ ]; │
│ } │
└──────────────────────────────────────────────┘
┌─ modules/home/nixos/tools/join-jam.nix ────────────────────────────────────┐
│ diff --git a/modules/home/nixos/tools/join-jam.nix b/modules/home/nixos/tools/join │
│ -jam.nix │
│ new file mode 100644 │
│ index 0000000..c6b3d1e │
│ --- /dev/null │
│ +++ b/modules/home/nixos/tools/join-jam.nix │
│ @@ -0,0 +1,49 @@ │
│ +{ │
│ + lib, │
│ + pkgs, │
│ + osConfig, │
│ + ... │
│ +}: let │
│ + inherit (lib) mkIf elem; │
│ + inherit (osConfig.ooknet.workstation) profiles; │
│ + join-jam = pkgs.writeShellApplication { │
│ + name = "join-jam"; │
│ + runtimeInputs = with pkgs; [wl-clipboard curl spotify]; │
│ + text = '' │
│ + ua="Mozilla/5.0 (X11; Linux x86_64)" │
│ + url=$(wl-paste) │
│ + │
│ + if [ -z "$url" ]; then │
│ + echo "clipboard is empty" >&2 │
│ + exit 1 │
│ + fi │
│ + │
│ + # keep the ?si= token, its the join credential │
│ + case "$url" in │
│ + spotify:socialsession:* | *open.spotify.com/socialsession/*) │
│ + target="$url" ;; │
│ + *spotify.link/* | *spotify.app.link/*) │
│ + target=$(curl -sIL -A "$ua" "$url" \ │
│ + | tr -d '\r' \ │
│ + | grep -oiE 'https://open\.spotify\.com/socialsession/[^[:space:]]+' │
│ \ │
│ + | head -n1 || true) ;; │
│ + *) │
│ + echo "clipboard is not a spotify jam link: $url" >&2 │
│ + exit 1 ;; │
│ + esac │
│ + │
│ + if [ -z "$target" ]; then │
│ + echo "couldn't find a jam in that link: $url" >&2 │
│ + exit 1 │
│ + fi │
│ + │
│ + echo "joining jam: $target" │
│ + # already-running spotify forwards the url and returns nonzero, thats fine │
│ + spotify "$target" || true │
│ + ''; │
│ + }; │
│ +in { │
│ + config = mkIf (elem "media" profiles) { │
│ + home.packages = [join-jam]; │
│ + }; │
│ +} │
└────────────────────────────────────────────────────────────────────────────────────┘
┌─ ...home/nixos/tools/join-jam.nix ───┐
│ diff --git a/modules/home/nixos/tools/join-j │
│ am.nix b/modules/home/nixos/tools/join-jam.n │
│ ix │
│ new file mode 100644 │
│ index 0000000..c6b3d1e │
│ --- /dev/null │
│ +++ b/modules/home/nixos/tools/join-jam.nix │
│ @@ -0,0 +1,49 @@ │
│ +{ │
│ + lib, │
│ + pkgs, │
│ + osConfig, │
│ + ... │
│ +}: let │
│ + inherit (lib) mkIf elem; │
│ + inherit (osConfig.ooknet.workstation) pro │
│ files; │
│ + join-jam = pkgs.writeShellApplication { │
│ + name = "join-jam"; │
│ + runtimeInputs = with pkgs; [wl-clipboar │
│ d curl spotify]; │
│ + text = '' │
│ + ua="Mozilla/5.0 (X11; Linux x86_64)" │
│ + url=$(wl-paste) │
│ + │
│ + if [ -z "$url" ]; then │
│ + echo "clipboard is empty" >&2 │
│ + exit 1 │
│ + fi │
│ + │
│ + # keep the ?si= token, its the join c │
│ redential │
│ + case "$url" in │
│ + spotify:socialsession:* | *open.spo │
│ tify.com/socialsession/*) │
│ + target="$url" ;; │
│ + *spotify.link/* | *spotify.app.link │
│ /*) │
│ + target=$(curl -sIL -A "$ua" "$url │
│ " \ │
│ + | tr -d '\r' \ │
│ + | grep -oiE 'https://open\.spot │
│ ify\.com/socialsession/[^[:space:]]+' \ │
│ + | head -n1 || true) ;; │
│ + *) │
│ + echo "clipboard is not a spotify │
│ jam link: $url" >&2 │
│ + exit 1 ;; │
│ + esac │
│ + │
│ + if [ -z "$target" ]; then │
│ + echo "couldn't find a jam in that l │
│ ink: $url" >&2 │
│ + exit 1 │
│ + fi │
│ + │
│ + echo "joining jam: $target" │
│ + # already-running spotify forwards th │
│ e url and returns nonzero, thats fine │
│ + spotify "$target" || true │
│ + ''; │
│ + }; │
│ +in { │
│ + config = mkIf (elem "media" profiles) { │
│ + home.packages = [join-jam]; │
│ + }; │
│ +} │
└──────────────────────────────────────────────┘
[ BACK TO LOG ]
──────────────────────────────────────────────────────────────────────────────────────
OOKNET
────────────────────────────────────────────────
OOKNET